diff options
author | Karlson2k <k2k@narod.ru> | 2016-02-19 22:38:20 +0300 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2016-04-20 09:22:48 +0200 |
commit | 72d5e144fbc6a9db264ae425bb788af218f25d9e (patch) | |
tree | fefce2fae7b555b33c32745bf2e83ed5e2823c3c /lib/urldata.h | |
parent | ad3d40d40707f1c5f37f878a61de4a8f0aeac2b8 (diff) |
sendf.c: added ability to call recv() before send() as workaround
WinSock destroys recv() buffer if send() is failed. As result - server
response may be lost if server sent it while curl is still sending
request. This behavior noticeable on HTTP server short replies if
libcurl use several send() for request (usually for POST request).
To workaround this problem, libcurl use recv() before every send() and
keeps received data in intermediate buffer for further processing.
Fixes: #657
Closes: #668
Diffstat (limited to 'lib/urldata.h')
-rw-r--r-- | lib/urldata.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/urldata.h b/lib/urldata.h index 016761929..f190fbdd6 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -833,6 +833,20 @@ typedef ssize_t (Curl_recv)(struct connectdata *conn, /* connection data */ size_t len, /* max amount to read */ CURLcode *err); /* error to return */ +#ifdef USE_RECV_BEFORE_SEND_WORKAROUND +struct postponed_data { + char *buffer; /* Temporal store for received data during + sending, must be freed */ + size_t allocated_size; /* Size of temporal store */ + size_t recv_size; /* Size of received data during sending */ + size_t recv_processed; /* Size of processed part of postponed data */ +#ifdef DEBUGBUILD + curl_socket_t bindsock;/* Structure must be bound to specific socket, + used only for DEBUGASSERT */ +#endif /* DEBUGBUILD */ +}; +#endif /* USE_RECV_BEFORE_SEND_WORKAROUND */ + /* * The connectdata struct contains all fields and variables that should be * unique for an entire connection. @@ -931,6 +945,9 @@ struct connectdata { Curl_recv *recv[2]; Curl_send *send[2]; +#ifdef USE_RECV_BEFORE_SEND_WORKAROUND + struct postponed_data postponed[2]; /* two buffers for two sockets */ +#endif /* USE_RECV_BEFORE_SEND_WORKAROUND */ struct ssl_connect_data ssl[2]; /* this is for ssl-stuff */ struct ssl_config_data ssl_config; bool tls_upgraded; |