w3m

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/w3m.git/
Log | Files | Refs | README

commit 1dd13ceda32fd7a813a4375edfd0b8a3b0b9fd84
parent 197256469ebf2b4e5a40cb7a6176937bf99a7ed1
Author: ukai <ukai>
Date:   Thu, 28 Feb 2002 16:15:41 +0000

[w3m-dev 03072] Proxy-Authorization (Re:  Re: https through proxy)
* file.c (loadGeneralFile) delete Proxy-Authorization set here
* fm.h (HR_FLAG_PROXY): added
* main.c (MAIN): need "Basic " for proxy_auth_cookie
* url.c (HTTPrequest): add seen_proxy_auth
	if proxy and no Proxy-Authorization: header seen and
	has proxy_auth_cookie, use it
* url.c (openURL): hr->flag |= HR_FLAG_PROXY

* file.c (loadGeneralFile) comment indent fix
* html.c (TagMAP): ditto
From: Fumitoshi UKAI <ukai@debian.or.jp>

Diffstat:
MChangeLog | 14++++++++++++++
Mfile.c | 6+-----
Mfm.h | 1+
Mhtml.c | 4++--
Mmain.c | 4+++-
Murl.c | 16+++++++++++++++-
6 files changed, 36 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,17 @@ +2002-03-01 Fumitoshi UKAI <ukai@debian.or.jp> + + * [w3m-dev 03072] Proxy-Authorization (Re: Re: https through proxy) + * file.c (loadGeneralFile) delete Proxy-Authorization set here + * fm.h (HR_FLAG_PROXY): added + * main.c (MAIN): need "Basic " for proxy_auth_cookie + * url.c (HTTPrequest): add seen_proxy_auth + if proxy and no Proxy-Authorization: header seen and + has proxy_auth_cookie, use it + * url.c (openURL): hr->flag |= HR_FLAG_PROXY + + * file.c (loadGeneralFile) comment indent fix + * html.c (TagMAP): ditto + 2002-02-28 Fumitoshi UKAI <ukai@debian.or.jp> * [w3m-dev 03070] Re: https through proxy diff --git a/file.c b/file.c @@ -1433,10 +1433,6 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, prevtrap = NULL; add_auth_cookie_flag = 0; - if (proxy_auth_cookie != NULL) { - pushText(extra_header, Sprintf("Proxy-Authorization: Basic %s\r\n", - proxy_auth_cookie->ptr)->ptr); - } load_doc: url_option.referer = referer; url_option.flag = flag; @@ -1566,7 +1562,7 @@ loadGeneralFile(char *path, ParsedURL *volatile current, char *referer, } if (t_buf == NULL) t_buf = newBuffer(INIT_BUFFER_WIDTH); -#if 0 /* USE_SSL */ +#if 0 /* USE_SSL */ if (IStype(f.stream) == IST_SSL) { Str s = ssl_get_certificate(f.stream, pu.host); if (s == NULL) diff --git a/fm.h b/fm.h @@ -675,6 +675,7 @@ typedef struct http_request { #define HR_COMMAND_HEAD 3 #define HR_FLAG_LOCAL 1 +#define HR_FLAG_PROXY 2 #define HTST_UNKNOWN 255 #define HTST_MISSING 254 diff --git a/html.c b/html.c @@ -134,8 +134,8 @@ TagInfo TagMAP[MAX_HTMLTAG] = { {"hr", ALST_HR, MAXA_HR, 0}, /* 16 HTML_HR */ {"dl", ALST_DL, MAXA_DL, 0}, /* 17 HTML_DL */ {"/dl", NULL, 0, TFLG_END}, /* 18 HTML_N_DL */ - {"dt", ALST_NOP, MAXA_NOP, 0}, /* 19 HTML_DT */ - {"dd", ALST_NOP, MAXA_NOP, 0}, /* 20 HTML_DD */ + {"dt", ALST_NOP, MAXA_NOP, 0}, /* 19 HTML_DT */ + {"dd", ALST_NOP, MAXA_NOP, 0}, /* 20 HTML_DD */ {"pre", ALST_PRE, MAXA_PRE, 0}, /* 21 HTML_PRE */ {"/pre", NULL, 0, TFLG_END}, /* 22 HTML_N_PRE */ {"blockquote", ALST_NOP, MAXA_NOP, 0}, /* 23 HTML_BLQ */ diff --git a/main.c b/main.c @@ -643,7 +643,9 @@ MAIN(int argc, char **argv, char **envp) else if (!strcmp("-pauth", argv[i])) { if (++i >= argc) usage(); - proxy_auth_cookie = encodeB(argv[i]); + proxy_auth_cookie = Strnew_m_charp("Basic ", + encodeB(argv[i])->ptr, + NULL); while (argv[i][0]) { argv[i][0] = '\0'; argv[i]++; diff --git a/url.c b/url.c @@ -1284,6 +1284,7 @@ HTTPrequest(ParsedURL *pu, ParsedURL *current, HRequest *hr, TextList *extra) { Str tmp; TextListItem *i; + int seen_proxy_auth = 0; #ifdef USE_COOKIE Str cookie; #endif /* USE_COOKIE */ @@ -1296,8 +1297,18 @@ HTTPrequest(ParsedURL *pu, ParsedURL *current, HRequest *hr, TextList *extra) else Strcat_charp(tmp, otherinfo(pu, current, hr->referer)); if (extra != NULL) - for (i = extra->first; i != NULL; i = i->next) + for (i = extra->first; i != NULL; i = i->next) { + if (strncasecmp(i->ptr, "Proxy-Authorization:", + sizeof("Proxy-Authorization:") - 1) == 0) + seen_proxy_auth = 1; Strcat_charp(tmp, i->ptr); + } + + if (!seen_proxy_auth && (hr->flag & HR_FLAG_PROXY) + && proxy_auth_cookie != NULL) + Strcat_m_charp(tmp, "Proxy-Authorization: ", proxy_auth_cookie->ptr, + "\r\n", NULL); + #ifdef USE_COOKIE if (hr->command != HR_COMMAND_CONNECT && use_cookie && (cookie = find_cookie(pu))) { @@ -1516,6 +1527,7 @@ openURL(char *url, ParsedURL *pu, ParsedURL *current, if (non_null(FTP_proxy) && !Do_not_use_proxy && pu->host != NULL && !check_no_proxy(pu->host)) { + hr->flag |= HR_FLAG_PROXY; sock = openSocket(FTP_proxy_parsed.host, schemetable[FTP_proxy_parsed.scheme].cmdname, FTP_proxy_parsed.port); @@ -1546,6 +1558,7 @@ openURL(char *url, ParsedURL *pu, ParsedURL *current, !Do_not_use_proxy && pu->host != NULL && !check_no_proxy(pu->host)) { char *save_label; + hr->flag |= HR_FLAG_PROXY; #ifdef USE_SSL if (pu->scheme == SCM_HTTPS && *status == HTST_CONNECT) { sock = ssl_socket_of(ouf->stream); @@ -1650,6 +1663,7 @@ openURL(char *url, ParsedURL *pu, ParsedURL *current, if (non_null(GOPHER_proxy) && !Do_not_use_proxy && pu->host != NULL && !check_no_proxy(pu->host)) { + hr->flag |= HR_FLAG_PROXY; sock = openSocket(GOPHER_proxy_parsed.host, schemetable[GOPHER_proxy_parsed.scheme].cmdname, GOPHER_proxy_parsed.port);