From 0f08d9bbd9e48c62ab15652316948329317b3e01 Mon Sep 17 00:00:00 2001 From: Hubert Tarasiuk Date: Wed, 22 Apr 2015 19:04:22 +0200 Subject: [PATCH] Handle --content-on-error on http authorization. * src/http.c (gethttp): Save response body to file if authorization "error" is encountered. --- src/http.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/http.c b/src/http.c index f543957..09b1d2e 100644 --- a/src/http.c +++ b/src/http.c @@ -2766,15 +2766,32 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy, bool retry; /* Normally we are not interested in the response body. But if we are writing a WARC file we are: we like to keep everyting. */ - if (warc_enabled) + if (warc_enabled || opt.content_on_error) { int _err; type = resp_header_strdup (resp, "Content-Type"); - _err = read_response_body (hs, sock, NULL, contlen, 0, + + fp = NULL; + if (opt.content_on_error) + { + _err = open_output_stream (hs, count, &fp); + if (_err != RETROK) + { + CLOSE_INVALIDATE (sock); + retval = _err; + goto cleanup; + } + } + + _err = read_response_body (hs, sock, fp, contlen, 0, chunked_transfer_encoding, u->url, warc_timestamp_str, warc_request_uuid, warc_ip, type, statcode, head); + + if (fp) + fclose (fp); + xfree (type); if (_err != RETRFINISHED || hs->res < 0) -- 2.3.5