static void on_context_dispose(h2o_handler_t *_self, h2o_context_t *ctx) { struct rp_handler_t *self = (void*)_self; h2o_http1client_ctx_t *client_ctx = h2o_context_get_handler_context(ctx, &self->super); free(client_ctx); }
static int on_req(h2o_handler_t *_self, h2o_req_t *req) { struct rp_handler_t *self = (void *)_self; h2o_req_overrides_t *overrides = h2o_mem_alloc_pool(&req->pool, sizeof(*overrides)); const h2o_url_scheme_t *scheme; h2o_iovec_t *authority; /* setup overrides */ *overrides = (h2o_req_overrides_t){}; if (self->sockpool != NULL) { overrides->socketpool = self->sockpool; } else if (self->config.preserve_host) { overrides->hostport.host = self->upstream.host; overrides->hostport.port = h2o_url_get_port(&self->upstream); } overrides->location_rewrite.match = &self->upstream; overrides->location_rewrite.path_prefix = req->pathconf->path; overrides->client_ctx = h2o_context_get_handler_context(req->conn->ctx, &self->super); /* determine the scheme and authority */ if (self->config.preserve_host) { scheme = req->scheme; authority = &req->authority; } else { scheme = self->upstream.scheme; authority = &self->upstream.authority; } /* request reprocess */ h2o_reprocess_request(req, req->method, scheme, *authority, h2o_build_destination(req, self->upstream.path.base, self->upstream.path.len), overrides, 0); return 0; }
static int on_req(h2o_handler_t *_self, h2o_req_t *req) { struct rp_handler_t *self = (void*)_self; h2o_http1client_ctx_t *client_ctx = h2o_context_get_handler_context(req->conn->ctx, &self->super); if (self->sockpool != NULL) return h2o_proxy_send_with_pool(req, client_ctx, &self->upstream, self->sockpool); else return h2o_proxy_send(req, client_ctx, &self->upstream); }
static void on_context_dispose(h2o_handler_t *_self, h2o_context_t *ctx) { struct rp_handler_t *self = (void *)_self; struct rp_handler_context_t *handler_ctx = h2o_context_get_handler_context(ctx, &self->super); if (handler_ctx->client_ctx != NULL) free(handler_ctx->client_ctx); h2o_socketpool_unregister_loop(self->sockpool, ctx->loop); }
static void on_context_dispose(h2o_handler_t *_self, h2o_context_t *ctx) { struct rp_handler_t *self = (void *)_self; h2o_http1client_ctx_t *client_ctx = h2o_context_get_handler_context(ctx, &self->super); if (client_ctx == NULL) return; if (client_ctx->io_timeout != &ctx->proxy.io_timeout) { h2o_timeout_dispose(client_ctx->loop, client_ctx->io_timeout); free(client_ctx->io_timeout); } if (client_ctx->websocket_timeout != NULL) { h2o_timeout_dispose(client_ctx->loop, client_ctx->websocket_timeout); free(client_ctx->websocket_timeout); } free(client_ctx); }
static int on_req(h2o_handler_t *_self, h2o_req_t *req) { struct rp_handler_t *self = (void *)_self; h2o_req_overrides_t *overrides = h2o_mem_alloc_pool(&req->pool, *overrides, 1); struct rp_handler_context_t *handler_ctx = h2o_context_get_handler_context(req->conn->ctx, &self->super); /* setup overrides */ *overrides = (h2o_req_overrides_t){NULL}; overrides->connpool = &handler_ctx->connpool; overrides->location_rewrite.path_prefix = req->pathconf->path; overrides->use_proxy_protocol = self->config.use_proxy_protocol; overrides->client_ctx = handler_ctx->client_ctx; overrides->headers_cmds = self->config.headers_cmds; overrides->proxy_preserve_host = self->config.preserve_host; /* request reprocess (note: path may become an empty string, to which one of the target URL within the socketpool will be * right-padded when lib/core/proxy connects to upstream; see #1563) */ h2o_iovec_t path = h2o_build_destination(req, NULL, 0, 0); h2o_reprocess_request(req, req->method, req->scheme, req->authority, path, overrides, 0); return 0; }