Log complete http response, including response1 and payload
186853
def stage_http_response2(self, payload):
        """"""

        # required because http code uses sending all None to reset
        # parameters. We ignore that
        if not self._http_response_version and not payload:
            return
        if self.enabled and self.http_detail_level is not None and \
                self.httplogger.isEnabledFor(logging.DEBUG):
            if self._http_response_headers:
                header_str = \
                    ' '.join('{0}:{1!r}'.format(k, v)
                             for k, v in self._http_response_headers.items())
            else:
                header_str = ''

            if self.http_detail_level == 'summary':
                upayload = ""
            elif self.http_maxlen and (len(payload) > self.http_maxlen):
                upayload = (_ensure_unicode(payload[:self.http_maxlen]) +
                            '...')
            else:
                upayload = _ensure_unicode(payload)

            self.httplogger.debug('Response:%s %s:%s %s %s\n    %s',
                                  self._http_response_conn_id,
                                  self._http_response_status,
                                  self._http_response_reason,
                                  self._http_response_version,
                                  header_str, upayload)
470590
def parse_response(self, response):
        
        status = response.status_code
        if response.ok:
            data = response.json()
            return HttpResponse(ok=response.ok, status=status, errors=None, data=data)
        else:
            try:
                errors = response.json()
            except ValueError:
                errors = response.content
            return HttpResponse(ok=response.ok, status=status, errors=errors, data=None)
1318423
def _process_response(self, request, response):
        """"""
        log_format = self._get_log_format(request)
        if not log_format:
            return response

        params = self._get_parameters_from_request(request)
        # log a message displayed to user
        messages = django_messages.get_messages(request)
        result_message = None
        if messages:
            result_message = ', '.join('%s: %s' % (message.tags, message)
                                       for message in messages)
        elif 'action' in request.POST:
            result_message = request.POST['action']
        params['message'] = result_message
        params['http_status'] = response.status_code

        self.OPERATION_LOG.info(log_format, params)

        return response
820148
def _request_finished(self, reply):
        """"""
        url = to_text_string(reply.url().toEncoded(), encoding='utf-8')

        if url in self._paths:
            path = self._paths[url]
        if url in self._workers:
            worker = self._workers[url]

        if url in self._head_requests:
            error = reply.error()
#            print(url, error)
            if error:
                logger.error(str(('Head Reply Error:', error)))
                worker.sig_download_finished.emit(url, path)
                worker.sig_finished.emit(worker, path, error)
                return

            self._head_requests.pop(url)
            start_download = not bool(error)
            header_pairs = reply.rawHeaderPairs()
            headers = {}

            for hp in header_pairs:
                headers[to_text_string(hp[0]).lower()] = to_text_string(hp[1])

            total_size = int(headers.get('content-length', 0))

            # Check if file exists
            if os.path.isfile(path):
                file_size = os.path.getsize(path)

                # Check if existing file matches size of requested file
                start_download = file_size != total_size

            if start_download:
                # File sizes dont match, hence download file
                qurl = QUrl(url)
                request = QNetworkRequest(qurl)
                self._get_requests[url] = request
                reply = self._manager.get(request)

                error = reply.error()
                if error:
                    logger.error(str(('Reply Error:', error)))

                reply.downloadProgress.connect(
                    lambda r, t, w=worker: self._progress(r, t, w))
            else:
                # File sizes match, dont download file or error?
                worker.finished = True
                worker.sig_download_finished.emit(url, path)
                worker.sig_finished.emit(worker, path, None)
        elif url in self._get_requests:
            data = reply.readAll()
            self._save(url, path, data)
1340285
def access_log(request, response)
      return if access_log_dest.nil?

      @@access_logger ||= init_access_log
      code = response.respond_to?(:code) ? response.code.to_s : "success"
      size = response.respond_to?(:size) ? response.size : response.length
      output = [request.ip_address, request.selector, request.input, code.to_s, size].join("\t")

      @@access_logger.debug output
    end
433801
def _handler_http(self, result):
        
        monitor = result['monitor']
        self.thread_debug("process_http", data=monitor, module='handler')
        self.stats.http_handled += 1

        # splunk will pick this up
        logargs = {
            'type':"metric",
            'endpoint': result['url'],
            'pipeline': monitor['pipeline'],
            'service': monitor['service'],
            'instance': monitor['instance'],
            'status': result['status'],
            'elapsed-ms': round(result['elapsedms'], 5),
            'code': result['code']
        }
        self.NOTIFY(result['message'], **logargs)

        # if our status has changed, also update Reflex Engine
        if result['status'] != self.instances[monitor['instance']]['status']:
            # do some retry/counter steps on failure?
            self.instances[monitor['instance']]['status'] = result['status']
            self.rcs.patch('instance',
                           monitor['instance'],
                           {'status': result['status']})
346925
private String getResponseContent(CachingClientHttpResponseWrapper response) throws IOException {
        if (response != null) {
            StringBuilder builder = new StringBuilder();
            
            builder.append("HTTP/1.1 "); // TODO get Http version from message
            builder.append(response.getStatusCode());
            builder.append(" ");
            builder.append(response.getStatusText());
            builder.append(NEWLINE);
            
            appendHeaders(response.getHeaders(), builder);
            
            builder.append(NEWLINE);
            builder.append(response.getBodyContent());
            
            return builder.toString();
        } else {
            return "";
        }
    }
1094997
def _finalize_response(self, response):
        

        res = HttpResponse(content=response.content,
                           content_type=self._get_content_type())
        # status_code is set separately to allow zero
        res.status_code = response.code
        return res
1249807
function logConsole() {

    return function (req, res, next) {

        console.log('Received request: ' + req.method + ' ' + req.originalUrl);

        next();
    };
}
434474
def process_request_result(self, prepare_response_func=None):
        

        now = datetime.utcnow()
        # TODO: move into separate method
        if self.config['debug_post']:
            post = self.config['post'] or self.config['multipart_post']
            if isinstance(post, dict):
                post = list(post.items())
            if post:
                if isinstance(post, six.string_types):
                    post = make_str(post[:self.config['debug_post_limit']],
                                    errors='ignore') + b'...'
                else:
                    items = normalize_http_values(
                        post, charset=self.config['charset'])
                    new_items = []
                    for key, value in items:
                        if len(value) > self.config['debug_post_limit']:
                            value = value[
                                :self.config['debug_post_limit']] + b'...'
                        else:
                            value = value
                        new_items.append((key, value))
                    post = '\n'.join('%-25s: %s' % x for x in new_items)
            if post:
                logger_network.debug('[%02d] POST request:\n%s\n',
                                     self.request_counter, post)

        # It's important to delete old POST data after request is performed.
        # If POST data is not cleared then next request will try to use them
        # again!
        self.reset_temporary_options()

        if prepare_response_func:
            self.doc = prepare_response_func(self.transport, self)
        else:
            self.doc = self.transport.prepare_response(self)

        self.doc.process_grab(self)

        if self.config['reuse_cookies']:
            self.cookies.update(self.doc.cookies)

        self.doc.timestamp = now

        self.config['charset'] = self.doc.charset

        if self.config['log_file']:
            with open(self.config['log_file'], 'wb') as out:
                out.write(self.doc.body)

        if self.config['cookiefile']:
            self.cookies.save_to_file(self.config['cookiefile'])

        if self.config['reuse_referer']:
            self.config['referer'] = self.doc.url

        self.copy_request_data()

        # Should be called after `copy_request_data`
        if self.config['log_dir']:
            self.save_dumps()

        return self.doc
1282159
function logJolokiaStackTrace(response) {
        var stacktrace = response.stacktrace;
        if (stacktrace) {
            var operation = Core.pathGet(response, ['request', 'operation']) || "unknown";
            log.info("Operation", operation, "failed due to:", response['error']);
        }
    }
113456
def logs(self, num=None, source=None, ps=None, tail=False):
        """"""

        # Bootstrap payload package.
        payload = {'logplex': 'true'}

        if num:
            payload['num'] = num

        if source:
            payload['source'] = source

        if ps:
            payload['ps'] = ps

        if tail:
            payload['tail'] = 1

        # Grab the URL of the logplex endpoint.
        r = self._h._http_resource(
            method='GET',
            resource=('apps', self.name, 'logs'),
            data=payload
        )

        # Grab the actual logs.
        r = requests.get(r.content.decode("utf-8"), verify=False, stream=True)

        if not tail:
            return r.content
        else:
            # Return line iterator for tail!
            return r.iter_lines()
583393
def _parse_response(response, post_request=False):
        
        try:
            data = response.json()
        except:
            msg = 'Unhandled HTTP %s response, shown truncated below:\n%s...' % (
                response.status_code, response.text[:50]
            )
            raise ValueError(msg)

        if not response.ok:
            utils.error_message_and_exit(None, data)

        if post_request and not data['success']:
            raise Exception('Asmaster Api Error: [%s]' % data['error'])

        return data
138085
function loggingMiddleware(req, res, next) {
  logRequest(req, res);
  setupResponseInterceptors(req, res);
  next();
}
1356314
def process_response(self, request, response):
        
        try:
            log_dict = create_log_dict(request, response)

            # add the request time to the log_dict; if no start time is
            # available, use -1 as NA value
            request_time = (
                time.time() - self.start_time if hasattr(self, 'start_time')
                and self.start_time else -1)
            log_dict.update({'request_time': request_time})

            is_request_time_too_high = (
                request_time > float(settings.LOGUTILS_REQUEST_TIME_THRESHOLD))
            use_sql_info = settings.DEBUG or is_request_time_too_high

            log_msg = create_log_message(log_dict, use_sql_info, fmt=False)

            if is_request_time_too_high:
                logger.warning(log_msg, log_dict, extra=log_dict)
            else:
                logger.info(log_msg, log_dict, extra=log_dict)
        except Exception as e:
            logger.exception(e)

        return response
201873
public void log(HttpRequest request,
                    HttpResponse response,
                    int responseLength)
    {
        try{
            // ignore ignorables
            if (_ignorePathMap != null &&
                _ignorePathMap.getMatch(request.getPath()) != null)
                return;

            // log the rest
            if (_fileOut==null)
                return;

            StringBuffer buf = new StringBuffer(160);
            
            String addr = null;
            if(_preferProxiedForAddress)
            {
                // If header is not present, addr will remain null ...
                addr = request.getField(HttpFields.__XForwardedFor);
            }
            if(addr == null)
                addr = request.getRemoteAddr();
            buf.append(addr);
            
            buf.append(" - ");
            String user = request.getAuthUser();
            buf.append((user==null)?"-":user);
            buf.append(" [");
            buf.append(_logDateCache.format(request.getTimeStamp()));
            buf.append("] \"");
            buf.append(request.getMethod());
            buf.append(' ');
            buf.append(request.getURI());
            buf.append(' ');
            buf.append(request.getVersion());
            buf.append("\" ");
            int status=response.getStatus();    
            buf.append((char)('0'+((status/100)%10)));
            buf.append((char)('0'+((status/10)%10)));
            buf.append((char)('0'+(status%10)));
            if (responseLength>=0)
            {
                buf.append(' ');
                if (responseLength>99999)
                    buf.append(Integer.toString(responseLength));
                else
                {
                    if (responseLength>9999) 
                        buf.append((char)('0'+((responseLength/10000)%10)));
                    if (responseLength>999) 
                        buf.append((char)('0'+((responseLength/1000)%10)));
                    if (responseLength>99) 
                        buf.append((char)('0'+((responseLength/100)%10)));
                    if (responseLength>9) 
                        buf.append((char)('0'+((responseLength/10)%10)));
                    buf.append((char)('0'+(responseLength%10)));
                }
                buf.append(' ');
            }
            else
                buf.append(" - ");

            String log =buf.toString();
            synchronized(_writer)
            {
                _writer.write(log);
                if (_extended)
                {
                    logExtended(request,response,_writer);
                    if (!_logCookies)
                        _writer.write(" -");
                }
                
                if (_logCookies)
                {
                    Cookie[] cookies = request.getCookies();
                    if (cookies==null || cookies.length==0)
                        _writer.write(" -");
                    else
                    {
                        _writer.write(" \"");
                        for (int i=0;i<cookies.length;i++)
                        {
                            if (i!=0)
                                _writer.write(';');
                            _writer.write(cookies[i].getName());
                            _writer.write('=');
                            _writer.write(cookies[i].getValue());
                        }
                        _writer.write("\"");
                    }
                }
                
                if (_logLatency)
                    _writer.write(" "+(System.currentTimeMillis()-request.getTimeStamp()));
                
                _writer.write(StringUtil.__LINE_SEPARATOR);
                _writer.flush();
            }
        }
        catch(IOException e)
        {
            log.warn(LogSupport.EXCEPTION,e);
        }
    }
839210
def RenderHttpResponse(request):
  """"""

  start_time = time.time()
  response = HTTP_REQUEST_HANDLER.HandleRequest(request)
  total_time = time.time() - start_time

  method_name = response.headers.get("X-API-Method", "unknown")
  if response.status_code == 200:
    status = "SUCCESS"
  elif response.status_code == 403:
    status = "FORBIDDEN"
  elif response.status_code == 404:
    status = "NOT_FOUND"
  elif response.status_code == 501:
    status = "NOT_IMPLEMENTED"
  else:
    status = "SERVER_ERROR"

  if request.method == "HEAD":
    metric_name = "api_access_probe_latency"
  else:
    metric_name = "api_method_latency"

  stats_collector_instance.Get().RecordEvent(
      metric_name, total_time, fields=(method_name, "http", status))

  return response