line |
true |
false |
branch |
140
|
0 |
0 |
return (response->status == GIT_HTTP_MOVED_PERMANENTLY || |
141
|
0 |
0 |
response->status == GIT_HTTP_FOUND || |
142
|
0 |
0 |
response->status == GIT_HTTP_SEE_OTHER || |
143
|
0 |
0 |
response->status == GIT_HTTP_TEMPORARY_REDIRECT || |
|
0 |
0 |
response->status == GIT_HTTP_TEMPORARY_REDIRECT || |
149
|
0 |
0 |
assert(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_buf_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_buf_put(&ctx->parse_header_name, str, len) < 0) |
261
|
0 |
0 |
switch (ctx->parse_header_state) { |
266
|
0 |
0 |
if (git_buf_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 |
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) |
653
|
0 |
0 |
if ((error = apply_proxy_credentials(buf, client, request) < 0)) |
658
|
0 |
0 |
return git_buf_oom(buf) ? -1 : 0; |
669
|
0 |
0 |
assert(client && request); |
|
0 |
0 |
assert(client && request); |
678
|
0 |
0 |
if (request->proxy && strcmp(request->url->scheme, "https")) |
|
0 |
0 |
if (request->proxy && strcmp(request->url->scheme, "https")) |
691
|
0 |
0 |
if (!git_net_url_is_default_port(request->url)) |
696
|
0 |
0 |
if (request->accept) |
701
|
0 |
0 |
if (request->content_type) |
705
|
0 |
0 |
if (request->chunked) |
708
|
0 |
0 |
if (request->content_length > 0) |
712
|
0 |
0 |
if (request->expect_continue) |
715
|
0 |
0 |
if ((error = apply_server_credentials(buf, client, request)) < 0 || |
|
0 |
0 |
if ((error = apply_server_credentials(buf, client, request)) < 0 || |
719
|
0 |
0 |
if (request->custom_headers) { |
720
|
0 |
0 |
for (i = 0; i < request->custom_headers->count; i++) { |
723
|
0 |
0 |
if (hdr) |
730
|
0 |
0 |
if (git_buf_oom(buf)) |
747
|
0 |
0 |
if ((error = git_stream_certificate(&cert, stream)) < 0) |
754
|
0 |
0 |
if (error == GIT_PASSTHROUGH && !is_valid) |
|
0 |
0 |
if (error == GIT_PASSTHROUGH && !is_valid) |
756
|
0 |
0 |
else if (error == GIT_PASSTHROUGH) |
758
|
0 |
0 |
else if (error && !git_error_last()) |
|
0 |
0 |
else if (error && !git_error_last()) |
773
|
0 |
0 |
GIT_ERROR_CHECK_VERSION(server->stream, GIT_STREAM_VERSION, "git_stream"); |
777
|
0 |
0 |
if (error && error != GIT_ECERTIFICATE) |
|
0 |
0 |
if (error && error != GIT_ECERTIFICATE) |
780
|
0 |
0 |
if (git_stream_is_encrypted(server->stream) && cert_cb != NULL) |
|
0 |
0 |
if (git_stream_is_encrypted(server->stream) && cert_cb != NULL) |
800
|
0 |
0 |
if (server->auth_context && |
|
0 |
0 |
if (server->auth_context && |
813
|
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) || |
814
|
0 |
0 |
!server->url.host || strcmp(server->url.host, url->host) || |
|
0 |
0 |
!server->url.host || strcmp(server->url.host, url->host) || |
815
|
0 |
0 |
!server->url.port || strcmp(server->url.port, url->port)) { |
821
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(server->url.scheme); |
824
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(server->url.host); |
827
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(server->url.port); |
846
|
0 |
0 |
assert(client && request && request->url); |
|
0 |
0 |
assert(client && request && request->url); |
|
0 |
0 |
assert(client && request && request->url); |
848
|
0 |
0 |
if ((ret = server_setup_from_url(&client->server, request->url)) < 0) |
853
|
0 |
0 |
if (request->proxy && |
|
0 |
0 |
if (request->proxy && |
859
|
0 |
0 |
if (diff) { |
873
|
0 |
0 |
if (strcasecmp(url->scheme, "https") == 0) |
875
|
0 |
0 |
else if (strcasecmp(url->scheme, "http") == 0) |
900
|
0 |
0 |
if (!client->proxy_connected || !client->keepalive) { |
|
0 |
0 |
if (!client->proxy_connected || !client->keepalive) { |
904
|
0 |
0 |
if ((error = server_create_stream(&client->proxy)) < 0 || |
|
0 |
0 |
if ((error = server_create_stream(&client->proxy)) < 0 || |
916
|
0 |
0 |
if ((error = generate_connect_request(client, request)) < 0 || |
|
0 |
0 |
if ((error = generate_connect_request(client, request)) < 0 || |
922
|
0 |
0 |
if ((error = git_http_client_read_response(&response, client)) < 0 || |
|
0 |
0 |
if ((error = git_http_client_read_response(&response, client)) < 0 || |
926
|
0 |
0 |
assert(client->state == DONE); |
928
|
0 |
0 |
if (response.status == GIT_HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED) { |
933
|
0 |
0 |
} else if (response.status != GIT_HTTP_STATUS_OK) { |
956
|
0 |
0 |
if (client->proxy.stream) |
961
|
0 |
0 |
if (error < 0) |
975
|
0 |
0 |
if (server->stream) { |
989
|
0 |
0 |
if ((error = setup_hosts(client, request)) < 0) |
993
|
0 |
0 |
if (client->connected && client->keepalive && |
|
0 |
0 |
if (client->connected && client->keepalive && |
|
0 |
0 |
if (client->connected && client->keepalive && |
994
|
0 |
0 |
(client->state == NONE || client->state == DONE)) |
1006
|
0 |
0 |
use_proxy = client->proxy.url.host && |
|
0 |
0 |
use_proxy = client->proxy.url.host && |
1009
|
0 |
0 |
if (use_proxy) { |
1010
|
0 |
0 |
if (!client->proxy_connected || !client->keepalive || |
|
0 |
0 |
if (!client->proxy_connected || !client->keepalive || |
|
0 |
0 |
if (!client->proxy_connected || !client->keepalive || |
1011
|
0 |
0 |
(client->state != NONE && client->state != DONE)) { |
1018
|
0 |
0 |
if ((error = proxy_connect(client, request)) < 0) |
1025
|
0 |
0 |
if ((error = server_connect(client)) < 0) |
1032
|
0 |
0 |
if (error != GIT_RETRY) |
1048
|
0 |
0 |
client->proxy.stream : client->server.stream; |
1058
|
0 |
0 |
if (parser_context->output_size) |
1061
|
0 |
0 |
if (max_len == 0) { |
1068
|
0 |
0 |
if (read_len >= 0) { |
1083
|
0 |
0 |
if (!parser_settings_initialized) { |
1109
|
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) |
1118
|
0 |
0 |
if (parsed_len > INT_MAX) { |
1123
|
0 |
0 |
if (parser->upgrade) { |
1128
|
0 |
0 |
if (ctx->parse_status == PARSE_STATUS_ERROR) { |
1130
|
0 |
0 |
return ctx->error ? ctx->error : -1; |
1140
|
0 |
0 |
if (http_errno == HPE_PAUSED) { |
1146
|
0 |
0 |
assert(client->read_buf.size > parsed_len); |
1157
|
0 |
0 |
else if (parser->http_errno != HPE_OK) { |
1164
|
0 |
0 |
else if (parsed_len != client->read_buf.size) { |
1172
|
0 |
0 |
else if (!parsed_len) { |
1196
|
0 |
0 |
if (!client->keepalive) { |
1205
|
0 |
0 |
if (client_read_and_parse(client) < 0 || |
|
0 |
0 |
if (client_read_and_parse(client) < 0 || |
1206
|
0 |
0 |
parser_context.error != HPE_OK || |
1207
|
0 |
0 |
(parser_context.parse_status != PARSE_STATUS_OK && |
1224
|
0 |
0 |
assert(client && request); |
|
0 |
0 |
assert(client && request); |
1227
|
0 |
0 |
if (client->state == READING_BODY) |
1231
|
0 |
0 |
if (client->state == HAS_EARLY_RESPONSE) |
1243
|
0 |
0 |
if ((error = http_client_connect(client, request)) < 0 || |
|
0 |
0 |
if ((error = http_client_connect(client, request)) < 0 || |
1244
|
0 |
0 |
(error = generate_request(client, request)) < 0 || |
1250
|
0 |
0 |
if (request->expect_continue) { |
1251
|
0 |
0 |
if ((error = git_http_client_read_response(&response, client)) < 0 || |
|
0 |
0 |
if ((error = git_http_client_read_response(&response, client)) < 0 || |
1257
|
0 |
0 |
if (response.status != GIT_HTTP_STATUS_CONTINUE) { |
1263
|
0 |
0 |
if (request->content_length || request->chunked) { |
|
0 |
0 |
if (request->content_length || request->chunked) { |
1273
|
0 |
0 |
if (error == GIT_RETRY) |
1282
|
0 |
0 |
return (client->state == HAS_EARLY_RESPONSE || |
|
0 |
0 |
return (client->state == HAS_EARLY_RESPONSE || |
1295
|
0 |
0 |
assert(client); |
1298
|
0 |
0 |
if (client->state == HAS_EARLY_RESPONSE) |
1301
|
0 |
0 |
if (client->state != SENDING_BODY) { |
1306
|
0 |
0 |
if (!buffer_len) |
1311
|
0 |
0 |
if (client->request_body_len) { |
1312
|
0 |
0 |
assert(buffer_len <= client->request_body_remain); |
1314
|
0 |
0 |
if ((error = stream_write(server, buffer, buffer_len)) < 0) |
1319
|
0 |
0 |
if ((error = git_buf_printf(&hdr, "%" PRIxZ "\r\n", buffer_len)) < 0 || |
|
0 |
0 |
if ((error = git_buf_printf(&hdr, "%" PRIxZ "\r\n", buffer_len)) < 0 || |
1320
|
0 |
0 |
(error = stream_write(server, hdr.ptr, hdr.size)) < 0 || |
1335
|
0 |
0 |
assert(client && client->state == SENDING_BODY); |
|
0 |
0 |
assert(client && client->state == SENDING_BODY); |
1337
|
0 |
0 |
if (client->request_body_len && client->request_body_remain) { |
|
0 |
0 |
if (client->request_body_len && client->request_body_remain) { |
1340
|
0 |
0 |
} else if (client->request_chunked) { |
1355
|
0 |
0 |
assert(response && client); |
|
0 |
0 |
assert(response && client); |
1357
|
0 |
0 |
if (client->state == SENDING_BODY) { |
1358
|
0 |
0 |
if ((error = complete_request(client)) < 0) |
1362
|
0 |
0 |
if (client->state == HAS_EARLY_RESPONSE) { |
1369
|
0 |
0 |
if (client->state != SENT_REQUEST) { |
1387
|
0 |
0 |
while (client->state == READING_RESPONSE) { |
1388
|
0 |
0 |
if ((error = client_read_and_parse(client)) < 0) |
1392
|
0 |
0 |
assert(client->state == READING_BODY || client->state == DONE); |
|
0 |
0 |
assert(client->state == READING_BODY || client->state == DONE); |
1409
|
0 |
0 |
if (client->state == DONE) |
1412
|
0 |
0 |
if (client->state != READING_BODY) { |
1435
|
0 |
0 |
while (!parser_context.output_written) { |
1438
|
0 |
0 |
if (error <= 0) |
1441
|
0 |
0 |
if (client->state == DONE) |
1445
|
0 |
0 |
assert(parser_context.output_written <= INT_MAX); |
1449
|
0 |
0 |
if (error < 0) |
1460
|
0 |
0 |
if (client->state == DONE) |
1463
|
0 |
0 |
if (client->state != READING_BODY) { |
1474
|
0 |
0 |
if (parser_context.error != HPE_OK || |
|
0 |
0 |
if (parser_context.error != HPE_OK || |
1475
|
0 |
0 |
(parser_context.parse_status != PARSE_STATUS_OK && |
1481
|
0 |
0 |
} while (!error); |
1483
|
0 |
0 |
if (error < 0) |
1499
|
0 |
0 |
assert(out); |
1502
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(client); |
1505
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(client->read_buf.ptr); |
1507
|
0 |
0 |
if (opts) |
1516
|
0 |
0 |
if (server->stream) { |
1543
|
0 |
0 |
if (!client) |