1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

[svn] Don't attempt to "skip short body" if we're issuing a HEAD request (in which

case the response head is not followed by a body).
This commit is contained in:
hniksic 2005-05-30 07:29:01 -07:00
parent 0840de6605
commit eeacdb2ebc
2 changed files with 15 additions and 5 deletions

View File

@ -1,3 +1,9 @@
2005-05-30 Hrvoje Niksic <hniksic@xemacs.org>
* http.c (gethttp): Don't attempt to "skip short body" if we're
issuing a HEAD request (in which case the response head is not
followed by a body).
2005-05-30 Hrvoje Niksic <hniksic@xemacs.org> 2005-05-30 Hrvoje Niksic <hniksic@xemacs.org>
* init.c (cmd_spec_header): Don't split the string along the * init.c (cmd_spec_header): Don't split the string along the

View File

@ -1158,6 +1158,10 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy)
/* Whether our connection to the remote host is through SSL. */ /* Whether our connection to the remote host is through SSL. */
int using_ssl = 0; int using_ssl = 0;
/* Whether a HEAD request will be issued (as opposed to GET or
POST). */
int head_only = *dt & HEAD_ONLY;
char *head; char *head;
struct response *resp; struct response *resp;
char hdrval[256]; char hdrval[256];
@ -1197,7 +1201,7 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy)
} }
#endif /* HAVE_SSL */ #endif /* HAVE_SSL */
if (!(*dt & HEAD_ONLY)) if (!head_only)
/* If we're doing a GET on the URL, as opposed to just a HEAD, we need to /* If we're doing a GET on the URL, as opposed to just a HEAD, we need to
know the local filename so we can save to it. */ know the local filename so we can save to it. */
assert (*hs->local_file != NULL); assert (*hs->local_file != NULL);
@ -1218,7 +1222,7 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy)
{ {
char *meth_arg; char *meth_arg;
const char *meth = "GET"; const char *meth = "GET";
if (*dt & HEAD_ONLY) if (head_only)
meth = "HEAD"; meth = "HEAD";
else if (opt.post_file_name || opt.post_data) else if (opt.post_file_name || opt.post_data)
meth = "POST"; meth = "POST";
@ -1625,7 +1629,7 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy)
if (statcode == HTTP_STATUS_UNAUTHORIZED) if (statcode == HTTP_STATUS_UNAUTHORIZED)
{ {
/* Authorization is required. */ /* Authorization is required. */
if (keep_alive && skip_short_body (sock, contlen)) if (keep_alive && !head_only && skip_short_body (sock, contlen))
CLOSE_FINISH (sock); CLOSE_FINISH (sock);
else else
CLOSE_INVALIDATE (sock); CLOSE_INVALIDATE (sock);
@ -1765,7 +1769,7 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy)
_("Location: %s%s\n"), _("Location: %s%s\n"),
hs->newloc ? escnonprint_uri (hs->newloc) : _("unspecified"), hs->newloc ? escnonprint_uri (hs->newloc) : _("unspecified"),
hs->newloc ? _(" [following]") : ""); hs->newloc ? _(" [following]") : "");
if (keep_alive && skip_short_body (sock, contlen)) if (keep_alive && !head_only && skip_short_body (sock, contlen))
CLOSE_FINISH (sock); CLOSE_FINISH (sock);
else else
CLOSE_INVALIDATE (sock); CLOSE_INVALIDATE (sock);
@ -1871,7 +1875,7 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy)
type = NULL; /* We don't need it any more. */ type = NULL; /* We don't need it any more. */
/* Return if we have no intention of further downloading. */ /* Return if we have no intention of further downloading. */
if (!(*dt & RETROKF) || (*dt & HEAD_ONLY)) if (!(*dt & RETROKF) || head_only)
{ {
/* In case the caller cares to look... */ /* In case the caller cares to look... */
hs->len = 0; hs->len = 0;