示例#1
0
文件: http.py 项目: fvennetier/oiopy
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
示例#2
0
文件: http.py 项目: carriercomm/oiopy
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
示例#3
0
    def putrequest(self, method, url, skip_host=0, skip_accept_encoding=0):
        '''Send a request to the server.

        :param method: specifies an HTTP request method, e.g. 'GET'.
        :param url: specifies the object being requested, e.g. '/index.html'.
        :param skip_host: if True does not add automatically a 'Host:' header
        :param skip_accept_encoding: if True does not add automatically an
           'Accept-Encoding:' header
        '''
        self._method = method
        self._path = url
        return HTTPConnection.putrequest(self, method, url, skip_host,
                                         skip_accept_encoding)
示例#4
0
    def putrequest(self, method, url, skip_host=0, skip_accept_encoding=0):
        '''Send a request to the server.

        :param method: specifies an HTTP request method, e.g. 'GET'.
        :param url: specifies the object being requested, e.g. '/index.html'.
        :param skip_host: if True does not add automatically a 'Host:' header
        :param skip_accept_encoding: if True does not add automatically an
           'Accept-Encoding:' header
        '''
        self._method = method
        self._path = url
        return HTTPConnection.putrequest(self, method, url, skip_host,
                                         skip_accept_encoding)
示例#5
0
 def putrequest(self, method, url, skip_host=0, skip_accept_encoding=0):
     self._method = method
     self._path = url
     return HTTPConnection.putrequest(self, method, url, skip_host,
                                      skip_accept_encoding)
示例#6
0
 def putrequest(self, method, url, skip_host=0, skip_accept_encoding=0):
     self._method = method
     self._path = url
     return HTTPConnection.putrequest(self, method, url, skip_host,
                                      skip_accept_encoding)
示例#7
0
 def putrequest(self, method, url, skip_host=0, skip_accept_encoding=0):
     self._method = method  # save method for getexpect method
     return BaseHTTPConnection.putrequest(self, method, url, skip_host,
                                          skip_accept_encoding)