Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/git/dumb.py
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | Returns: | ||||
Whether the dumb protocol is supported. | Whether the dumb protocol is supported. | ||||
""" | """ | ||||
if not repo_url.startswith("http"): | if not repo_url.startswith("http"): | ||||
return False | return False | ||||
http_client = DumbHttpGitClient(repo_url) | http_client = DumbHttpGitClient(repo_url) | ||||
url = http_client.get_url("info/refs?service=git-upload-pack") | url = http_client.get_url("info/refs?service=git-upload-pack") | ||||
response = http_client.get(url) | response = http_client.get(url) | ||||
content_type = response.getheader("Content-Type") | |||||
return ( | return ( | ||||
response.status in (200, 304,) | response.status in (200, 304,) | ||||
# header is not mandatory in protocol specification | # header is not mandatory in protocol specification | ||||
and response.content_type is None | and (content_type is None or not content_type.startswith("application/x-git-")) | ||||
or not response.content_type.startswith("application/x-git-") | |||||
) | ) | ||||
class GitObjectsFetcher: | class GitObjectsFetcher: | ||||
"""Git objects fetcher using dumb HTTP protocol. | """Git objects fetcher using dumb HTTP protocol. | ||||
Fetches a set of git objects for a repository according to its archival | Fetches a set of git objects for a repository according to its archival | ||||
state by Software Heritage and provides iterators on them. | state by Software Heritage and provides iterators on them. | ||||
▲ Show 20 Lines • Show All 137 Lines • Show Last 20 Lines |