From 98f77ef8c7f7e9d329beac1bcced5eea4fd17f19 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sat, 16 Nov 2013 15:09:48 +0100 Subject: 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 :// header anyways. This in preparation of fixing bug BB#106: ssl fails with literal ipv6 addrs. Signed-off-by: Michael Adam --- src/reqs.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/reqs.c b/src/reqs.c index f527c57..4f37124 100644 --- a/src/reqs.c +++ b/src/reqs.c @@ -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 '://' + * 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); -- cgit v1.2.3