Render a request by forwarding it to the proxied server.
495089
def render(self, request):
        
        # set up and evaluate a connection to the target server
        if self.port == 80:
            host = self.host
        else:
            host = "%s:%d" % (self.host, self.port)
        request.requestHeaders.addRawHeader('host', host)
        request.content.seek(0, 0)
        qs = urlparse.urlparse(request.uri)[4]
        if qs:
            rest = self.path + '?' + qs
        else:
            rest = self.path

        global_self = self.getGlobalSelf()

        clientFactory = self.proxyClientFactoryClass(
            request.method, rest, request.clientproto,
            request.getAllHeaders(), request.content.read(), request,
            global_self  # this is new
        )
        self.reactor.connectTCP(self.host, self.port, clientFactory)

        return NOT_DONE_YET
1085153
function execute(req, res) {
  var proxy = req.exec ? req.exec.proxy : this.proxy;
  res.send(null, proxy(req, res));
}
1362877
function maybeProxy(jolokiaUrl, url) {
        if (jolokiaUrl && _.startsWith(jolokiaUrl, 'proxy/')) {
            log.debug("Jolokia URL is proxied, applying proxy to: ", url);
            return join('proxy', url);
        }
        var origin = window.location['origin'];
        if (url && (_.startsWith(url, 'http') && !_.startsWith(url, origin))) {
            log.debug("Url doesn't match page origin: ", origin, " applying proxy to: ", url);
            return join('proxy', url);
        }
        log.debug("No need to proxy: ", url);
        return url;
    }
718695
function requestFilter() {
  return function(req, res, next) {
    if (!_isJsonRequest(req) && !_isVoidFilterRoute(req)) {
      return _renderAppShell(res);
    }
    next();
  };
}
504307
def serve(self, host='', port=8000, no_documentation=False, display_intro=True):
        """"""
        if no_documentation:
            api = self.server(None)
        else:
            api = self.server()

        if display_intro:
            print(INTRO)

        httpd = make_server(host, port, api)
        print("Serving on {0}:{1}...".format(host, port))
        httpd.serve_forever()
726364
async def open(self, port, proxied_path=''):
        
        if not proxied_path.startswith('/'):
            proxied_path = '/' + proxied_path

        client_uri = self.get_client_uri('ws', port, proxied_path)
        headers = self.request.headers

        def message_cb(message):
            """
            Callback when the backend sends messages to us

            We just pass it back to the frontend
            """
            # Websockets support both string (utf-8) and binary data, so let's
            # make sure we signal that appropriately when proxying
            self._record_activity()
            if message is None:
                self.close()
            else:
                self.write_message(message, binary=isinstance(message, bytes))

        def ping_cb(data):
            """
            Callback when the backend sends pings to us.

            We just pass it back to the frontend.
            """
            self._record_activity()
            self.ping(data)

        async def start_websocket_connection():
            self.log.info('Trying to establish websocket connection to {}'.format(client_uri))
            self._record_activity()
            request = httpclient.HTTPRequest(url=client_uri, headers=headers)
            self.ws = await pingable_ws_connect(request=request,
                on_message_callback=message_cb, on_ping_callback=ping_cb)
            self._record_activity()
            self.log.info('Websocket connection established to {}'.format(client_uri))

        ioloop.IOLoop.current().add_callback(start_websocket_connection)
925503
function _proxy(rule, metas) {
  var opts = _getRequestOpts(metas.req, rule);
  var request = httpsSyntax.test(rule.replace) ? httpsReq : httpReq;

  var pipe = request(opts, function (res) {
    res.headers.via = opts.headers.via;
    metas.res.writeHead(res.statusCode, res.headers);
    res.on('error', function (err) {
      metas.next(err);
    });
    res.pipe(metas.res);
  });

  pipe.on('error', function (err) {
    metas.next(err);
  });

  if(!metas.req.readable) {
    pipe.end();
  } else {
    metas.req.pipe(pipe);
  }
}
1119636
def render_GET(self, request):
        """"""
        if not request.args:
            request.setHeader("Content-Type", "text/plain")
            return self.get_status_text()
        else:
            self.handle(request)
            return NOT_DONE_YET
660680
function renderExpressRoute(req, res, next) {
  var hrStart = process.hrtime(),
    site = res.locals.site,
    prefix = `${getExpressRoutePrefix(site)}/_uris/`,
    pageReference = `${prefix}${buf.encode(req.hostname + req.baseUrl + req.path)}`;

  return module.exports.renderUri(pageReference, req, res, hrStart)
    .catch((error) => {
      if (error.name === 'NotFoundError') {
        log('error', `could not find resource ${req.uri}`, {
          message: error.message
        });
        next();
      } else {
        next(error);
      }
    });
}
1158936
def serve_http(self):
        
        start_http_server(port=self.options.port,
                          addr=str(self.options.address))
704181
def render(self, request, instance, **kwargs):
        
        if instance.get_item():
            return super(LinkPlugin, self).render(request, instance, **kwargs)
        return ""
1181742
protected function render() {
		if ($this->getSite()->hasRedirectUrl()) {
			$this->getSite()->redirect();
		}
		//send system messages to the ViewRenderer
		$this->getSite()->getViewRenderer()->registerAppContextProperty("systemMessages", $this->getSite()->getSystemMessages());

		//display the content
		$this->getSite()->getViewRenderer()->renderView();
	}
59378
def serve_websocket(request, port):
    """"""
    env = request.environ

    # Send HTTP response 101 Switch Protocol downstream
    uwsgi.websocket_handshake(env['HTTP_SEC_WEBSOCKET_KEY'], env.get('HTTP_ORIGIN', ''))

    # Map the websocket URL to the upstream localhost:4000x Notebook instance
    parts = urlparse(request.url)
    parts = parts._replace(scheme="ws", netloc="localhost:{}".format(port))
    url = urlunparse(parts)

    # Proxy initial connection headers
    headers = [(header, value) for header, value in request.headers.items() if header.lower() in CAPTURE_CONNECT_HEADERS]

    logger.info("Connecting to upstream websockets: %s, headers: %s", url, headers)

    ws = ProxyClient(url, headers=headers)
    ws.connect()

    # TODO: Will complain loudly about already send headers - how to abort?
    return httpexceptions.HTTPOk()
348494
def render_GET(self, request):
        
        request.setHeader(b'accept-ranges', b'bytes')

        producer = self.makeProducer(request, self.fileObject)

        if request.method == b'HEAD':
            return b''

        def done(ign):
            producer.stopProducing()

        request.notifyFinish().addCallbacks(done, done)
        producer.start()
        # and make sure the connection doesn't get closed
        return server.NOT_DONE_YET
270806
public void renderView(HttpServerRequest request, JsonObject params) {
		renderView(request, params, null, null, 200);
	}
243539
def _generate_request_handler_proxy(handler_class, handler_args, name):
    """"""

    @scope.inject
    def request_handler_wrapper(app, handler, **kwargs):
        handler = handler_class(app, handler.request, **handler_args)
        handler._execute([], **kwargs)
    request_handler_wrapper.__name__ = name
    request_handler_wrapper.handler_class = handler_class
    request_handler_wrapper.handler_args = handler_args

    return request_handler_wrapper
814815
def renderHTTP(self, context):
        
        request = IRequest(context)
        request = StylesheetRewritingRequestWrapper(
            request, self.installedOfferingNames, self.rootURL)
        context.remember(request, IRequest)
        return self.resource.renderHTTP(context)