line |
true |
false |
branch |
139
|
0 |
0 |
return (response->status == GIT_HTTP_MOVED_PERMANENTLY || |
140
|
0 |
0 |
response->status == GIT_HTTP_FOUND || |
141
|
0 |
0 |
response->status == GIT_HTTP_SEE_OTHER || |
142
|
0 |
0 |
response->status == GIT_HTTP_TEMPORARY_REDIRECT || |
|
0 |
0 |
response->status == GIT_HTTP_TEMPORARY_REDIRECT || |
148
|
0 |
0 |
if (!response) |
166
|
0 |
0 |
if (!strcasecmp("Content-Type", name->ptr)) { |
167
|
0 |
0 |
if (response->content_type) { |
175
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(ctx->response->content_type); |
176
|
0 |
0 |
} else if (!strcasecmp("Content-Length", name->ptr)) { |
179
|
0 |
0 |
if (response->content_length) { |
185
|
0 |
0 |
if (git__strntol64(&len, value->ptr, value->size, |
186
|
0 |
0 |
NULL, 10) < 0 || len < 0) { |
193
|
0 |
0 |
} else if (!strcasecmp("Transfer-Encoding", name->ptr) && |
|
0 |
0 |
} else if (!strcasecmp("Transfer-Encoding", name->ptr) && |
196
|
0 |
0 |
} else if (!strcasecmp("Proxy-Authenticate", git_str_cstr(name))) { |
198
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(dup); |
200
|
0 |
0 |
if (git_vector_insert(&client->proxy.auth_challenges, dup) < 0) |
202
|
0 |
0 |
} else if (!strcasecmp("WWW-Authenticate", name->ptr)) { |
204
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(dup); |
206
|
0 |
0 |
if (git_vector_insert(&client->server.auth_challenges, dup) < 0) |
208
|
0 |
0 |
} else if (!strcasecmp("Location", name->ptr)) { |
209
|
0 |
0 |
if (response->location) { |
216
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(response->location); |
232
|
0 |
0 |
if (on_header_complete(parser) < 0) |
243
|
0 |
0 |
if (git_str_put(&ctx->parse_header_name, str, len) < 0) |
261
|
0 |
0 |
switch (ctx->parse_header_state) { |
266
|
0 |
0 |
if (git_str_put(&ctx->parse_header_value, str, len) < 0) |
287
|
0 |
0 |
if (!strncasecmp(challenge, scheme_name, scheme_len) && |
|
0 |
0 |
if (!strncasecmp(challenge, scheme_name, scheme_len) && |
288
|
0 |
0 |
(challenge[scheme_len] == '\0' || challenge[scheme_len] == ' ')) |
298
|
0 |
0 |
for (i = 0; i < ARRAY_SIZE(auth_schemes); i++) { |
299
|
0 |
0 |
if (challenge_matches_scheme(challenge, &auth_schemes[i])) |
318
|
0 |
0 |
git_vector_foreach(challenges, i, challenge) { |
319
|
0 |
0 |
if ((scheme = scheme_for_challenge(challenge)) != NULL) { |
330
|
0 |
0 |
if (response->status == GIT_HTTP_STATUS_UNAUTHORIZED && |
|
0 |
0 |
if (response->status == GIT_HTTP_STATUS_UNAUTHORIZED && |
331
|
0 |
0 |
(auth_context = client->server.auth_context) && |
332
|
0 |
0 |
auth_context->is_complete && |
336
|
0 |
0 |
if (response->status == GIT_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED && |
|
0 |
0 |
if (response->status == GIT_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED && |
337
|
0 |
0 |
(auth_context = client->proxy.auth_context) && |
338
|
0 |
0 |
auth_context->is_complete && |
352
|
0 |
0 |
if (on_header_complete(parser) < 0) |
384
|
0 |
0 |
if (ctx->response->content_type || ctx->response->chunked) |
|
0 |
0 |
if (ctx->response->content_type || ctx->response->chunked) |
398
|
0 |
0 |
if (ctx->output_buf == NULL || ctx->output_size == 0) { |
|
0 |
0 |
if (ctx->output_buf == NULL || ctx->output_size == 0) { |
403
|
0 |
0 |
GIT_ASSERT(ctx->output_size >= ctx->output_written); |
436
|
0 |
0 |
client->proxy.stream : client->server.stream; |
475
|
0 |
0 |
for (i = 0; i < ARRAY_SIZE(auth_schemes); i++) { |
476
|
0 |
0 |
git_vector_foreach(challenges, j, challenge) { |
479
|
0 |
0 |
if (challenge_matches_scheme(challenge, scheme) && |
|
0 |
0 |
if (challenge_matches_scheme(challenge, scheme) && |
501
|
0 |
0 |
for (i = 0; i < ARRAY_SIZE(auth_schemes); i++) { |
502
|
0 |
0 |
if (auth_schemes[i].type == auth_ctx->type) { |
505
|
0 |
0 |
git_vector_foreach(challenges, j, challenge) { |
506
|
0 |
0 |
if (challenge_matches_scheme(challenge, scheme)) |
524
|
0 |
0 |
if (!best_scheme_and_challenge(&scheme, &challenge, challenges, credentials)) { |
531
|
0 |
0 |
if (error == GIT_PASSTHROUGH) { |
541
|
0 |
0 |
if (!server->auth_context) |
544
|
0 |
0 |
if (server->auth_context->free) |
563
|
0 |
0 |
if (auth && !credentials) { |
|
0 |
0 |
if (auth && !credentials) { |
569
|
0 |
0 |
if (!auth && !git_vector_length(challenges)) |
|
0 |
0 |
if (!auth && !git_vector_length(challenges)) |
572
|
0 |
0 |
if (!auth) { |
576
|
0 |
0 |
if (!challenge || !auth) { |
|
0 |
0 |
if (!challenge || !auth) { |
580
|
0 |
0 |
} else if (auth->set_challenge) { |
584
|
0 |
0 |
if (auth->set_challenge && challenge && |
|
0 |
0 |
if (auth->set_challenge && challenge && |
|
0 |
0 |
if (auth->set_challenge && challenge && |
588
|
0 |
0 |
if ((error = auth->next_token(&token, auth, credentials)) < 0) |
591
|
0 |
0 |
if (auth->is_complete && auth->is_complete(auth)) { |
|
0 |
0 |
if (auth->is_complete && auth->is_complete(auth)) { |
596
|
0 |
0 |
if (auth->connection_affinity) |
598
|
0 |
0 |
} else if (!token.size) { |
604
|
0 |
0 |
if (token.size > 0) |
638
|
0 |
0 |
if (ipv6) |
643
|
0 |
0 |
if (ipv6) |
646
|
0 |
0 |
if (force_port || !git_net_url_is_default_port(url)) { |
|
0 |
0 |
if (force_port || !git_net_url_is_default_port(url)) { |
651
|
0 |
0 |
return git_str_oom(buf) ? -1 : 0; |
676
|
0 |
0 |
if ((error = apply_proxy_credentials(buf, client, request) < 0)) |
681
|
0 |
0 |
return git_str_oom(buf) ? -1 : 0; |
686
|
0 |
0 |
return client->proxy.url.host && !strcmp(client->server.url.scheme, "https"); |
|
0 |
0 |
return client->proxy.url.host && !strcmp(client->server.url.scheme, "https"); |
697
|
0 |
0 |
GIT_ASSERT_ARG(client); |
698
|
0 |
0 |
GIT_ASSERT_ARG(request); |
707
|
0 |
0 |
if (request->proxy && strcmp(request->url->scheme, "https")) |
|
0 |
0 |
if (request->proxy && strcmp(request->url->scheme, "https")) |
722
|
0 |
0 |
if (request->accept) |
727
|
0 |
0 |
if (request->content_type) |
731
|
0 |
0 |
if (request->chunked) |
734
|
0 |
0 |
if (request->content_length > 0) |
738
|
0 |
0 |
if (request->expect_continue) |
742
|
0 |
0 |
(!use_connect_proxy(client) && |
746
|
0 |
0 |
if (request->custom_headers) { |
747
|
0 |
0 |
for (i = 0; i < request->custom_headers->count; i++) { |
750
|
0 |
0 |
if (hdr) |
757
|
0 |
0 |
if (git_str_oom(buf)) |
774
|
0 |
0 |
if ((error = git_stream_certificate(&cert, stream)) < 0) |
781
|
0 |
0 |
if (error == GIT_PASSTHROUGH && !is_valid) |
|
0 |
0 |
if (error == GIT_PASSTHROUGH && !is_valid) |
783
|
0 |
0 |
else if (error == GIT_PASSTHROUGH) |
785
|
0 |
0 |
else if (error && !git_error_last()) |
|
0 |
0 |
else if (error && !git_error_last()) |
800
|
0 |
0 |
GIT_ERROR_CHECK_VERSION(server->stream, GIT_STREAM_VERSION, "git_stream"); |
804
|
0 |
0 |
if (error && error != GIT_ECERTIFICATE) |
|
0 |
0 |
if (error && error != GIT_ECERTIFICATE) |
807
|
0 |
0 |
if (git_stream_is_encrypted(server->stream) && cert_cb != NULL) |
|
0 |
0 |
if (git_stream_is_encrypted(server->stream) && cert_cb != NULL) |
827
|
0 |
0 |
if (server->auth_context && |
|
0 |
0 |
if (server->auth_context && |
840
|
0 |
0 |
if (!server->url.scheme || strcmp(server->url.scheme, url->scheme) || |
|
0 |
0 |
if (!server->url.scheme || strcmp(server->url.scheme, url->scheme) || |
|
0 |
0 |
if (!server->url.scheme || strcmp(server->url.scheme, url->scheme) || |
841
|
0 |
0 |
!server->url.host || strcmp(server->url.host, url->host) || |
|
0 |
0 |
!server->url.host || strcmp(server->url.host, url->host) || |
842
|
0 |
0 |
!server->url.port || strcmp(server->url.port, url->port)) { |
848
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(server->url.scheme); |
851
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(server->url.host); |
854
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(server->url.port); |
873
|
0 |
0 |
GIT_ASSERT_ARG(client); |
874
|
0 |
0 |
GIT_ASSERT_ARG(request); |
876
|
0 |
0 |
GIT_ASSERT(request->url); |
878
|
0 |
0 |
if ((ret = server_setup_from_url(&client->server, request->url)) < 0) |
883
|
0 |
0 |
if (request->proxy && |
|
0 |
0 |
if (request->proxy && |
889
|
0 |
0 |
if (diff) { |
903
|
0 |
0 |
if (strcasecmp(url->scheme, "https") == 0) |
905
|
0 |
0 |
else if (strcasecmp(url->scheme, "http") == 0) |
930
|
0 |
0 |
if (!client->proxy_connected || !client->keepalive) { |
|
0 |
0 |
if (!client->proxy_connected || !client->keepalive) { |
934
|
0 |
0 |
if ((error = server_create_stream(&client->proxy)) < 0 || |
|
0 |
0 |
if ((error = server_create_stream(&client->proxy)) < 0 || |
946
|
0 |
0 |
if ((error = generate_connect_request(client, request)) < 0 || |
|
0 |
0 |
if ((error = generate_connect_request(client, request)) < 0 || |
952
|
0 |
0 |
if ((error = git_http_client_read_response(&response, client)) < 0 || |
|
0 |
0 |
if ((error = git_http_client_read_response(&response, client)) < 0 || |
956
|
0 |
0 |
GIT_ASSERT(client->state == DONE); |
958
|
0 |
0 |
if (response.status == GIT_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED) { |
963
|
0 |
0 |
} else if (response.status != GIT_HTTP_STATUS_OK) { |
986
|
0 |
0 |
if (client->proxy.stream) |
991
|
0 |
0 |
if (error < 0) |
1005
|
0 |
0 |
if (server->stream) { |
1019
|
0 |
0 |
if ((error = setup_hosts(client, request)) < 0) |
1023
|
0 |
0 |
if (client->connected && client->keepalive && |
|
0 |
0 |
if (client->connected && client->keepalive && |
|
0 |
0 |
if (client->connected && client->keepalive && |
1024
|
0 |
0 |
(client->state == NONE || client->state == DONE)) |
1038
|
0 |
0 |
if (use_proxy) { |
1039
|
0 |
0 |
if (!client->proxy_connected || !client->keepalive || |
|
0 |
0 |
if (!client->proxy_connected || !client->keepalive || |
|
0 |
0 |
if (!client->proxy_connected || !client->keepalive || |
1040
|
0 |
0 |
(client->state != NONE && client->state != DONE)) { |
1047
|
0 |
0 |
if ((error = proxy_connect(client, request)) < 0) |
1054
|
0 |
0 |
if ((error = server_connect(client)) < 0) |
1061
|
0 |
0 |
if (error != GIT_RETRY) |
1077
|
0 |
0 |
client->proxy.stream : client->server.stream; |
1087
|
0 |
0 |
if (parser_context->output_size) |
1090
|
0 |
0 |
if (max_len == 0) { |
1097
|
0 |
0 |
if (read_len >= 0) { |
1112
|
0 |
0 |
if (!parser_settings_initialized) { |
1138
|
0 |
0 |
if (!client->read_buf.size && (read_len = client_read(client)) < 0) |
|
0 |
0 |
if (!client->read_buf.size && (read_len = client_read(client)) < 0) |
1147
|
0 |
0 |
if (parsed_len > INT_MAX) { |
1152
|
0 |
0 |
if (ctx->parse_status == PARSE_STATUS_ERROR) { |
1154
|
0 |
0 |
return ctx->error ? ctx->error : -1; |
1164
|
0 |
0 |
if (http_errno == HPE_PAUSED) { |
1170
|
0 |
0 |
GIT_ASSERT(client->read_buf.size > parsed_len); |
1181
|
0 |
0 |
else if (parser->http_errno != HPE_OK) { |
1188
|
0 |
0 |
else if (parsed_len != client->read_buf.size) { |
1196
|
0 |
0 |
else if (!parsed_len) { |
1220
|
0 |
0 |
if (!client->keepalive) { |
1229
|
0 |
0 |
if (client_read_and_parse(client) < 0 || |
|
0 |
0 |
if (client_read_and_parse(client) < 0 || |
1230
|
0 |
0 |
parser_context.error != HPE_OK || |
1231
|
0 |
0 |
(parser_context.parse_status != PARSE_STATUS_OK && |
1248
|
0 |
0 |
GIT_ASSERT_ARG(client); |
1249
|
0 |
0 |
GIT_ASSERT_ARG(request); |
1252
|
0 |
0 |
if (client->state == READING_BODY) |
1256
|
0 |
0 |
if (client->state == HAS_EARLY_RESPONSE) |
1259
|
0 |
0 |
if (git_trace_level() >= GIT_TRACE_DEBUG) { |
1262
|
0 |
0 |
git_trace(GIT_TRACE_DEBUG, "Sending %s request to %s", |
1268
|
0 |
0 |
if ((error = http_client_connect(client, request)) < 0 || |
|
0 |
0 |
if ((error = http_client_connect(client, request)) < 0 || |
1269
|
0 |
0 |
(error = generate_request(client, request)) < 0 || |
1275
|
0 |
0 |
if (request->expect_continue) { |
1276
|
0 |
0 |
if ((error = git_http_client_read_response(&response, client)) < 0 || |
|
0 |
0 |
if ((error = git_http_client_read_response(&response, client)) < 0 || |
1282
|
0 |
0 |
if (response.status != GIT_HTTP_STATUS_CONTINUE) { |
1288
|
0 |
0 |
if (request->content_length || request->chunked) { |
|
0 |
0 |
if (request->content_length || request->chunked) { |
1298
|
0 |
0 |
if (error == GIT_RETRY) |
1307
|
0 |
0 |
return (client->state == HAS_EARLY_RESPONSE || |
|
0 |
0 |
return (client->state == HAS_EARLY_RESPONSE || |
1320
|
0 |
0 |
GIT_ASSERT_ARG(client); |
1323
|
0 |
0 |
if (client->state == HAS_EARLY_RESPONSE) |
1326
|
0 |
0 |
if (client->state != SENDING_BODY) { |
1331
|
0 |
0 |
if (!buffer_len) |
1336
|
0 |
0 |
if (client->request_body_len) { |
1337
|
0 |
0 |
GIT_ASSERT(buffer_len <= client->request_body_remain); |
1339
|
0 |
0 |
if ((error = stream_write(server, buffer, buffer_len)) < 0) |
1344
|
0 |
0 |
if ((error = git_str_printf(&hdr, "%" PRIxZ "\r\n", buffer_len)) < 0 || |
|
0 |
0 |
if ((error = git_str_printf(&hdr, "%" PRIxZ "\r\n", buffer_len)) < 0 || |
1345
|
0 |
0 |
(error = stream_write(server, hdr.ptr, hdr.size)) < 0 || |
1360
|
0 |
0 |
GIT_ASSERT_ARG(client); |
1361
|
0 |
0 |
GIT_ASSERT(client->state == SENDING_BODY); |
1363
|
0 |
0 |
if (client->request_body_len && client->request_body_remain) { |
|
0 |
0 |
if (client->request_body_len && client->request_body_remain) { |
1366
|
0 |
0 |
} else if (client->request_chunked) { |
1381
|
0 |
0 |
GIT_ASSERT_ARG(response); |
1382
|
0 |
0 |
GIT_ASSERT_ARG(client); |
1384
|
0 |
0 |
if (client->state == SENDING_BODY) { |
1385
|
0 |
0 |
if ((error = complete_request(client)) < 0) |
1389
|
0 |
0 |
if (client->state == HAS_EARLY_RESPONSE) { |
1396
|
0 |
0 |
if (client->state != SENT_REQUEST) { |
1404
|
0 |
0 |
if (client->current_server == PROXY) { |
1406
|
0 |
0 |
} else if(client->current_server == SERVER) { |
1417
|
0 |
0 |
while (client->state == READING_RESPONSE) { |
1418
|
0 |
0 |
if ((error = client_read_and_parse(client)) < 0) |
1422
|
0 |
0 |
GIT_ASSERT(client->state == READING_BODY || client->state == DONE); |
|
0 |
0 |
GIT_ASSERT(client->state == READING_BODY || client->state == DONE); |
1439
|
0 |
0 |
if (client->state == DONE) |
1442
|
0 |
0 |
if (client->state != READING_BODY) { |
1465
|
0 |
0 |
while (!parser_context.output_written) { |
1468
|
0 |
0 |
if (error <= 0) |
1471
|
0 |
0 |
if (client->state == DONE) |
1475
|
0 |
0 |
GIT_ASSERT(parser_context.output_written <= INT_MAX); |
1479
|
0 |
0 |
if (error < 0) |
1490
|
0 |
0 |
if (client->state == DONE) |
1493
|
0 |
0 |
if (client->state != READING_BODY) { |
1504
|
0 |
0 |
if (parser_context.error != HPE_OK || |
|
0 |
0 |
if (parser_context.error != HPE_OK || |
1505
|
0 |
0 |
(parser_context.parse_status != PARSE_STATUS_OK && |
1511
|
0 |
0 |
} while (error >= 0 && client->state != DONE); |
|
0 |
0 |
} while (error >= 0 && client->state != DONE); |
1513
|
0 |
0 |
if (error < 0) |
1529
|
0 |
0 |
GIT_ASSERT_ARG(out); |
1532
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(client); |
1535
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(client->read_buf.ptr); |
1537
|
0 |
0 |
if (opts) |
1546
|
0 |
0 |
if (server->stream) { |
1573
|
0 |
0 |
if (!client) |