diff options
| author | Thomas E. Dickey <dickey@invisible-island.net> | 2018-03-11 21:51:34 +0000 |
|---|---|---|
| committer | Thomas E. Dickey <dickey@invisible-island.net> | 2018-03-11 21:51:34 +0000 |
| commit | 56022e66dd44884bad02e8577b9cdb455b04dceb (patch) | |
| tree | 2c611bd10b9a1bf34f195ba4b7ab0f71562c5f7a /WWW/Library | |
| parent | 8cffae83790c0c2537c7de1630712e87351dd582 (diff) | |
| download | lynx-snapshots-56022e66dd44884bad02e8577b9cdb455b04dceb.tar.gz | |
snapshot of project "lynx", label v2-8-9dev_16r
Diffstat (limited to 'WWW/Library')
| -rw-r--r-- | WWW/Library/Implementation/HTAnchor.c | 6 | ||||
| -rw-r--r-- | WWW/Library/Implementation/HTAnchor.h | 6 | ||||
| -rw-r--r-- | WWW/Library/Implementation/HTFormat.c | 39 | ||||
| -rw-r--r-- | WWW/Library/Implementation/HTMIME.c | 26 |
4 files changed, 55 insertions, 22 deletions
diff --git a/WWW/Library/Implementation/HTAnchor.c b/WWW/Library/Implementation/HTAnchor.c index d782020b..ee983a77 100644 --- a/WWW/Library/Implementation/HTAnchor.c +++ b/WWW/Library/Implementation/HTAnchor.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTAnchor.c,v 1.80 2018/03/06 09:34:12 tom Exp $ + * $LynxId: HTAnchor.c,v 1.81 2018/03/11 18:34:50 tom Exp $ * * Hypertext "Anchor" Object HTAnchor.c * ========================== @@ -762,9 +762,7 @@ static void HTParentAnchor_free(HTParentAnchor *me) } FREE(me->SugFname); FREE(me->cache_control); -#ifdef EXP_HTTP_HEADERS HTChunkClear(&(me->http_headers)); -#endif FREE(me->content_type_params); FREE(me->content_type); FREE(me->content_language); @@ -1067,14 +1065,12 @@ const char *HTAnchor_SugFname(HTParentAnchor *me) return (me ? me->SugFname : NULL); } -#ifdef EXP_HTTP_HEADERS /* HTTP Headers. */ const char *HTAnchor_http_headers(HTParentAnchor *me) { return (me ? me->http_headers.data : NULL); } -#endif /* Content-Type handling (parameter list). */ diff --git a/WWW/Library/Implementation/HTAnchor.h b/WWW/Library/Implementation/HTAnchor.h index e06ed017..3b1e6e68 100644 --- a/WWW/Library/Implementation/HTAnchor.h +++ b/WWW/Library/Implementation/HTAnchor.h @@ -1,5 +1,5 @@ /* - * $LynxId: HTAnchor.h,v 1.38 2017/02/10 22:26:48 tom Exp $ + * $LynxId: HTAnchor.h,v 1.40 2018/03/11 18:43:50 tom Exp $ * * Hypertext "Anchor" Object HTAnchor.h * ========================== @@ -100,10 +100,9 @@ extern "C" { char *SugFname; /* Suggested filename */ char *cache_control; /* Cache-Control */ BOOL no_cache; /* Cache-Control, Pragma or META "no-cache"? */ + BOOL inHEAD; /* HTMIMEConvert is decoding server-headers */ BOOL inBASE; /* duplicated from HTStructured (HTML.c/h) */ -#ifdef EXP_HTTP_HEADERS HTChunk http_headers; -#endif BOOL no_content_encoding; /* server did not use C-T? */ char *content_type_params; /* Content-Type (with parameters if any) */ char *content_type; /* Content-Type */ @@ -115,6 +114,7 @@ extern "C" { char *content_md5; /* Content-MD5 */ char *message_id; /* Message-ID */ char *subject; /* Subject */ + off_t header_length; /* length of headers */ off_t content_length; /* Content-Length */ off_t actual_length; /* actual length may differ */ char *date; /* Date */ diff --git a/WWW/Library/Implementation/HTFormat.c b/WWW/Library/Implementation/HTFormat.c index ccab7d89..e1a173d5 100644 --- a/WWW/Library/Implementation/HTFormat.c +++ b/WWW/Library/Implementation/HTFormat.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTFormat.c,v 1.86 2017/07/02 17:09:45 tom Exp $ + * $LynxId: HTFormat.c,v 1.89 2018/03/11 21:33:34 tom Exp $ * * Manage different file formats HTFormat.c * ============================= @@ -733,6 +733,7 @@ int HTCopy(HTParentAnchor *anchor, BOOL suppress_readprogress = NO; off_t limit = anchor ? anchor->content_length : 0; off_t bytes = 0; + off_t header_length = 0; int rv = 0; /* Push the data down the stream @@ -864,11 +865,39 @@ int HTCopy(HTParentAnchor *anchor, } #endif /* NOT_ASCII */ + header_length = anchor->header_length; + (*targetClass.put_block) (sink, input_buffer, status); - bytes += status; - if (!suppress_readprogress) - HTReadProgress(bytes, limit); - HTDisplayPartial(); + if (anchor->inHEAD) { + if (!suppress_readprogress) { + statusline(gettext("Reading headers...")); + } + CTRACE((tfp, "HTCopy read %" PRI_off_t " header bytes\n", + CAST_off_t (anchor->header_length))); + } else { + /* + * If header-length is increased at this point, that is due to + * HTMIME, which detects the end of the server headers. There + * may be additional (non-header) data in that block. + */ + if (anchor->header_length > header_length) { + int header = (int) (anchor->header_length - header_length); + + CTRACE((tfp, "HTCopy read %" PRI_off_t " header bytes " + "(%d extra vs %d total)\n", + CAST_off_t (anchor->header_length), + header, status)); + if (status > header) { + bytes += (status - header); + } + } else { + bytes += status; + } + if (!suppress_readprogress) { + HTReadProgress(bytes, limit); + } + HTDisplayPartial(); + } /* a few buggy implementations do not close the connection properly * and will hang if we try to read past the declared content-length. diff --git a/WWW/Library/Implementation/HTMIME.c b/WWW/Library/Implementation/HTMIME.c index bc2fd1ec..d8fe9978 100644 --- a/WWW/Library/Implementation/HTMIME.c +++ b/WWW/Library/Implementation/HTMIME.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTMIME.c,v 1.97 2018/03/05 10:21:10 tom Exp $ + * $LynxId: HTMIME.c,v 1.100 2018/03/11 21:32:38 tom Exp $ * * MIME Message Parse HTMIME.c * ================== @@ -1079,7 +1079,9 @@ static int dispatchField(HTStream *me) */ static void HTMIME_put_character(HTStream *me, int c) { - /* MUST BE FAST */ + if (me->anchor->inHEAD) { + me->anchor->header_length++; + } switch (me->state) { begin_transparent: case MIME_TRANSPARENT: @@ -1309,6 +1311,9 @@ static void HTMIME_put_character(HTStream *me, int c) case '\n': /* Blank line: End of Header! */ { + me->anchor->inHEAD = FALSE; + CTRACE((tfp, "HTMIME length %" PRI_off_t "\n", + CAST_off_t (me->anchor->header_length))); me->net_ascii = NO; pumpData(me); } @@ -2046,7 +2051,6 @@ static void HTMIME_put_character(HTStream *me, int c) } /* switch on state */ -#ifdef EXP_HTTP_HEADERS HTChunkPutc(&me->anchor->http_headers, UCH(c)); if (me->state == MIME_TRANSPARENT) { HTChunkTerminate(&me->anchor->http_headers); @@ -2057,7 +2061,6 @@ static void HTMIME_put_character(HTStream *me, int c) CTRACE((tfp, "Server Content-Type:%s\n", me->anchor->content_type_params)); } -#endif return; value_too_long: @@ -2066,12 +2069,9 @@ static void HTMIME_put_character(HTStream *me, int c) bad_field_name: /* Ignore it */ me->state = miJUNK_LINE; -#ifdef EXP_HTTP_HEADERS HTChunkPutc(&me->anchor->http_headers, UCH(c)); -#endif return; - } /* String handling @@ -2177,13 +2177,14 @@ HTStream *HTMIMEConvert(HTPresentation *pres, me->anchor = anchor; me->anchor->safe = FALSE; me->anchor->no_cache = FALSE; + FREE(me->anchor->cache_control); FREE(me->anchor->SugFname); FREE(me->anchor->charset); -#ifdef EXP_HTTP_HEADERS + HTChunkClear(&me->anchor->http_headers); HTChunkInit(&me->anchor->http_headers, 128); -#endif + FREE(me->anchor->content_type_params); FREE(me->anchor->content_language); FREE(me->anchor->content_encoding); @@ -2191,15 +2192,21 @@ HTStream *HTMIMEConvert(HTPresentation *pres, FREE(me->anchor->content_disposition); FREE(me->anchor->content_location); FREE(me->anchor->content_md5); + + me->anchor->inHEAD = TRUE; + me->anchor->header_length = 0; me->anchor->content_length = 0; + FREE(me->anchor->date); FREE(me->anchor->expires); FREE(me->anchor->last_modified); FREE(me->anchor->ETag); FREE(me->anchor->server); + me->target = NULL; me->state = miBEGINNING_OF_LINE; me->format = HTAtom_for(ContentTypes[LYContentType]); + CTRACE((tfp, "default Content-Type is %s\n", HTAtom_name(me->format))); me->targetRep = pres->rep_out; me->boundary = NULL; /* Not set yet */ @@ -2209,6 +2216,7 @@ HTStream *HTMIMEConvert(HTPresentation *pres, me->c_t_encoding = 0; /* Not set yet */ me->compression_encoding = NULL; /* Not set yet */ me->net_ascii = NO; /* Local character set */ + HTAnchor_setUCInfoStage(me->anchor, current_char_set, UCT_STAGE_STRUCTURED, UCT_SETBY_DEFAULT); |