Abdurrahman ÇARKACIOĞLU <[EMAIL PROTECTED]> writes:

> Now, it works. Thanks a lot.
>
> But I want to understand what is going on ? Was it a bug ?

It was a combination of two Wget bugs, one in actual code and other in
MinGW configuration.

Wget 1.9.1 and earlier used to close connections to the server after
an error response, as well as after HEAD requests.  Wget 1.10 was
modified to simply "skip" the error response and to trust that the
HEAD response will not be followed by message body (HTTP forbids it).
But there was a bug: I simply forgot one place where skip_short_body()
needs to be invoked in the non-HEAD error case, and this is what the
patch fixes.

"But why didn't the bug appear in Heiko's binaries or, for that
matter, on Unix?"  Because the bug was hidden by an unrelated feature,
the test_socket_open that Wget calls to verify that a socket is still
"open" before using it again.  The test waits for the socket to become
readable for no more than one microsecond.  The socket is supposed to
still be waiting for our input, so if it becomes readable, it means
it's about to return end-of-file and it is no longer open.  OTOH if
the call to select indicates that the microsecond has passed without
the socket becoming readable, it means that the socket is still open
and waiting for our input.

A useful side-effect of this check is that sockets with pending data
(possibly produced by broken server-side software that sends wrong
content-length) are considered closed and are not reused.  This is
what masked the bug in 1.10.  But, because of config.h.mingw didn't
define HAVE_SELECT, the select() check never got called, and
effectively exposed the bug.

> Will you consider the patch for future release of Wget.

It's already in the repository.

Reply via email to