summaryrefslogtreecommitdiff
path: root/lib/curl_setup.h
diff options
context:
space:
mode:
authorKarlson2k <k2k@narod.ru>2016-02-19 22:38:20 +0300
committerDaniel Stenberg <daniel@haxx.se>2016-04-20 09:22:48 +0200
commit72d5e144fbc6a9db264ae425bb788af218f25d9e (patch)
treefefce2fae7b555b33c32745bf2e83ed5e2823c3c /lib/curl_setup.h
parentad3d40d40707f1c5f37f878a61de4a8f0aeac2b8 (diff)
downloadcurl-72d5e144fbc6a9db264ae425bb788af218f25d9e.tar.gz
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/curl_setup.h')
-rw-r--r--lib/curl_setup.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/curl_setup.h b/lib/curl_setup.h
index da26e48cb..d78873fe5 100644
--- a/lib/curl_setup.h
+++ b/lib/curl_setup.h
@@ -722,4 +722,19 @@ endings either CRLF or LF so 't' is appropriate.
#define FOPEN_WRITETEXT "w"
#endif
+/* WinSock destroys recv() buffer when send() failed.
+ * Enabled automatically for Windows and for Cygwin as Cygwin sockets are
+ * wrappers for WinSock sockets. https://github.com/curl/curl/issues/657
+ * Define DONT_USE_RECV_BEFORE_SEND_WORKAROUND to force disable workaround.
+ */
+#if !defined(DONT_USE_RECV_BEFORE_SEND_WORKAROUND)
+# if defined(WIN32) || defined(__CYGWIN__)
+# define USE_RECV_BEFORE_SEND_WORKAROUND
+# endif
+#else /* DONT_USE_RECV_BEFORE_SEND_WORKAROUNDS */
+# ifdef USE_RECV_BEFORE_SEND_WORKAROUND
+# undef USE_RECV_BEFORE_SEND_WORKAROUND
+# endif
+#endif /* DONT_USE_RECV_BEFORE_SEND_WORKAROUNDS */
+
#endif /* HEADER_CURL_SETUP_H */