diff options
author | Michael Adam <obnox@samba.org> | 2013-11-16 15:09:48 +0100 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2013-11-16 15:09:48 +0100 |
commit | 98f77ef8c7f7e9d329beac1bcced5eea4fd17f19 (patch) | |
tree | de762aed5d08dc7bdec02441255927b410d17781 /src/reqs.c | |
parent | 69c348ce6d553a2172b6cb126268826b7b637082 (diff) | |
download | tinyproxy-98f77ef8c7f7e9d329beac1bcced5eea4fd17f19.tar.gz tinyproxy-98f77ef8c7f7e9d329beac1bcced5eea4fd17f19.zip |
BB#106: add default_port argument to extract_http_url and rename it to extract_url
There is in fact nothing http-specific any more about this function, hence
the rename. The input has been stripped of the <proto>:// header anyways.
This in preparation of fixing bug BB#106: ssl fails with literal ipv6 addrs.
Signed-off-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'src/reqs.c')
-rw-r--r-- | src/reqs.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -186,10 +186,14 @@ static int strip_return_port (char *host) } /* - * Pull the information out of the URL line. This will handle both HTTP - * and FTP (proxied) URLs. + * Pull the information out of the URL line. + * This expects urls with the initial '<proto>://' + * part stripped and hence can handle http urls, + * (proxied) ftp:// urls and https-requests that + * come in without the proto:// part via CONNECT. */ -static int extract_http_url (const char *url, struct request_s *request) +static int extract_url (const char *url, int default_port, + struct request_s *request) { char *p; int port; @@ -216,7 +220,7 @@ static int extract_http_url (const char *url, struct request_s *request) /* Find a proper port in www.site.com:8001 URLs */ port = strip_return_port (request->host); - request->port = (port != 0) ? port : HTTP_PORT; + request->port = (port != 0) ? port : default_port; /* Remove any surrounding '[' and ']' from IPv6 literals */ p = strrchr (request->host, ']'); @@ -413,7 +417,7 @@ BAD_REQUEST_ERROR: { char *skipped_type = strstr (url, "//") + 2; - if (extract_http_url (skipped_type, request) < 0) { + if (extract_url (skipped_type, HTTP_PORT, request) < 0) { indicate_http_error (connptr, 400, "Bad Request", "detail", "Could not parse URL", "url", url, NULL); |