added two APIs: mg_set_non_blocking_mode(sock, on) and mg_shutdown(sock, how); the porting header file now also always provides all three mg_shutdown related defines: SHUT_RW, SHUT_RD and SHUT_RDWR.

The set-socket-non-blocking code has been made more portable (based on info from libxml code, among others).

mg_vprintf() has a peephole optimization: when the format string doesn't contain any %-argument, then we don't copy&allocate the string to print via mg_vasprintf() but print fmt directly for faster action and less thread collisions due to malloc/free.
testclient now provides all tests - still a compile time switch (testcase=nnn). Code has been tested and tweaked to maximize performance - while still using select() et al.

Note that the test code is essentially half-duplex (regular HTTP): what this means is that sending large amounts of data only works as long as the server isn't starting to send large chunks of response back at the same time: since we don't check the read-channel at that time, client and server code will deadlock for large enough sizes and main.c dataSize != bufferSize (switch that bit of #if 0'd code in there ~ line 356, run the testclient and note the lock-up once the message size is moderately large: switching on dataSize != bufferSize code at line 356 will also enable the code at line 436 (mg_send_data()) which is interleaved with fetching the data from the client, but since the client doesn't select() for read until all data has been sent to the server, and buffers are limited in size, you will find testclient and mongoose deadlock on write.)
augmented testclient to support full-duplex IP traffic, i.e. streaming responses. (And thus preventing deadlock in the IP stack due to both sides wanting to write but not fetching data from the full RX buffers at the same time.)
1) made sure that /_stat (almost) always produces the same number of bytes in the HTML output - this is done to help the testclient which expects a certain number of bytes when rerunning a request; the old /_stat code might increase the output by one byte as numbers got larger.

2) also set the proper response codes for improved mongoose access log file logging. (Cut down on the number of '-1' reponse codes logged in there...)
augmented testclient: command line args to pick rounds, testcase, client count; also augmented code to allow user to abort a test scenario by pressing a key; this is particularly handy when you're scanning for trouble by running all testcases all at once and want to stop the data increment for the current case, in order to continue with the next scenario - contrast this with hitting Ctrl+C/Break, which aborts the entire testclient run.
using the 'proper' 5xx response codes - internal ones for which we provide a description text as well
replaced the less than intuitive and incomplete solution mg_send_data() with the mg_mark_end_of_header_transmission(conn) API to signal the end of the transmission of header data (and consequently the beginning of transmission of content data); now mg_write(), mg_printf() et al track the number of content bytes written to the socket correctly (they track the number of header bytes written before that). This fix corrects the issues with the length data written to the access log file.

NOTE: when NO content data is written, the number of header bytes is logged instead, placed between braces, e.g. "(122)" instead of "0".
adjusted mongoose and testclient to both use graceful close plus half-close by shutdown(RW); corrections for Win32 based on these URLs/pages:
- http://blog.netherlabs.nl/articles/2009/01/18/the-ultimate-so_linger-page-or-why-is-my-tcp-not-reliable
- http://msdn.microsoft.com/en-us/library/ms737582(v=vs.85).aspx
- http://msdn.microsoft.com/en-us/library/ms739165(v=vs.85).aspx
- http://msdn.microsoft.com/en-us/library/ms738547(VS.85).aspx
observed data loss issues were gone; this edit is one after, so we need to revert a bit: mongoose code is clearly critical to the failure/success; current revision fails again. :-((
okay, this was the revision / code which PASSed the issues on POST tests for testclient (testcase 32: commandline args: '32 . 200'); note the graceful close code which doesn't yet shutdown(RW) before pulling all pending RX data. Further testing is required to see if _that_ is the difference between success and failure on Win32. Very odd indeed...
slowly working to a reduced version which still works (~ zero failures for a 'testclient 32 . 200' test run)
final mongoose revision which PASSES the testclient test '32 . 200' i.e. no trouble with lost data on POST. Third revision, which has been tested on Win7/64/Wonsock2. Not tested on Linux -- which should have an edge due to SIOCOUTQ
bugfix for testclient: prevent crash when no commandline args are given
bug fix: close connection when we encounter a malformed request (mongoose would 'forget' that malformedness and barge on when it is followed by \r\n\r\n)
testclient bug fix: strstr() would scan past the valid section of the buffer; now uses strnstr() instead.
introduce the mg_ioctlsocket() API
augmented echo output for the sake of testclient; debug printing while attempting to track down remaining odd behaviour ('testclient 35 1 .' can under the 'right' circumstances stop immediately due to 'no data received'. When you debug the code, this issue does not occur as clearly that alters the timing and hence the interchange. this problem is yet to be solved!)