Skip to content

Commit

Permalink
Fix handling of custom headers in http_method.
Browse files Browse the repository at this point in the history
  • Loading branch information
JNRowe committed Feb 1, 2013
1 parent 915b2bb commit 38923cc
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions hubugs/utils.py
Expand Up @@ -320,18 +320,17 @@ def setup_environment(args):

def http_method(url, method='GET', params=None, body=None, headers=None,
model=None, is_json=True):
lheaders = HEADERS.copy()
if headers:
headers.update(HEADERS)
else:
headers = HEADERS
lheaders.update(headers)
if not isinstance(url, (str, unicode)) or not url.startswith('http'):
url = '%s/repos/%s/issues%s%s' % (args.host_url, args.project,
'/' if url else '', url)
if params:
url += '?' + urlencode(params)
if is_json and body:
body = json.dumps(body)
r, c = http.request(url, method=method, body=body, headers=headers)
r, c = http.request(url, method=method, body=body, headers=lheaders)
if is_json:
c = json.loads(c.decode('utf-8'))
if str(r.status)[0] == '4':
Expand Down

0 comments on commit 38923cc

Please sign in to comment.