MCPcopy Create free account
hub / github.com/apache/httpd / open_stream

Function open_stream

modules/http2/h2_proxy_session.c:825–934  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

823}
824
825static apr_status_t open_stream(h2_proxy_session *session, const char *url,
826 request_rec *r, int standalone,
827 h2_proxy_stream **pstream)
828{
829 h2_proxy_stream *stream;
830 apr_uri_t puri;
831 const char *authority, *scheme, *path, *orig_host;
832 apr_status_t status;
833 proxy_dir_conf *dconf;
834
835 stream = apr_pcalloc(r->pool, sizeof(*stream));
836
837 stream->pool = r->pool;
838 stream->url = url;
839 stream->r = r;
840 stream->cfront = r->connection;
841 stream->standalone = standalone;
842 stream->session = session;
843 stream->state = H2_STREAM_ST_IDLE;
844
845 stream->input = apr_brigade_create(stream->pool, stream->cfront->bucket_alloc);
846 stream->output = apr_brigade_create(stream->pool, stream->cfront->bucket_alloc);
847
848 stream->req = h2_proxy_req_create(1, stream->pool);
849
850 status = apr_uri_parse(stream->pool, url, &puri);
851 if (status != APR_SUCCESS)
852 return status;
853
854 scheme = (strcmp(puri.scheme, "h2")? "http" : "https");
855 orig_host = apr_table_get(r->headers_in, "Host");
856 if (orig_host == NULL) {
857 orig_host = r->hostname;
858 }
859
860 dconf = ap_get_module_config(r->per_dir_config, &proxy_module);
861 if (dconf->preserve_host) {
862 authority = orig_host;
863 if (!authority) {
864 /* Duplicate mod_proxy behaviour if ProxyPreserveHost is
865 * used but an "HTTP/0.9" request is received without a
866 * Host: header */
867 authority = r->server->server_hostname;
868 ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, APLOGNO(10511)
869 "incoming HTTP/0.9 request (with no Host header) "
870 "and preserve host set, "
871 "forcing hostname to be %s for uri %s",
872 authority, r->uri);
873 apr_table_setn(r->headers_in, "Host", authority);
874 }
875 }
876 else {
877 authority = puri.hostname;
878 if (!ap_strchr_c(authority, ':') && puri.port
879 && apr_uri_port_of_scheme(scheme) != puri.port) {
880 /* port info missing and port is not default for scheme: append */
881 authority = apr_psprintf(stream->pool, "%s:%d", authority, puri.port);
882 }

Callers 1

h2_proxy_session_submitFunction · 0.85

Calls 4

h2_proxy_req_createFunction · 0.85
ap_get_module_configFunction · 0.85
ap_strchr_cFunction · 0.85
h2_proxy_req_makeFunction · 0.85

Tested by

no test coverage detected