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

Function proxy_wstunnel_canon

modules/proxy/mod_proxy_wstunnel.c:61–158  ·  view source on GitHub ↗

* Canonicalise http-like URLs. * scheme is the scheme for the URL * url is the URL starting with the first '/' * def_port is the default port for this scheme. */

Source from the content-addressed store, hash-verified

59 * def_port is the default port for this scheme.
60 */
61static int proxy_wstunnel_canon(request_rec *r, char *url)
62{
63 proxyws_dir_conf *dconf = ap_get_module_config(r->per_dir_config,
64 &proxy_wstunnel_module);
65 char *host, *path, sport[7];
66 char *search = NULL;
67 const char *err;
68 char *scheme;
69 apr_port_t port, def_port;
70
71 if (can_fallback_to_proxy_http && dconf->fallback_to_proxy_http) {
72 ap_log_rerror(APLOG_MARK, APLOG_TRACE5, 0, r, "canon fallback");
73 return DECLINED;
74 }
75
76 /* ap_port_of_scheme() */
77 if (ap_cstr_casecmpn(url, "ws:", 3) == 0) {
78 url += 3;
79 scheme = "ws:";
80 def_port = apr_uri_port_of_scheme("http");
81 }
82 else if (ap_cstr_casecmpn(url, "wss:", 4) == 0) {
83 url += 4;
84 scheme = "wss:";
85 def_port = apr_uri_port_of_scheme("https");
86 }
87 else {
88 return DECLINED;
89 }
90
91 port = def_port;
92 ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, r, "canonicalising URL %s", url);
93
94 /*
95 * do syntactic check.
96 * We break the URL into host, port, path, search
97 */
98 err = ap_proxy_canon_netloc(r->pool, &url, NULL, NULL, &host, &port);
99 if (err) {
100 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(02439) "error parsing URL %s: %s",
101 url, err);
102 return HTTP_BAD_REQUEST;
103 }
104
105 /*
106 * now parse path/search args, according to rfc1738:
107 * process the path. With proxy-nocanon set (by
108 * mod_proxy) we use the raw, unparsed uri
109 */
110 if (apr_table_get(r->notes, "proxy-nocanon")) {
111 path = url; /* this is the raw path */
112 }
113 else if (apr_table_get(r->notes, "proxy-noencode")) {
114 path = url; /* this is the encoded path already */
115 search = r->args;
116 }
117 else {
118 core_dir_config *d = ap_get_core_module_config(r->per_dir_config);

Callers

nothing calls this directly

Calls 7

ap_get_module_configFunction · 0.85
ap_cstr_casecmpnFunction · 0.85
ap_proxy_canon_netlocFunction · 0.85
ap_proxy_canonenc_exFunction · 0.85
ap_scan_vchar_obstextFunction · 0.85
ap_strchr_cFunction · 0.85

Tested by

no test coverage detected