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

Function scgi_canon

modules/proxy/mod_proxy_scgi.c:177–224  ·  view source on GitHub ↗

* Canonicalize scgi-like URLs. */

Source from the content-addressed store, hash-verified

175 * Canonicalize scgi-like URLs.
176 */
177static int scgi_canon(request_rec *r, char *url)
178{
179 char *host, sport[sizeof(":65535")];
180 const char *err, *path;
181 apr_port_t port, def_port;
182 core_dir_config *d = ap_get_core_module_config(r->per_dir_config);
183 int flags = d->allow_encoded_slashes && !d->decode_encoded_slashes ? PROXY_CANONENC_NOENCODEDSLASHENCODING : 0;
184
185 if (ap_cstr_casecmpn(url, SCHEME "://", sizeof(SCHEME) + 2)) {
186 return DECLINED;
187 }
188 url += sizeof(SCHEME); /* Keep slashes */
189
190 port = def_port = SCGI_DEF_PORT;
191
192 err = ap_proxy_canon_netloc(r->pool, &url, NULL, NULL, &host, &port);
193 if (err) {
194 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00857)
195 "error parsing URL %s: %s", url, err);
196 return HTTP_BAD_REQUEST;
197 }
198
199 if (port != def_port) {
200 apr_snprintf(sport, sizeof(sport), ":%u", port);
201 }
202 else {
203 sport[0] = '\0';
204 }
205
206 if (ap_strchr(host, ':')) { /* if literal IPv6 address */
207 host = apr_pstrcat(r->pool, "[", host, "]", NULL);
208 }
209
210 path = ap_proxy_canonenc_ex(r->pool, url, strlen(url), enc_path, flags,
211 r->proxyreq);
212 if (!path) {
213 return HTTP_BAD_REQUEST;
214 }
215
216 r->filename = apr_pstrcat(r->pool, "proxy:" SCHEME "://", host, sport, "/",
217 path, NULL);
218
219 if (apr_table_get(r->subprocess_env, "proxy-scgi-pathinfo")) {
220 r->path_info = apr_pstrcat(r->pool, "/", path, NULL);
221 }
222
223 return OK;
224}
225
226
227/*

Callers

nothing calls this directly

Calls 5

ap_cstr_casecmpnFunction · 0.85
ap_proxy_canon_netlocFunction · 0.85
ap_strchrFunction · 0.85
ap_proxy_canonenc_exFunction · 0.85

Tested by

no test coverage detected