Commit 80890b9a by Edward Thomson Committed by Patrick Steinhardt

winhttp: retry erroneously failing requests

Early Windows TLS 1.2 implementations have an issue during key exchange
with OpenSSL implementations that cause negotiation to fail with the
error "the buffer supplied to a function was too small."

This is a transient error on the connection, so when that error is
received, retry up to 5 times to create a connection to the remote
server before actually giving up.

(cherry picked from commit dc371e3c)
parent ebdca44a
......@@ -846,23 +846,27 @@ on_error:
static int do_send_request(winhttp_stream *s, size_t len, int ignore_length)
{
int attempts;
bool success;
for (attempts = 0; attempts < 5; attempts++) {
if (ignore_length) {
if (!WinHttpSendRequest(s->request,
success = WinHttpSendRequest(s->request,
WINHTTP_NO_ADDITIONAL_HEADERS, 0,
WINHTTP_NO_REQUEST_DATA, 0,
WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH, 0)) {
return -1;
}
WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH, 0);
} else {
if (!WinHttpSendRequest(s->request,
success = WinHttpSendRequest(s->request,
WINHTTP_NO_ADDITIONAL_HEADERS, 0,
WINHTTP_NO_REQUEST_DATA, 0,
len, 0)) {
return -1;
len, 0);
}
if (success || GetLastError() != SEC_E_BUFFER_TOO_SMALL)
break;
}
return 0;
return success ? 0 : -1;
}
static int send_request(winhttp_stream *s, size_t len, int ignore_length)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment