Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Changing requests to urllib3 to be able to request raw paths #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions git-dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import gin
import os.path
import concurrent.futures
import urllib3
from urllib3.exceptions import InsecureRequestWarning


Expand Down Expand Up @@ -93,7 +94,12 @@ def createDir():
def gitFilesDownload(fileName):
print("Fetching: " + URL+fileName)
try:
downloaded = requests.get(URL+fileName, allow_redirects=False, headers=headers, verify=False).content
s = requests.Session( )
req = requests.Request(method='GET' ,url=URL+fileName, headers=headers)
prep = req.prepare()
prep.url = URL+fileName
downloaded = s.send(prep, verify=False).content

if len(downloaded) > 0 and (not ("<!DOCTYPE html>" in str(downloaded) or "<html>" in str(downloaded) or '<html lang="en">' in str(downloaded) or str(downloaded).isspace() or str(downloaded) == "")):
with open(outputFolder + ".git/" + fileName, "wb+") as f:
f.write(downloaded)
Expand Down Expand Up @@ -141,7 +147,12 @@ def filesDownloadMatchingSHA1(sha1):
endpoint = "objects/" + sha1[:2] + "/" + sha1[-38:]
print("Fetching: " + URL + endpoint)
try:
downloaded = requests.get(URL + endpoint, allow_redirects=False, headers=headers, verify=False).content
s = requests.Session( )
req = requests.Request(method='GET' ,url=URL + endpoint, headers=headers)
prep = req.prepare()
prep.url = URL + endpoint
downloaded = s.send(prep, verify=False).content

if len(downloaded) > 0 and (not ("<!DOCTYPE html>" in str(downloaded) or "<html>" in str(downloaded) or '<html lang="en">' in str(downloaded) or str(downloaded).isspace() or str(downloaded) == "")):
with open(outputFolder + ".git/" + endpoint, "wb+") as f:
f.write(downloaded)
Expand All @@ -168,7 +179,11 @@ def packFileDownload(line):
try:
endpoint = "objects/pack/" + line[-51:-1]
print("Fetching " + URL + endpoint)
downloaded = requests.get(URL + endpoint, allow_redirects=False, headers=headers, verify=False).content
s = requests.Session( )
req = requests.Request(method='GET' ,url=URL + endpoint, headers=headers)
prep = req.prepare()
prep.url = URL + endpoint
downloaded = s.send(prep, verify=False).content
if len(downloaded) > 0 and (not ("<!DOCTYPE html>" in str(downloaded) or "<html>" in str(downloaded) or '<html lang="en">' in str(downloaded) or str(downloaded).isspace() or str(downloaded) == "")):
with open(outputFolder + ".git/" + endpoint, "wb+") as packFile:
packFile.write(downloaded) # pack file
Expand All @@ -182,7 +197,11 @@ def idxFileDownload(line):
try:
endpoint = "objects/pack/" + line[-51:-5] + "idx"
print("Fetching " + URL + endpoint)
downloaded = requests.get(URL + endpoint, allow_redirects=False, headers=headers, verify=False).content
s = requests.Session( )
req = requests.Request(method='GET' ,url=URL + endpoint, headers=headers)
prep = req.prepare()
prep.url = URL + endpoint
downloaded = s.send(prep, verify=False).content
if len(downloaded) > 0 and (not ("<!DOCTYPE html>" in str(downloaded) or "<html>" in str(downloaded) or '<html lang="en">' in str(downloaded) or str(downloaded).isspace() or str(downloaded) == "")):
with open(outputFolder + ".git/" + endpoint, "wb+") as idxFile:
idxFile.write(downloaded) #idx file
Expand Down