Unverified Commit b00a09b0 by Edward Thomson Committed by GitHub

Merge pull request #4731 from libgit2/ethomson/wintls_fix

winhttp: retry erroneously failing requests
parents 42f83840 dc371e3c
...@@ -845,23 +845,27 @@ on_error: ...@@ -845,23 +845,27 @@ on_error:
static int do_send_request(winhttp_stream *s, size_t len, int ignore_length) static int do_send_request(winhttp_stream *s, size_t len, int ignore_length)
{ {
if (ignore_length) { int attempts;
if (!WinHttpSendRequest(s->request, bool success;
WINHTTP_NO_ADDITIONAL_HEADERS, 0,
WINHTTP_NO_REQUEST_DATA, 0, for (attempts = 0; attempts < 5; attempts++) {
WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH, 0)) { if (ignore_length) {
return -1; success = WinHttpSendRequest(s->request,
} WINHTTP_NO_ADDITIONAL_HEADERS, 0,
} else { WINHTTP_NO_REQUEST_DATA, 0,
if (!WinHttpSendRequest(s->request, WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH, 0);
WINHTTP_NO_ADDITIONAL_HEADERS, 0, } else {
WINHTTP_NO_REQUEST_DATA, 0, success = WinHttpSendRequest(s->request,
len, 0)) { WINHTTP_NO_ADDITIONAL_HEADERS, 0,
return -1; WINHTTP_NO_REQUEST_DATA, 0,
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) 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