Skip to content

Commit a194e17

Browse files
committed
winhttp: refactor request sending
Clarify what it means to not send a length; this allows us to refactor requests further.
1 parent da9bc8a commit a194e17

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/transports/winhttp.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ static int winhttp_connect(
830830
return error;
831831
}
832832

833-
static int do_send_request(winhttp_stream *s, size_t len, int ignore_length)
833+
static int do_send_request(winhttp_stream *s, size_t len, bool chunked)
834834
{
835835
int attempts;
836836
bool success;
@@ -841,7 +841,7 @@ static int do_send_request(winhttp_stream *s, size_t len, int ignore_length)
841841
}
842842

843843
for (attempts = 0; attempts < 5; attempts++) {
844-
if (ignore_length) {
844+
if (chunked) {
845845
success = WinHttpSendRequest(s->request,
846846
WINHTTP_NO_ADDITIONAL_HEADERS, 0,
847847
WINHTTP_NO_REQUEST_DATA, 0,
@@ -860,13 +860,13 @@ static int do_send_request(winhttp_stream *s, size_t len, int ignore_length)
860860
return success ? 0 : -1;
861861
}
862862

863-
static int send_request(winhttp_stream *s, size_t len, int ignore_length)
863+
static int send_request(winhttp_stream *s, size_t len, bool chunked)
864864
{
865865
int request_failed = 0, cert_valid = 1, error = 0;
866866
DWORD ignore_flags;
867867

868868
git_error_clear();
869-
if ((error = do_send_request(s, len, ignore_length)) < 0) {
869+
if ((error = do_send_request(s, len, chunked)) < 0) {
870870
if (GetLastError() != ERROR_WINHTTP_SECURE_FAILURE) {
871871
git_error_set(GIT_ERROR_OS, "failed to send request");
872872
return -1;
@@ -895,7 +895,7 @@ static int send_request(winhttp_stream *s, size_t len, int ignore_length)
895895
return -1;
896896
}
897897

898-
if ((error = do_send_request(s, len, ignore_length)) < 0)
898+
if ((error = do_send_request(s, len, chunked)) < 0)
899899
git_error_set(GIT_ERROR_OS, "failed to send request with unchecked certificate");
900900

901901
return error;
@@ -984,7 +984,7 @@ static int winhttp_stream_read(
984984

985985
if (!s->sent_request) {
986986

987-
if ((error = send_request(s, s->post_body_len, 0)) < 0)
987+
if ((error = send_request(s, s->post_body_len, false)) < 0)
988988
return error;
989989

990990
s->sent_request = 1;
@@ -1241,7 +1241,7 @@ static int winhttp_stream_write_single(
12411241
return -1;
12421242
}
12431243

1244-
if ((error = send_request(s, len, 0)) < 0)
1244+
if ((error = send_request(s, len, false)) < 0)
12451245
return error;
12461246

12471247
s->sent_request = 1;
@@ -1380,7 +1380,7 @@ static int winhttp_stream_write_chunked(
13801380
return -1;
13811381
}
13821382

1383-
if ((error = send_request(s, 0, 1)) < 0)
1383+
if ((error = send_request(s, 0, true)) < 0)
13841384
return error;
13851385

13861386
s->sent_request = 1;

0 commit comments

Comments
 (0)