mirror of
https://github.com/mirror/wget.git
synced 2025-03-10 09:40:17 +08:00
[svn] Read the data in skip_short_body directly.
This commit is contained in:
parent
2f357b5eb8
commit
381457408a
@ -1,3 +1,8 @@
|
|||||||
|
2003-11-30 Hrvoje Niksic <hniksic@xemacs.org>
|
||||||
|
|
||||||
|
* http.c (skip_short_body): Renamed skip_body to skip_short_body;
|
||||||
|
don't bother calling fd_read_body.
|
||||||
|
|
||||||
2003-11-30 Hrvoje Niksic <hniksic@xemacs.org>
|
2003-11-30 Hrvoje Niksic <hniksic@xemacs.org>
|
||||||
|
|
||||||
* retr.c (fd_read_body): Sanitize arguments and document them
|
* retr.c (fd_read_body): Sanitize arguments and document them
|
||||||
|
30
src/http.c
30
src/http.c
@ -740,27 +740,31 @@ parse_content_range (const char *hdr, long *first_byte_ptr,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read the body of the request, but don't store it anywhere. This is
|
/* Read the body of the request, but don't store it anywhere and don't
|
||||||
useful when reading error responses that are not logged anywhere,
|
display a progress gauge. This is useful for reading the error
|
||||||
but which need to be read so the same connection can be reused. */
|
responses whose bodies don't need to be displayed or logged, but
|
||||||
|
which need to be read anyway. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
skip_body (int fd, long contlen)
|
skip_short_body (int fd, long contlen)
|
||||||
{
|
{
|
||||||
int oldverbose;
|
|
||||||
long dummy;
|
|
||||||
|
|
||||||
/* Skipping the body doesn't make sense if the content length is
|
/* Skipping the body doesn't make sense if the content length is
|
||||||
unknown because, in that case, persistent connections cannot be
|
unknown because, in that case, persistent connections cannot be
|
||||||
used. (#### This is not the case with HTTP/1.1 where they can
|
used. (#### This is not the case with HTTP/1.1 where they can
|
||||||
still be used with the magic of the "chunked" transfer!) */
|
still be used with the magic of the "chunked" transfer!) */
|
||||||
if (contlen == -1)
|
if (contlen == -1)
|
||||||
return;
|
return;
|
||||||
|
DEBUGP (("Skipping %ld bytes of body data... ", contlen));
|
||||||
|
|
||||||
oldverbose = opt.verbose;
|
while (contlen > 0)
|
||||||
opt.verbose = 0;
|
{
|
||||||
fd_read_body (fd, NULL, contlen, 1, 0, &dummy, NULL);
|
char dlbuf[512];
|
||||||
opt.verbose = oldverbose;
|
int ret = fd_read (fd, dlbuf, MIN (contlen, sizeof (dlbuf)), -1);
|
||||||
|
if (ret <= 0)
|
||||||
|
return;
|
||||||
|
contlen -= ret;
|
||||||
|
}
|
||||||
|
DEBUGP (("done.\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Persistent connections. Currently, we cache the most recently used
|
/* Persistent connections. Currently, we cache the most recently used
|
||||||
@ -1470,7 +1474,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. */
|
||||||
skip_body (sock, contlen);
|
skip_short_body (sock, contlen);
|
||||||
CLOSE_FINISH (sock);
|
CLOSE_FINISH (sock);
|
||||||
if (auth_tried_already || !(user && passwd))
|
if (auth_tried_already || !(user && passwd))
|
||||||
{
|
{
|
||||||
@ -1575,7 +1579,7 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy)
|
|||||||
hs->newloc ? hs->newloc : _("unspecified"),
|
hs->newloc ? hs->newloc : _("unspecified"),
|
||||||
hs->newloc ? _(" [following]") : "");
|
hs->newloc ? _(" [following]") : "");
|
||||||
if (keep_alive)
|
if (keep_alive)
|
||||||
skip_body (sock, contlen);
|
skip_short_body (sock, contlen);
|
||||||
CLOSE_FINISH (sock);
|
CLOSE_FINISH (sock);
|
||||||
xfree_null (type);
|
xfree_null (type);
|
||||||
return NEWLOCATION;
|
return NEWLOCATION;
|
||||||
|
@ -179,7 +179,7 @@ static struct {
|
|||||||
{ "passwd", &opt.ftp_pass, cmd_string },
|
{ "passwd", &opt.ftp_pass, cmd_string },
|
||||||
{ "postdata", &opt.post_data, cmd_string },
|
{ "postdata", &opt.post_data, cmd_string },
|
||||||
{ "postfile", &opt.post_file_name, cmd_file },
|
{ "postfile", &opt.post_file_name, cmd_file },
|
||||||
{ "preservepermissions", &opt.preserve_perm, cmd_boolean },
|
{ "preservepermissions", &opt.preserve_perm, cmd_boolean },
|
||||||
{ "progress", &opt.progress_type, cmd_spec_progress },
|
{ "progress", &opt.progress_type, cmd_spec_progress },
|
||||||
{ "proxypasswd", &opt.proxy_passwd, cmd_string },
|
{ "proxypasswd", &opt.proxy_passwd, cmd_string },
|
||||||
{ "proxyuser", &opt.proxy_user, cmd_string },
|
{ "proxyuser", &opt.proxy_user, cmd_string },
|
||||||
|
Loading…
Reference in New Issue
Block a user