summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2013-11-16 15:09:48 +0100
committerMichael Adam <obnox@samba.org>2013-11-16 15:09:48 +0100
commit98f77ef8c7f7e9d329beac1bcced5eea4fd17f19 (patch)
treede762aed5d08dc7bdec02441255927b410d17781
parent69c348ce6d553a2172b6cb126268826b7b637082 (diff)
downloadtinyproxy-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>
-rw-r--r--src/reqs.c14
1 files changed, 9 insertions, 5 deletions
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 '<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);