通过代理到api.github.com的httplib请求给出502错误

时间:2016-05-18 14:08:35

标签: python http-proxy httplib

我正在尝试使用httplib通过代理服务器向api.github.com发出请求,但收到502错误。仅供参考,curl, requests, wget工作正常。

c = HTTPSConnection(host='192.168.1.1', port='8080')
c.set_tunnel('api.github.com', headers={'Proxy-Authorization': 'Basic ...'})
rh =  {'Authorization': 'Basic ...', 'User-Agent': 'prboard/Python'}
url = '/users/kumarvaradarajulu/repos'
c.request('GET', url, 'null', rh)
r = c.getresponse()

我的状态为502,输出如下所示。

<!DOCTYPE html>\n<!--\n\nHello future GitHubber! I bet you\'re here to remove those nasty inline styles,\nDRY up these templates and make \'em nice and re-usable, right?\n\nPlease, don\'t. https://github.com/styleguide/templates/2.0\n\n-->\n<html>\n  <head>\n    <meta http-equiv="Content-type" content="text/html; charset=utf-8">\n    <title>Unicorn! &middot; GitHub</title>\n 

0 个答案:

没有答案