cURL / Mailing Lists / curl-library / Single Mail


Re: [PATCH] tool_operate: set stdin to binary and fix telnet test 1326 on Windows

From: Marc Hoersken <>
Date: Sun, 20 Apr 2014 10:40:29 +0200

To elaborate a little bit on the actual issue on Windows:

If the input is read from stdin, the code in telnet_do (telnet.c)
requires that the remote socket is closed in order to terminate, because
there is no way for the read callback to gracefully signal that there
will be no more data to send. This means that telnet_do will loop
forever until the remote socket is closed if a read callback is used.
This is the case if the input is fed from stdin, using a pipe or redirect.

Since test 1326 uses telnet to simulate a HTTP request to the internal
test server, a HTTP request which uses CRLF line-endings is fed from an
input file to stdin. If binary mode is not enabled, those CRLF line
endings are screwed up and the internal HTTP test server never receives
a correctly formatted HTTP request. This results in the internal HTTP
test server never closing the connection and curl looping forever in

Some questions regarding this issue:
- should stdin always use binary mode to avoid such CRLF conversion issues?
- should the internal HTTP test server terminate the connection if it
receives "garbage"?
- should the read callback have a way to signal that there will be no
more data to process, e.g. a new return flag?

Best regards,

PS: On a slightly related note: I would really love to cleanup the
select-mess in Windows-specific curl code right now. Searching the
source code for "select(" returns various
"hacks"/workarounds/implementations to deal with select on Windows. I
would like to improve on the approach "select_ws" within sockfilt.c and
merge it into Curl_select / select.c or maybe curlx at some point in
order to streamline the various solutions. This approach requires
WinSock 2.0 and depends on a separate "waiting thread". What do you think?
List admin:
Received on 2014-04-20