v2: - added patch 2 ("winhttp: Don't refill buffer after receiving server response."); - keep header and redirect processing in receive_response(); - introduce a receive / response state instead of multiple flags and receive_response_queue_state; - added patch 7 ("winhttp: Wait for WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE in request_send()."). Waiting for WINHTTP_CALLBACK_STATUS_REQUEST_SENT is a bit racy with the next patch (it would be fine if WinHttpReceiveResponse was called right from callback but when it signals the event the state update in send_request() races with receive_request() (matter of atomic status update in receive_request / send_request but it is hopefully not needed). WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE looks like a correct callback and using it also avoids asynchronous queuing due to send_request() is not fully complete yet. - remove leftover break from test_recursion_callback() in the last patch.