Exemple #1
0
    def perform_http_connection(request, url, port):
        try:
            conn = httplib.HTTPConnection(url, port)
            headers = dict(request.headers.items())

            conn.request(request.method,
                         request.url,
                         body=request.content,
                         headers=headers)
            httplib_response = conn.getresponse()

            headers = ODictCaseless.from_httplib_headers(
                httplib_response.getheaders())
            response = HTTPResponse(code=httplib_response.status,
                                    content=httplib_response.read(),
                                    msg="",
                                    httpversion=(1, 1),
                                    headers=headers)
            return response
        except Exception as ex:
            error("Error Happened")
            error(ex)
            error("method: %s\nurl: %s\nbody: --\nheaders: --" %
                  (request.method, request.url))
            return None
def from_intercepted_response(cls, response):
    headers = ODictCaseless.from_httplib_headers(response.headers)
    response = cls(code=response.status,
                   content=response.body_response(),
                   msg="",
                   httpversion=(1, 1),
                   headers=headers)
    return response
Exemple #3
0
def from_intercepted_response(cls, response):
    headers = ODictCaseless.from_httplib_headers(response.headers)
    response = cls(code=response.status,
                   content=response.body_response(),
                   msg="",
                   httpversion=(1, 1),
                   headers=headers)
    return response
Exemple #4
0
    def perform_http_connection(request, url, port):
        try:
            conn = httplib.HTTPConnection(url, port)
            headers = dict(request.headers.items())

            conn.request(request.method, request.url,
                         body=request.content, headers=headers)
            httplib_response = conn.getresponse()

            headers = ODictCaseless.from_httplib_headers(httplib_response.getheaders())
            response = HTTPResponse(code=httplib_response.status,
                                    content=httplib_response.read(),
                                    msg="",
                                    httpversion=(1, 1),
                                    headers=headers)
            return response
        except Exception as ex:
            error("Error Happened")
            error(ex)
            error("method: %s\nurl: %s\nbody: --\nheaders: --" %
                  (request.method, request.url))
            return None