diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2019-11-27 18:43:36 +1100 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2020-01-24 09:54:29 -0600 |
commit | a194e17f9793eb960745243dde3eabfd60b65b56 (patch) | |
tree | 588543a7d508b88917b98d4163d00d296d7d039e | |
parent | da9bc8ac11d2ec2e5f013a91741fe1290cb338b5 (diff) | |
download | libgit2-a194e17f9793eb960745243dde3eabfd60b65b56.tar.gz |
winhttp: refactor request sending
Clarify what it means to not send a length; this allows us to refactor
requests further.
-rw-r--r-- | src/transports/winhttp.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/transports/winhttp.c b/src/transports/winhttp.c index 3a4497da5..57c6efcf6 100644 --- a/src/transports/winhttp.c +++ b/src/transports/winhttp.c @@ -830,7 +830,7 @@ on_error: return 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, bool chunked) { int attempts; bool success; @@ -841,7 +841,7 @@ static int do_send_request(winhttp_stream *s, size_t len, int ignore_length) } for (attempts = 0; attempts < 5; attempts++) { - if (ignore_length) { + if (chunked) { success = WinHttpSendRequest(s->request, WINHTTP_NO_ADDITIONAL_HEADERS, 0, WINHTTP_NO_REQUEST_DATA, 0, @@ -860,13 +860,13 @@ static int do_send_request(winhttp_stream *s, size_t len, int ignore_length) 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, bool chunked) { int request_failed = 0, cert_valid = 1, error = 0; DWORD ignore_flags; git_error_clear(); - if ((error = do_send_request(s, len, ignore_length)) < 0) { + if ((error = do_send_request(s, len, chunked)) < 0) { if (GetLastError() != ERROR_WINHTTP_SECURE_FAILURE) { git_error_set(GIT_ERROR_OS, "failed to send request"); return -1; @@ -895,7 +895,7 @@ static int send_request(winhttp_stream *s, size_t len, int ignore_length) return -1; } - if ((error = do_send_request(s, len, ignore_length)) < 0) + if ((error = do_send_request(s, len, chunked)) < 0) git_error_set(GIT_ERROR_OS, "failed to send request with unchecked certificate"); return error; @@ -984,7 +984,7 @@ replay: if (!s->sent_request) { - if ((error = send_request(s, s->post_body_len, 0)) < 0) + if ((error = send_request(s, s->post_body_len, false)) < 0) return error; s->sent_request = 1; @@ -1241,7 +1241,7 @@ static int winhttp_stream_write_single( return -1; } - if ((error = send_request(s, len, 0)) < 0) + if ((error = send_request(s, len, false)) < 0) return error; s->sent_request = 1; @@ -1380,7 +1380,7 @@ static int winhttp_stream_write_chunked( return -1; } - if ((error = send_request(s, 0, 1)) < 0) + if ((error = send_request(s, 0, true)) < 0) return error; s->sent_request = 1; |