Resend POST requests for Kerberos in WinHTTP

I'm trying to use LibGit2Sharp to connect to an Apache server that uses mod_auth_kerb for authentication, and I'm getting the error "Failed to receive response: The request must be resent".  It seems that the way WinHttp handles Kerberos authentication involves sending the request twice, which works fine for GET requests that have no body but fails for POST requests because it doesn’t store a copy of the request body to resend.  

The workaround I’m using here is to send an initial empty POST when using Negotiate, which should trigger the 401 early and allow the actual request to succeed without having to write the body twice.  I think this may be unnecessary in some cases, but I don’t see a way to tell whether it’s required and the extra empty POST appears to be harmless if it succeeds.  

I’m fairly new to both Kerberos and WinHttp, so I apologize in advance if I’ve done something completely crazy and I welcome suggestions for other solutions to my problem.  
Yes, that code is doing HTTP chunking by hand.  There is similar code already in `write_chunk` and `winhttp_stream_read`.  It seems that the way you do chunking in WinHTTP is by adding the header manually and then writing the chunk boundaries manually.  

The documentation for `WinHttpSendRequest` says that “dwTotalLength must not change between calls to WinHttpSendRequest for the same request”, and we need to use the same request handle in order to preserve the authentication information.  When using chunked encoding, `dwTotalLength` is set to `WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH` and so we’re able to send requests of different lengths, but I don’t see a way to use normal encoding if we’re trying to send an empty request followed by a real request on the same request handle.