Process an http monitor.
961287
def _worker_http(self, monitor):
        
        self.thread_debug("process_http", data=monitor, module='handler')
        query = monitor['query']
        method = query['method'].lower()
        self.stats.http_run += 1
        try:
            target = monitor['target']
            url = 'http://{host}:{port}{path}'.format(path=query['path'], **target)
            response = {
                'url': url,
                'status': 'failed',
                'result': {},
                'monitor': monitor,
                'message': 'did not meet expected result or no expected result defined',
                'elapsedms': monitor['timeout']*1000,
                'code':0
            }

            # not sed_env_dict -- we do not want to xref headers
            headers = query.get('headers', {})
            for elem in headers:
                headers[elem] = self.sed_env(headers[elem], {}, '')

            res = response['result'] = getattr(requests, method)(url,
                                                                 headers=headers,
                                                                 timeout=monitor['timeout'])
            response['code'] = res.status_code
            response['elapsedms'] = res.elapsed.total_seconds() * 1000
            if 'response-code' in monitor['expect']:
                if int(monitor['expect']['response-code']) == res.status_code:
                    response['message'] = ''
                    response['status'] = 'ok'
                else: # abort with failure, do not pass go
                    return response

            if 'content' in monitor['expect']:
                if monitor['expect']['content'] in res.text:
                    response['message'] = ''
                    response['status'] = 'ok'
                else: # abort with failure, do not pass go
                    return response

            if 'regex' in monitor['expect']:
                if re.search(monitor['expect']['regex'], res.text):
                    response['message'] = ''
                    response['status'] = 'ok'
                else: # abort with failure, do not pass go
                    return response

        except requests.exceptions.Timeout:
            response['message'] = 'timeout'
        except requests.exceptions.ConnectionError:
            response['message'] = 'connect-failed'
            response['elapsedms'] = -1
        return response
416368
def process_exception(self, request, exception):
        
        if isinstance(exception, HttpRedirectRequest):
            return HttpResponseRedirect(exception.url, status=exception.status)
        else:
            return None
895471
def handle(self, sock, read_data, path, headers):
        ""
        try:
            sock.sendall("HTTP/1.0 %s %s\r\nConnection: close\r\nContent-length: 0\r\n\r\n" % (self.code, responses.get(self.code, "Unknown")))
        except socket.error, e:
            if e.errno != errno.EPIPE:
                raise
863735
def get_monitor_ping(request):
    """"""
    response = d1_gmn.app.views.util.http_response_with_boolean_true_type()
    d1_gmn.app.views.headers.add_http_date_header(response)
    return response
201620
def process_response(self, request, response):
        """"""
        profiler = getattr(request, 'profiler', None)
        if profiler:
            profiler.close()
            params = request.REQUEST
            stats = hotshot.stats.load(request.statsfile.name)
            queries = connection.queries
            if (params.get('show_queries', False)
                and params.get('show_stats', '1') == '1'):
                response = display_queries(request, stats, queries)
            else:
                response = display_stats(request, stats, queries)
        return response
478990
async def _response_handler(self):
        """"""
        if self.debug is True:
            if self.debug is True:
                print("listenning response!")
        while True:
            try:
                res = await self.reader.readuntil(self.SEPARATOR)
            except:
                raise
            else:
                response = self.decoder(res)
                self._status_code_check(response)
27292
def _http_call(self, url, method, **kwargs):
        """"""
        logging.debug("Request[{0}]: {1}".format(method, url))
        start_time = datetime.datetime.now()

        logging.debug("Header: {0}".format(kwargs['headers']))
        logging.debug("Params: {0}".format(kwargs['data']))
        response = requests.request(method, url, verify=False, **kwargs)

        duration = datetime.datetime.now() - start_time
        logging.debug("Response[{0:d}]: {1}, Duration: {2}.{3}s.".format(
            response.status_code, response.reason, duration.seconds,
            duration.microseconds))
        return response
124625
def web(host, port):
    """"""
    from .webserver.web import get_app
    get_app().run(host=host, port=port)
28723
function execute(req, res) {
  req.conn.monitor(this);
  res.send(null, Constants.OK);
}
245064
def process_streamers(self):
        """"""

        # Check for any triggered streamers and pass them to stream manager
        in_progress = self._stream_manager.in_progress()
        triggered = self.graph.check_streamers(blacklist=in_progress)

        for streamer in triggered:
            self._stream_manager.process_streamer(streamer, callback=self._handle_streamer_finished)
318839
def process_response(self, request, response):
        """"""

        # For debug only.
        if not settings.DEBUG:
            return response

        # Check for responses where the data can't be inserted.
        content_encoding = response.get('Content-Encoding', '')
        content_type = response.get('Content-Type', '').split(';')[0]
        if any((getattr(response, 'streaming', False),
                'gzip' in content_encoding,
                content_type not in _HTML_TYPES)):
            return response

        content = force_text(response.content, encoding=settings.DEFAULT_CHARSET)

        pattern = re.escape('</body>')
        bits = re.split(pattern, content, flags=re.IGNORECASE)

        if len(bits) > 1:
            bits[-2] += debug_payload(request, response, self.view_data)
            response.content = "</body>".join(bits)
            if response.get('Content-Length', None):
                response['Content-Length'] = len(response.content)

        return response
490517
public function processSapiRequest()
    {
        $http = $this->builder->components()->http();
        $serverRequest = $http->sapiServerRequest();

        $response = $this->processor()->process($serverRequest);

        $http->output(
            $response,
            $this->builder->context()->httpContext()
        );
    }
396793
def monitor(self, timeout):
        

        def check(self, timeout):
            time.sleep(timeout)
            self.stop()
        wather = threading.Thread(target=check)
        wather.setDaemon(True)
        wather.start()
582751
def socket_monitor_loop(self):
        '''  '''
        try:
            while True:
                gevent.socket.wait_read(self.socket.fileno())

                self._handle_log_rotations()
                self.capture_packet()
        finally:
            self.clean_up()
1010678
def process(self, data, **kwargs):
        """"""
        data = super(RequestIdProcessor, self).process(data, **kwargs)
        if g and hasattr(g, 'request_id'):
            tags = data.get('tags', {})
            tags['request_id'] = g.request_id
            data['tags'] = tags
        return data
368448
def _StatusUpdateThreadMain(self):
    """"""
    while self._status_update_active:
      # Make a local copy of the PIDs in case the dict is changed by
      # the main thread.
      for pid in list(self._process_information_per_pid.keys()):
        self._CheckStatusAnalysisProcess(pid)

      self._UpdateForemanProcessStatus()

      if self._status_update_callback:
        self._status_update_callback(self._processing_status)

      time.sleep(self._STATUS_UPDATE_INTERVAL)
679109
def monitor():
    """"""
    log = logging.getLogger(__name__)
    loop = asyncio.get_event_loop()
    asyncio.ensure_future(console(loop, log))
    loop.run_forever()