Beispiel #1
0
    def process_response(self, request, response):
        try:
            d = {'startedDateTime': None,
                 'time': 0.0,
                 'request': harlib.HarRequest(request),
                 'response': harlib.HarResponse(response)}

            s = json.dumps(harlib.HarEntry(d).to_json(with_content=False))
            logger.info(s)
        except Exception as err:
            logger.error("%s %s" % (type(err), repr(err)))

        return response
Beispiel #2
0
    def test_3_mess_up_httplib(self):
        self.conn.request("GET", "/get")
        resp = self.conn.getresponse()

        # Mess stuff up so it is different than default
        resp.debuglevel = 3
        resp.strict = 1
        resp.version = 9
        resp.status = 418
        resp.reason = "I'm a teapot"

        har_resp = harlib.HarEntry(resp)

        to_resp = har_resp.encode(http_client.HTTPResponse)
        self.assertEqualHttplibHTTPResponse(to_resp, resp)
Beispiel #3
0
 def test_2_to_requests(self):
     har_resp = harlib.HarEntry(self.resp)
     to_resp = har_resp.encode(requests.Response)
     self.assertEqualResponse(to_resp, self.resp)
Beispiel #4
0
 def test_2_to_httplib(self):
     self.conn.request("GET", "/get")
     resp = self.conn.getresponse()
     har_resp = harlib.HarEntry(resp)
     to_resp = har_resp.encode(http_client.HTTPResponse)
     self.assertEqualHttplibHTTPResponse(to_resp, resp)