Sync httplib2. Fix user-agent code so base libraries are listed after higher level apps/libraries user-agent.
This commit is contained in:
@@ -131,10 +131,9 @@ class OAuthCredentials(Credentials):
|
|||||||
headers = {}
|
headers = {}
|
||||||
headers.update(req.to_header())
|
headers.update(req.to_header())
|
||||||
if 'user-agent' in headers:
|
if 'user-agent' in headers:
|
||||||
headers['user-agent'] += ' '
|
headers['user-agent'] = self.user_agent + ' ' + headers['user-agent']
|
||||||
else:
|
else:
|
||||||
headers['user-agent'] = ''
|
headers['user-agent'] = self.user_agent
|
||||||
headers['user-agent'] += self.user_agent
|
|
||||||
return request_orig(uri, method, body, headers,
|
return request_orig(uri, method, body, headers,
|
||||||
redirections, connection_type)
|
redirections, connection_type)
|
||||||
|
|
||||||
|
@@ -55,9 +55,9 @@ from gettext import gettext as _
|
|||||||
import socket
|
import socket
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from httplib2 import socks
|
from httplib2 import socks
|
||||||
except ImportError:
|
except ImportError:
|
||||||
socks = None
|
socks = None
|
||||||
|
|
||||||
# Build the appropriate socket wrapper for ssl
|
# Build the appropriate socket wrapper for ssl
|
||||||
try:
|
try:
|
||||||
@@ -83,7 +83,7 @@ def has_timeout(timeout): # python 2.6
|
|||||||
__all__ = ['Http', 'Response', 'ProxyInfo', 'HttpLib2Error',
|
__all__ = ['Http', 'Response', 'ProxyInfo', 'HttpLib2Error',
|
||||||
'RedirectMissingLocation', 'RedirectLimit', 'FailedToDecompressContent',
|
'RedirectMissingLocation', 'RedirectLimit', 'FailedToDecompressContent',
|
||||||
'UnimplementedDigestAuthOptionError', 'UnimplementedHmacDigestAuthOptionError',
|
'UnimplementedDigestAuthOptionError', 'UnimplementedHmacDigestAuthOptionError',
|
||||||
'debuglevel']
|
'debuglevel', 'ProxiesUnavailableError']
|
||||||
|
|
||||||
|
|
||||||
# The httplib debug level, set to a non-zero value to get debug output
|
# The httplib debug level, set to a non-zero value to get debug output
|
||||||
@@ -125,6 +125,7 @@ class UnimplementedHmacDigestAuthOptionError(HttpLib2ErrorWithResponse): pass
|
|||||||
|
|
||||||
class RelativeURIError(HttpLib2Error): pass
|
class RelativeURIError(HttpLib2Error): pass
|
||||||
class ServerNotFoundError(HttpLib2Error): pass
|
class ServerNotFoundError(HttpLib2Error): pass
|
||||||
|
class ProxiesUnavailableError(HttpLib2Error): pass
|
||||||
|
|
||||||
# Open Items:
|
# Open Items:
|
||||||
# -----------
|
# -----------
|
||||||
@@ -721,6 +722,9 @@ class HTTPConnectionWithTimeout(httplib.HTTPConnection):
|
|||||||
def connect(self):
|
def connect(self):
|
||||||
"""Connect to the host and port specified in __init__."""
|
"""Connect to the host and port specified in __init__."""
|
||||||
# Mostly verbatim from httplib.py.
|
# Mostly verbatim from httplib.py.
|
||||||
|
if self.proxy_info and socks is None:
|
||||||
|
raise ProxiesUnavailableError(
|
||||||
|
'Proxy support missing but proxy use was requested!')
|
||||||
msg = "getaddrinfo returns an empty list"
|
msg = "getaddrinfo returns an empty list"
|
||||||
for res in socket.getaddrinfo(self.host, self.port, 0,
|
for res in socket.getaddrinfo(self.host, self.port, 0,
|
||||||
socket.SOCK_STREAM):
|
socket.SOCK_STREAM):
|
||||||
|
@@ -41,12 +41,13 @@ mainly to merge bug fixes found in Sourceforge
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
|
if getattr(socket, 'socket', None) is None:
|
||||||
|
raise ImportError('socket.socket missing, proxy support unusable')
|
||||||
|
|
||||||
import struct
|
import struct
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
if not hasattr(socket, 'socket'):
|
|
||||||
raise ImportError("Running on App Engine?")
|
|
||||||
|
|
||||||
PROXY_TYPE_SOCKS4 = 1
|
PROXY_TYPE_SOCKS4 = 1
|
||||||
PROXY_TYPE_SOCKS5 = 2
|
PROXY_TYPE_SOCKS5 = 2
|
||||||
PROXY_TYPE_HTTP = 3
|
PROXY_TYPE_HTTP = 3
|
||||||
|
Reference in New Issue
Block a user