Beispiel #1
0
def http_connect(host, method, path, headers=None):
    conn = HTTPConnection(host)
    conn.path = path
    conn.putrequest(method, path)
    if headers:
        for header, value in headers.iteritems():
            conn.putheader(header, str(value))
    conn.endheaders()
    return conn
Beispiel #2
0
def http_connect(host, method, path, headers=None):
    conn = HTTPConnection(host)
    conn.path = path
    conn.putrequest(method, path)
    if headers:
        for header, value in headers.items():
            if isinstance(value, (list, tuple)):
                for k in value:
                    conn.putheader(header, str(k))
            else:
                conn.putheader(header, str(value))
    conn.endheaders()
    return conn
Beispiel #3
0
 def putheader(self, header, value):
     if not isinstance(header, bytes):
         header = header.encode('latin-1')
     HTTPConnection.putheader(self, header, value)
Beispiel #4
0
 def putheader(self, header, value):
     if header.lower() == 'x-cf-trans-id':
         self._txn_id = value
     return HTTPConnection.putheader(self, header, value)