#define FOPEN_APPENDTEXT "a"
#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.
+/* Windows workaround to recv before every send, because apparently Winsock
+ * destroys destroys recv() buffer when send() failed.
+ * This workaround is now disabled by default since it caused hard to fix bugs.
+ * Define USE_RECV_BEFORE_SEND_WORKAROUND to enable it.
+ * https://github.com/curl/curl/issues/657
+ * https://github.com/curl/curl/pull/10409
*/
#if !defined(DONT_USE_RECV_BEFORE_SEND_WORKAROUND)
# if defined(WIN32) || defined(__CYGWIN__)
-# define USE_RECV_BEFORE_SEND_WORKAROUND
+/* # define USE_RECV_BEFORE_SEND_WORKAROUND */
# endif
#else /* DONT_USE_RECV_BEFORE_SEND_WORKAROUND */
# ifdef USE_RECV_BEFORE_SEND_WORKAROUND
</keywords>
</info>
#
-# This reproduces issue #657, fixed with PR #668 - on Windows
+# This test checks to make sure curl can call recv() without failing after a
+# send() fails on the same socket (#657). Most OSes should support this
+# natively but on Windows curl must be built with a workaround (#668) for the
+# test to succeed. The precheck will skip this test on Windows if curl was
+# built without the workaround (USE_RECV_BEFORE_SEND_WORKAROUND isn't defined).
#
# Server-side
<reply>
<tool>
lib%TESTNUMBER
</tool>
+# precheck is a command line to run before the test, to see if we can execute
+# the test or not
+<precheck>
+./libtest/lib%TESTNUMBER check
+</precheck>
<name>
HTTP POST, server responds before completed send
struct WriteThis pooh;
+ if(!strcmp(URL, "check")) {
+#if (defined(WIN32) || defined(__CYGWIN__)) && \
+ !defined(USE_RECV_BEFORE_SEND_WORKAROUND)
+ printf("test requires recv-before-send workaround on Windows\n");
+ return 1; /* skip since test will fail on Windows without workaround */
+#else
+ return 0; /* sure, run this! */
+#endif
+ }
+
pooh.readptr = data;
pooh.sizeleft = strlen(data);