Fix request-line argument when talking to SSL server over proxy
Hrvoje Niksic <[email protected]> Sat, 07 May 2005 01:25:26 +0200
| Newsgroups | gmane.comp.web.wget.patches |
|---|---|
| Message-ID | <[email protected]> |
When using CONNECT to download https://server/dir/file over https_proxy, Wget sends "GET https://server/dir/file HTTP/1.0" to the server instead of "GET /dir/file HTTP/1.0". While HTTP/1.1 servers support this (as required by the HTTP/1.1 spec), the HTTP/1.0 ones don't, and besides, the 1.1 ones might reject it when coming in a 1.0 request. This patch, submitted by Charles Lane in a slightly different form, fixes the problem. 2005-05-07 Hrvoje Niksic <[email protected]> * http.c (gethttp): When tunnelling SSL traffic over proxy with CONNECT, we're really talking to the remote server directly. Because of this, the request-line argument must be the URL path rather than the whole URL, as it would be when using regular proxies. Reported by Charles Lane. Index: src/http.c =================================================================== RCS file: /pack/anoncvs/wget/src/http.c,v retrieving revision 1.178 diff -u -r1.178 http.c --- src/http.c 2005/05/06 17:16:15 1.178 +++ src/http.c 2005/05/06 23:22:57 @@ -1216,6 +1216,7 @@ req = request_new (); { + char *meth_arg; const char *meth = "GET"; if (*dt & HEAD_ONLY) meth = "HEAD"; @@ -1224,8 +1225,18 @@ /* Use the full path, i.e. one that includes the leading slash and the query string. E.g. if u->path is "foo/bar" and u->query is "param=value", full_path will be "/foo/bar?param=value". */ - request_set_method (req, meth, - proxy ? xstrdup (u->url) : url_full_path (u)); + if (proxy +#ifdef HAVE_SSL + /* When using SSL over proxy, CONNECT establishes a direct + connection to the HTTPS server. Therefore use the same + argument as when talking to the server directly. */ + && u->scheme != SCHEME_HTTPS +#endif + ) + meth_arg = xstrdup (u->url); + else + meth_arg = url_full_path (u); + request_set_method (req, meth, meth_arg); } request_set_header (req, "Referer", (char *) hs->referer, rel_none);