Commit: 3ddf6b22fe840a312680b7617c8ec94e31ebcba7
Parent: 308518aff48d3176d4eb99b2b73617b668c81263
Author: opask
Date: Sat, 22 Sep 2018 21:53:43 -0600
remove http 302 redirect
patch taken from links-2.17
Diffstat:
7 files changed, 14 insertions(+), 44 deletions(-)
diff --git a/default.c b/default.c
@@ -1015,12 +1015,10 @@ struct proxies proxies = { "", "", "", "", "", 0 };
struct ssl_options ssl_options = { SSL_WARN_ON_INVALID_CERTIFICATE,
0,
"", "", "" };
-struct http_options http_options = { 0, 1, 1, 0, 0, 0, 0, { 0, "", "" } };
+struct http_options http_options = { 0, 1, 0, 0, 0, { 0, "", "" } };
unsigned char download_dir[MAX_STR_LEN] = "";
-static int sink;
-
double display_red_gamma=2.2; /* Red gamma exponent of the display */
double display_green_gamma=2.2; /* Green gamma exponent of the display */
double display_blue_gamma=2.2; /* Blue gamma exponent of the display */
@@ -1124,8 +1122,6 @@ static struct option links_options[] = {
{1, gen_cmd, str_rd, NULL, 0, MAX_STR_LEN, &ssl_options.client_cert_crt, "client_cert_crt", "http.client_cert_crt"}, /* backward compatibility with Debian patches */
{1, gen_cmd, num_rd, num_wr, 0, 1, &http_options.http10, "http_bugs.http10", "http-bugs.http10"},
{1, gen_cmd, num_rd, num_wr, 0, 1, &http_options.allow_blacklist, "http_bugs.allow_blacklist", "http-bugs.allow-blacklist"},
- {1, gen_cmd, num_rd, num_wr, 0, 1, &http_options.bug_302_redirect, "http_bugs.bug_302_redirect", "http-bugs.bug-302-redirect"},
- {1, gen_cmd, num_rd, num_wr, 0, 1, &http_options.bug_post_no_keepalive, "http_bugs.bug_post_no_keepalive", "http-bugs.bug-post-no-keepalive"},
{1, gen_cmd, num_rd, num_wr, 0, 1, &http_options.no_accept_charset, "http_bugs.no_accept_charset", "http-bugs.bug-no-accept-charset"},
{1, gen_cmd, num_rd, num_wr, 0, 1, &http_options.no_compression, "http_bugs.no_compression", "http-bugs.no-compression"},
{1, gen_cmd, num_rd, num_wr, 0, 1, &http_options.retry_internal_errors, "http_bugs.retry_internal_errors", "http-bugs.retry-internal-errors"},
@@ -1145,7 +1141,7 @@ static struct option links_options[] = {
{1, gen_cmd, dbl_rd, dbl_wr, 1, 10000, &display_blue_gamma, "display_blue_gamma", "display-blue-gamma"},
{1, gen_cmd, dbl_rd, dbl_wr, 1, 10000, &user_gamma, "user_gamma", "user-gamma"},
{1, gen_cmd, dbl_rd, dbl_wr, 25, 400, &bfu_aspect, "bfu_aspect", "bfu-aspect"},
- {1, gen_cmd, num_rd, NULL, 0, 1, &sink, "aspect_on", NULL},
+ {1, gen_cmd, num_rd, NULL, 0, 1, NULL, "aspect_on", NULL},
{1, gen_cmd, num_rd, num_wr, 0, 1, &dither_letters, "dither_letters", "dither-letters"},
{1, gen_cmd, num_rd, num_wr, 0, 1, &dither_images, "dither_images", "dither-images"},
{1, gen_cmd, num_rd, num_wr, 0, 2, &gamma_bits, "gamma_correction", "gamma-correction"},
diff --git a/http.c b/http.c
@@ -263,7 +263,7 @@ http_bad_url:
post = cast_uchar strchr((char *)host, POST_CHAR);
if (post) post++;
}
- info->send_close = info->https_forward || http10 || (post && http_options.bug_post_no_keepalive);
+ info->send_close = info->https_forward || http10;
if (info->https_forward) {
add_to_str(&hdr, &l, cast_uchar "CONNECT ");
h = get_host_name(host);
@@ -695,7 +695,7 @@ static void read_http_data(struct connection *c, struct read_buffer *rb)
info->length -= l;
c->from += l;
kill_buffer_data(rb, l);
- if (!info->length && !rb->close) {
+ if (!info->length) {
http_end_request(c, 0, 0, S__OK);
return;
}
@@ -1003,7 +1003,7 @@ again:
e->redirect = NULL;
if ((h == 302 || h == 303 || h == 307 || h == 511) && !e->expire_time)
e->expire_time = 1;
- if (h == 301 || h == 302 || h == 303 || h == 307) {
+ if (h == 301 || h == 302 || h == 303 || h == 307 || h == 308) {
if ((d = parse_http_header(e->head, cast_uchar "Location", NULL))) {
unsigned char *user, *ins;
unsigned char *newuser, *newpassword;
@@ -1028,7 +1028,11 @@ again:
}
free(e->redirect);
e->redirect = d;
- e->redirect_get = h == 303;
+ if (h == 307 || h == 308) {
+ unsigned char *p;
+ if ((p = cast_uchar strchr(cast_const_char host, POST_CHAR)))
+ add_to_strn(&e->redirect, p);
+ }
}
}
if (!e->expire_time && strchr((char *)c->url, POST_CHAR))
@@ -1070,7 +1074,7 @@ again:
char *ep;
long l = strtol((char *)d, &ep, 10);
if (!*ep && l >= 0 && (off_t)l >= 0 && (off_t)l == l) {
- if (!info->close || version >= 11)
+ if (!info->close || version >= 11 || h / 100 == 3)
info->length = l;
if (c->from + l >= 0)
c->est_length = c->from + l;
diff --git a/links.1 b/links.1
@@ -247,17 +247,6 @@ that claim to be HTTP/1.1 compliant but are not)
When links finds such server, it will retry the request with HTTP/1.0.
.TP
-\f3-http-bugs.bug-302-redirect \f2<0>/<1>\f1
-(default 1)
-Process 302 redirect in a way that is incompatible with RFC1945 and RFC2068,
-but the same as Netscape and MSIE. Many pages depend on it.
-
-.TP
-\f3-http-bugs.bug-post-no-keepalive \f2<0>/<1>\f1
-(default 0)
-No keepalive connection after post requests. For some buggy servers.
-
-.TP
\f3-http-bugs.bug-no-accept-charset \f2<0>/<1>\f1
(default 0)
Do not send Accept-Charset field of HTTP header. Because it is too long
diff --git a/links.h b/links.h
@@ -3503,8 +3503,6 @@ struct http_header_options {
struct http_options {
int http10;
int allow_blacklist;
- int bug_302_redirect;
- int bug_post_no_keepalive;
int no_accept_charset;
int no_compression;
int retry_internal_errors;
diff --git a/menu.c b/menu.c
@@ -1044,8 +1044,6 @@ void reset_settings_for_tor(void)
http_options.http10 = 0;
http_options.allow_blacklist = 1;
- http_options.bug_302_redirect = 1;
- http_options.bug_post_no_keepalive = 0;
http_options.no_accept_charset = 0;
http_options.no_compression = 0;
http_options.retry_internal_errors = 0;
@@ -1529,7 +1527,7 @@ static void dlg_http_options(struct terminal *term, void *xxx, void *yyy)
{
struct dialog *d;
int a = 0;
- d = mem_calloc(sizeof(struct dialog) + 10 * sizeof(struct dialog_item));
+ d = mem_calloc(sizeof(struct dialog) + 8 * sizeof(struct dialog_item));
d->title = TEXT_(T_HTTP_BUG_WORKAROUNDS);
d->fn = checkbox_list_fn;
d->udata = (void *)http_labels;
@@ -1547,16 +1545,6 @@ static void dlg_http_options(struct terminal *term, void *xxx, void *yyy)
d->items[a].type = D_CHECKBOX;
d->items[a].gid = 0;
d->items[a].dlen = sizeof(int);
- d->items[a].data = (void *)&http_options.bug_302_redirect;
- a++;
- d->items[a].type = D_CHECKBOX;
- d->items[a].gid = 0;
- d->items[a].dlen = sizeof(int);
- d->items[a].data = (void *)&http_options.bug_post_no_keepalive;
- a++;
- d->items[a].type = D_CHECKBOX;
- d->items[a].gid = 0;
- d->items[a].dlen = sizeof(int);
d->items[a].data = (void *)&http_options.no_accept_charset;
a++;
d->items[a].type = D_CHECKBOX;
diff --git a/objreq.c b/objreq.c
@@ -338,17 +338,13 @@ static void objreq_end(struct status *stat, void *data)
if (stat->ce && rq->state == O_WAITING && stat->ce->redirect) {
if (rq->redirect_cnt++ < MAX_REDIRECTS) {
int cache, allow_flags;
- unsigned char *u, *p, *pos;
+ unsigned char *u, *pos;
change_connection(stat, NULL, PRI_CANCEL);
u = join_urls(rq->url, stat->ce->redirect);
if ((pos = extract_position(u))) {
free(rq->goto_position);
rq->goto_position = pos;
}
- if (!http_options.bug_302_redirect
- && !stat->ce->redirect_get
- && (p = cast_uchar strchr(cast_const_char u, POST_CHAR)))
- add_to_strn(&u, p);
cache = rq->cache;
if (cache < NC_RELOAD
&& (!strcmp(cast_const_char u, cast_const_char rq->url)
diff --git a/session.c b/session.c
@@ -900,13 +900,12 @@ static void download_data(struct status *stat, void *down_)
unsigned char *enc;
if (ce->redirect) {
if (down->redirect_cnt++ < MAX_REDIRECTS) {
- unsigned char *u, *p;
+ unsigned char *u;
unsigned char *prev_down_url;
int cache, allow_flags;
if (stat->state >= 0) change_connection(&down->stat, NULL, PRI_CANCEL);
u = join_urls(down->url, ce->redirect);
extract_position(u);
- if (!http_options.bug_302_redirect) if (!ce->redirect_get && (p = cast_uchar strchr(cast_const_char down->url, POST_CHAR))) add_to_strn(&u, p);
prev_down_url = down->url;
down->url = u;
down->stat.state = S_WAIT_REDIR;