return 1;
}
-/* Read the body of the request, but don't store it anywhere. This is
- useful when reading error responses that are not logged anywhere,
- but which need to be read so the same connection can be reused. */
+/* Read the body of the request, but don't store it anywhere and don't
+ display a progress gauge. This is useful for reading the error
+ responses whose bodies don't need to be displayed or logged, but
+ which need to be read anyway. */
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
unknown because, in that case, persistent connections cannot be
used. (#### This is not the case with HTTP/1.1 where they can
still be used with the magic of the "chunked" transfer!) */
if (contlen == -1)
return;
+ DEBUGP (("Skipping %ld bytes of body data... ", contlen));
- oldverbose = opt.verbose;
- opt.verbose = 0;
- fd_read_body (fd, NULL, contlen, 1, 0, &dummy, NULL);
- opt.verbose = oldverbose;
+ while (contlen > 0)
+ {
+ char dlbuf[512];
+ int ret = fd_read (fd, dlbuf, MIN (contlen, sizeof (dlbuf)), -1);
+ if (ret <= 0)
+ return;
+ contlen -= ret;
+ }
+ DEBUGP (("done.\n"));
}
\f
/* Persistent connections. Currently, we cache the most recently used
if (statcode == HTTP_STATUS_UNAUTHORIZED)
{
/* Authorization is required. */
- skip_body (sock, contlen);
+ skip_short_body (sock, contlen);
CLOSE_FINISH (sock);
if (auth_tried_already || !(user && passwd))
{
hs->newloc ? hs->newloc : _("unspecified"),
hs->newloc ? _(" [following]") : "");
if (keep_alive)
- skip_body (sock, contlen);
+ skip_short_body (sock, contlen);
CLOSE_FINISH (sock);
xfree_null (type);
return NEWLOCATION;
{ "passwd", &opt.ftp_pass, cmd_string },
{ "postdata", &opt.post_data, cmd_string },
{ "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 },
{ "proxypasswd", &opt.proxy_passwd, cmd_string },
{ "proxyuser", &opt.proxy_user, cmd_string },