Example #1
0
 def log_req_resp(request, response):
     '''
     Send the request and the response to the output manager.
     '''        
     fr = create_fuzzable_request(
                          request, add_headers=request.unredirected_hdrs)
     if isinstance(response, httpResponse.httpResponse):
         resp = response
     else:
         resp = httpResponse.from_httplib_resp(
                               response, original_url=request.url_object)
         resp.setId(response.id)
     
     om.out.logHttp(fr, resp)
Example #2
0
    def store_in_cache(request, response):
        hi = HistoryItem()

        # Set the request
        req = create_fuzzable_request(request, add_headers=request.unredirected_hdrs)
        hi.request = req

        # Set the response
        resp = httpResponse.from_httplib_resp(response, original_url=request.url_object)
        resp.setId(response.id)
        resp.setAlias(gen_hash(request))
        hi.response = resp

        # Now save them
        try:
            hi.save()
        except KeyboardInterrupt, k:
            raise k
Example #3
0
            # Everything went well!
            rdata = req.get_data()
            if not rdata:
                msg = ('%s %s returned HTTP code "%s" - id: %s' % 
                (req.get_method(), urllib.unquote_plus(original_url), res.code,
                 res.id))
            else:                
                msg = ('%s %s with data: "%s" returned HTTP code "%s" - id: %s'
                % (req.get_method(), original_url, urllib.unquote_plus(rdata),
                   res.code, res.id))

            if hasattr(res, 'from_cache'):
                msg += ' - from cache.'
            om.out.debug(msg)

            httpResObj = from_httplib_resp(res, original_url=original_url_inst)
            httpResObj.setId(id=res.id)
            httpResObj.setWaitTime(time.time()-start_time)

            # Let the upper layers know that this response came from the
            # local cache.
            if isinstance(res, CachedResponse):
                httpResObj.setFromCache(True)

            # Clear the log of failed requests; this request is done!
            req_id = id(req)
            if req_id in self._errorCount:
                del self._errorCount[req_id]
            self._zeroGlobalErrorCount()

            if grep: