Refactor: put form/multipart encoding in Requester

And remove my fucking credentials from git! (Password changed, btw)
This commit is contained in:
Vincent Jacques
2013-02-05 19:47:52 +01:00
parent 39c10b1544
commit 3cbc81551a
2 changed files with 45 additions and 26 deletions
+3 -20
View File
@@ -1067,9 +1067,6 @@ class Repository(github.GithubObject.GithubObject):
assert isinstance(callback, (str, unicode)), callback
assert secret is github.GithubObject.NotSet or isinstance(secret, (str, unicode)), secret
boundary = "----------------------------3c3ba8b523b2"
eol = "\r\n"
post_parameters = {
"hub.mode": mode,
"hub.topic": "https://github.com/" + self._full_name + "/events/" + event,
@@ -1078,25 +1075,11 @@ class Repository(github.GithubObject.GithubObject):
if secret is not github.GithubObject.NotSet:
post_parameters["hub.secret"] = secret
input = ""
for name, value in post_parameters.iteritems():
input += "--" + boundary + eol
input += "Content-Disposition: form-data; name=\"" + name + "\"" + eol
input += eol
input += value + eol
input += "--" + boundary + "--" + eol
requestHeaders = {
"Authorization": "Basic amFjcXVldjY6Y2xhdmllcg==",
"Content-Type": "multipart/form-data; boundary=" + boundary,
"Content-Length": len(input),
}
responseHeaders, output = self._requester.requestRawAndCheck(
responseHeaders, output = self._requester.requestMultipartAndCheck(
"POST",
"/hub",
requestHeaders,
input,
None,
post_parameters,
)
@property