Lines Matching refs:data
103 static bool http_should_fail(struct Curl_easy *data, int httpcode);
104 static bool http_exp100_is_waiting(struct Curl_easy *data);
105 static CURLcode http_exp100_add_reader(struct Curl_easy *data);
106 static void http_exp100_send_anyway(struct Curl_easy *data);
167 CURLcode Curl_http_setup_conn(struct Curl_easy *data, in Curl_http_setup_conn() argument
174 if(data->state.httpwant == CURL_HTTP_VERSION_3ONLY) { in Curl_http_setup_conn()
175 CURLcode result = Curl_conn_may_http3(data, conn); in Curl_http_setup_conn()
193 char *Curl_checkProxyheaders(struct Curl_easy *data, in Curl_checkProxyheaders() argument
200 for(head = (conn->bits.proxy && data->set.sep_headers) ? in Curl_checkProxyheaders()
201 data->set.proxyheaders : data->set.headers; in Curl_checkProxyheaders()
203 if(strncasecompare(head->data, thisheader, thislen) && in Curl_checkProxyheaders()
204 Curl_headersep(head->data[thislen])) in Curl_checkProxyheaders()
205 return head->data; in Curl_checkProxyheaders()
267 static CURLcode http_output_basic(struct Curl_easy *data, bool proxy) in http_output_basic() argument
281 userp = &data->state.aptr.proxyuserpwd; in http_output_basic()
282 user = data->state.aptr.proxyuser; in http_output_basic()
283 pwd = data->state.aptr.proxypasswd; in http_output_basic()
289 userp = &data->state.aptr.userpwd; in http_output_basic()
290 user = data->state.aptr.user; in http_output_basic()
291 pwd = data->state.aptr.passwd; in http_output_basic()
331 static CURLcode http_output_bearer(struct Curl_easy *data) in http_output_bearer() argument
336 userp = &data->state.aptr.userpwd; in http_output_bearer()
339 data->set.str[STRING_BEARER]); in http_output_bearer()
405 static CURLcode http_perhapsrewind(struct Curl_easy *data, in http_perhapsrewind() argument
408 curl_off_t bytessent = data->req.writebytecount; in http_perhapsrewind()
409 curl_off_t expectsend = Curl_creader_total_length(data); in http_perhapsrewind()
412 bool needs_rewind = Curl_creader_needs_rewind(data); in http_perhapsrewind()
416 bool abort_upload = (!data->req.upload_done && !little_upload_remains); in http_perhapsrewind()
426 infof(data, "Need to rewind upload for next request"); in http_perhapsrewind()
427 Curl_creader_set_rewind(data, TRUE); in http_perhapsrewind()
437 if((data->state.authproxy.picked == CURLAUTH_NTLM) || in http_perhapsrewind()
438 (data->state.authhost.picked == CURLAUTH_NTLM)) { in http_perhapsrewind()
450 if((data->state.authproxy.picked == CURLAUTH_NEGOTIATE) || in http_perhapsrewind()
451 (data->state.authhost.picked == CURLAUTH_NEGOTIATE)) { in http_perhapsrewind()
465 infof(data, "%s%sclose instead of sending %" FMT_OFF_T " more bytes", in http_perhapsrewind()
470 infof(data, "%s%sclose instead of sending unknown amount " in http_perhapsrewind()
477 data->req.size = 0; /* do not download any more than 0 bytes */ in http_perhapsrewind()
489 CURLcode Curl_http_auth_act(struct Curl_easy *data) in Curl_http_auth_act() argument
491 struct connectdata *conn = data->conn; in Curl_http_auth_act()
497 if(!data->set.str[STRING_BEARER]) in Curl_http_auth_act()
500 if(100 <= data->req.httpcode && data->req.httpcode <= 199) in Curl_http_auth_act()
504 if(data->state.authproblem) in Curl_http_auth_act()
505 return data->set.http_fail_on_error ? CURLE_HTTP_RETURNED_ERROR : CURLE_OK; in Curl_http_auth_act()
507 if((data->state.aptr.user || data->set.str[STRING_BEARER]) && in Curl_http_auth_act()
508 ((data->req.httpcode == 401) || in Curl_http_auth_act()
509 (data->req.authneg && data->req.httpcode < 300))) { in Curl_http_auth_act()
510 pickhost = pickoneauth(&data->state.authhost, authmask); in Curl_http_auth_act()
512 data->state.authproblem = TRUE; in Curl_http_auth_act()
513 if(data->state.authhost.picked == CURLAUTH_NTLM && in Curl_http_auth_act()
515 infof(data, "Forcing HTTP/1.1 for NTLM"); in Curl_http_auth_act()
517 data->state.httpwant = CURL_HTTP_VERSION_1_1; in Curl_http_auth_act()
522 ((data->req.httpcode == 407) || in Curl_http_auth_act()
523 (data->req.authneg && data->req.httpcode < 300))) { in Curl_http_auth_act()
524 pickproxy = pickoneauth(&data->state.authproxy, in Curl_http_auth_act()
527 data->state.authproblem = TRUE; in Curl_http_auth_act()
532 result = http_perhapsrewind(data, conn); in Curl_http_auth_act()
539 Curl_safefree(data->req.newurl); in Curl_http_auth_act()
540 data->req.newurl = strdup(data->state.url); /* clone URL */ in Curl_http_auth_act()
541 if(!data->req.newurl) in Curl_http_auth_act()
544 else if((data->req.httpcode < 300) && in Curl_http_auth_act()
545 (!data->state.authhost.done) && in Curl_http_auth_act()
546 data->req.authneg) { in Curl_http_auth_act()
551 if((data->state.httpreq != HTTPREQ_GET) && in Curl_http_auth_act()
552 (data->state.httpreq != HTTPREQ_HEAD)) { in Curl_http_auth_act()
553 data->req.newurl = strdup(data->state.url); /* clone URL */ in Curl_http_auth_act()
554 if(!data->req.newurl) in Curl_http_auth_act()
556 data->state.authhost.done = TRUE; in Curl_http_auth_act()
559 if(http_should_fail(data, data->req.httpcode)) { in Curl_http_auth_act()
560 failf(data, "The requested URL returned error: %d", in Curl_http_auth_act()
561 data->req.httpcode); in Curl_http_auth_act()
574 output_auth_headers(struct Curl_easy *data, in output_auth_headers() argument
592 result = Curl_output_aws_sigv4(data, proxy); in output_auth_headers()
601 result = Curl_output_negotiate(data, conn, proxy); in output_auth_headers()
610 result = Curl_output_ntlm(data, proxy); in output_auth_headers()
619 result = Curl_output_digest(data, in output_auth_headers()
634 !Curl_checkProxyheaders(data, conn, STRCONST("Proxy-authorization"))) || in output_auth_headers()
636 (!proxy && data->state.aptr.user && in output_auth_headers()
637 !Curl_checkheaders(data, STRCONST("Authorization")))) { in output_auth_headers()
639 result = http_output_basic(data, proxy); in output_auth_headers()
652 if((!proxy && data->set.str[STRING_BEARER] && in output_auth_headers()
653 !Curl_checkheaders(data, STRCONST("Authorization")))) { in output_auth_headers()
655 result = http_output_bearer(data); in output_auth_headers()
668 infof(data, "%s auth using %s with user '%s'", in output_auth_headers()
670 proxy ? (data->state.aptr.proxyuser ? in output_auth_headers()
671 data->state.aptr.proxyuser : "") : in output_auth_headers()
672 (data->state.aptr.user ? in output_auth_headers()
673 data->state.aptr.user : "")); in output_auth_headers()
676 infof(data, "Server auth using %s with user '%s'", in output_auth_headers()
677 auth, data->state.aptr.user ? in output_auth_headers()
678 data->state.aptr.user : ""); in output_auth_headers()
703 Curl_http_output_auth(struct Curl_easy *data, in Curl_http_output_auth() argument
715 DEBUGASSERT(data); in Curl_http_output_auth()
717 authhost = &data->state.authhost; in Curl_http_output_auth()
718 authproxy = &data->state.authproxy; in Curl_http_output_auth()
724 data->state.aptr.user || in Curl_http_output_auth()
729 data->set.str[STRING_BEARER]) in Curl_http_output_auth()
753 result = output_auth_headers(data, conn, authproxy, request, path, TRUE); in Curl_http_output_auth()
767 if(Curl_auth_allowed_to_host(data) in Curl_http_output_auth()
772 result = output_auth_headers(data, conn, authhost, request, path, FALSE); in Curl_http_output_auth()
782 data->req.authneg = TRUE; in Curl_http_output_auth()
785 data->req.authneg = FALSE; in Curl_http_output_auth()
793 Curl_http_output_auth(struct Curl_easy *data, in Curl_http_output_auth() argument
800 (void)data; in Curl_http_output_auth()
825 CURLcode Curl_http_input_auth(struct Curl_easy *data, bool proxy, in Curl_http_input_auth() argument
831 struct connectdata *conn = data->conn; in Curl_http_input_auth()
846 availp = &data->info.proxyauthavail; in Curl_http_input_auth()
847 authp = &data->state.authproxy; in Curl_http_input_auth()
850 availp = &data->info.httpauthavail; in Curl_http_input_auth()
851 authp = &data->state.authhost; in Curl_http_input_auth()
884 CURLcode result = Curl_input_negotiate(data, conn, proxy, auth); in Curl_http_input_auth()
886 free(data->req.newurl); in Curl_http_input_auth()
887 data->req.newurl = strdup(data->state.url); in Curl_http_input_auth()
888 if(!data->req.newurl) in Curl_http_input_auth()
890 data->state.authproblem = FALSE; in Curl_http_input_auth()
895 data->state.authproblem = TRUE; in Curl_http_input_auth()
911 CURLcode result = Curl_input_ntlm(data, proxy, auth); in Curl_http_input_auth()
913 data->state.authproblem = FALSE; in Curl_http_input_auth()
916 infof(data, "Authentication problem. Ignoring this."); in Curl_http_input_auth()
917 data->state.authproblem = TRUE; in Curl_http_input_auth()
927 infof(data, "Ignoring duplicate digest auth header."); in Curl_http_input_auth()
938 result = Curl_input_digest(data, proxy, auth); in Curl_http_input_auth()
940 infof(data, "Authentication problem. Ignoring this."); in Curl_http_input_auth()
941 data->state.authproblem = TRUE; in Curl_http_input_auth()
957 infof(data, "Authentication problem. Ignoring this."); in Curl_http_input_auth()
958 data->state.authproblem = TRUE; in Curl_http_input_auth()
972 infof(data, "Authentication problem. Ignoring this."); in Curl_http_input_auth()
973 data->state.authproblem = TRUE; in Curl_http_input_auth()
1007 static bool http_should_fail(struct Curl_easy *data, int httpcode) in http_should_fail() argument
1009 DEBUGASSERT(data); in http_should_fail()
1010 DEBUGASSERT(data->conn); in http_should_fail()
1016 if(!data->set.http_fail_on_error) in http_should_fail()
1029 if(data->state.resume_from && data->state.httpreq == HTTPREQ_GET && in http_should_fail()
1060 if((httpcode == 401) && !data->state.aptr.user) in http_should_fail()
1063 if((httpcode == 407) && !data->conn->bits.proxy_user_passwd) in http_should_fail()
1067 return data->state.authproblem; in http_should_fail()
1132 CURLcode Curl_http_connect(struct Curl_easy *data, bool *done) in Curl_http_connect() argument
1134 struct connectdata *conn = data->conn; in Curl_http_connect()
1140 return Curl_conn_connect(data, FIRSTSOCKET, FALSE, done); in Curl_http_connect()
1146 int Curl_http_getsock_do(struct Curl_easy *data, in Curl_http_getsock_do() argument
1152 socks[0] = Curl_conn_get_socket(data, FIRSTSOCKET); in Curl_http_getsock_do()
1161 CURLcode Curl_http_done(struct Curl_easy *data, in Curl_http_done() argument
1164 struct connectdata *conn = data->conn; in Curl_http_done()
1168 data->state.authhost.multipass = FALSE; in Curl_http_done()
1169 data->state.authproxy.multipass = FALSE; in Curl_http_done()
1171 Curl_dyn_reset(&data->state.headerb); in Curl_http_done()
1172 Curl_hyper_done(data); in Curl_http_done()
1180 !data->set.connect_only && in Curl_http_done()
1181 (data->req.bytecount + in Curl_http_done()
1182 data->req.headerbytecount - in Curl_http_done()
1183 data->req.deductheadercount) <= 0) { in Curl_http_done()
1187 failf(data, "Empty reply from server"); in Curl_http_done()
1205 bool Curl_use_http_1_1plus(const struct Curl_easy *data, in Curl_use_http_1_1plus() argument
1208 if((data->state.httpversion == 10) || (conn->httpversion == 10)) in Curl_use_http_1_1plus()
1210 if((data->state.httpwant == CURL_HTTP_VERSION_1_0) && in Curl_use_http_1_1plus()
1213 return ((data->state.httpwant == CURL_HTTP_VERSION_NONE) || in Curl_use_http_1_1plus()
1214 (data->state.httpwant >= CURL_HTTP_VERSION_1_1)); in Curl_use_http_1_1plus()
1218 static const char *get_http_string(const struct Curl_easy *data, in get_http_string() argument
1221 if(Curl_conn_is_http3(data, conn, FIRSTSOCKET)) in get_http_string()
1223 if(Curl_conn_is_http2(data, conn, FIRSTSOCKET)) in get_http_string()
1225 if(Curl_use_http_1_1plus(data, conn)) in get_http_string()
1247 CURLcode Curl_dynhds_add_custom(struct Curl_easy *data, in Curl_dynhds_add_custom() argument
1251 struct connectdata *conn = data->conn; in Curl_dynhds_add_custom()
1269 h[0] = data->set.headers; in Curl_dynhds_add_custom()
1272 h[0] = data->set.headers; in Curl_dynhds_add_custom()
1273 if(data->set.sep_headers) { in Curl_dynhds_add_custom()
1274 h[1] = data->set.proxyheaders; in Curl_dynhds_add_custom()
1279 if(data->set.sep_headers) in Curl_dynhds_add_custom()
1280 h[0] = data->set.proxyheaders; in Curl_dynhds_add_custom()
1282 h[0] = data->set.headers; in Curl_dynhds_add_custom()
1287 h[0] = data->set.headers; in Curl_dynhds_add_custom()
1300 ptr = strchr(headers->data, ':'); in Curl_dynhds_add_custom()
1302 name = headers->data; in Curl_dynhds_add_custom()
1303 namelen = ptr - headers->data; in Curl_dynhds_add_custom()
1317 ptr = strchr(headers->data, ';'); in Curl_dynhds_add_custom()
1325 name = headers->data; in Curl_dynhds_add_custom()
1326 namelen = ptr - headers->data; in Curl_dynhds_add_custom()
1343 if(data->state.aptr.host && in Curl_dynhds_add_custom()
1348 else if(data->state.httpreq == HTTPREQ_POST_FORM && in Curl_dynhds_add_custom()
1352 else if(data->state.httpreq == HTTPREQ_POST_MIME && in Curl_dynhds_add_custom()
1356 else if(data->req.authneg && in Curl_dynhds_add_custom()
1361 else if(data->state.aptr.te && in Curl_dynhds_add_custom()
1374 !Curl_auth_allowed_to_host(data)) in Curl_dynhds_add_custom()
1389 CURLcode Curl_add_custom_headers(struct Curl_easy *data, in Curl_add_custom_headers() argument
1398 struct connectdata *conn = data->conn; in Curl_add_custom_headers()
1416 h[0] = data->set.headers; in Curl_add_custom_headers()
1419 h[0] = data->set.headers; in Curl_add_custom_headers()
1420 if(data->set.sep_headers) { in Curl_add_custom_headers()
1421 h[1] = data->set.proxyheaders; in Curl_add_custom_headers()
1426 if(data->set.sep_headers) in Curl_add_custom_headers()
1427 h[0] = data->set.proxyheaders; in Curl_add_custom_headers()
1429 h[0] = data->set.headers; in Curl_add_custom_headers()
1434 h[0] = data->set.headers; in Curl_add_custom_headers()
1443 ptr = strchr(headers->data, ':'); in Curl_add_custom_headers()
1447 ptr = strchr(headers->data, ';'); in Curl_add_custom_headers()
1461 semicolonp = strdup(headers->data); in Curl_add_custom_headers()
1469 semicolonp[ptr - headers->data] = ':'; in Curl_add_custom_headers()
1471 optr = &semicolonp [ptr - headers->data]; in Curl_add_custom_headers()
1477 if(ptr && (ptr != headers->data)) { in Curl_add_custom_headers()
1487 char *compare = semicolonp ? semicolonp : headers->data; in Curl_add_custom_headers()
1489 if(data->state.aptr.host && in Curl_add_custom_headers()
1495 else if(data->state.httpreq == HTTPREQ_POST_FORM && in Curl_add_custom_headers()
1499 else if(data->state.httpreq == HTTPREQ_POST_MIME && in Curl_add_custom_headers()
1503 else if(data->req.authneg && in Curl_add_custom_headers()
1508 else if(data->state.aptr.te && in Curl_add_custom_headers()
1521 !Curl_auth_allowed_to_host(data)) in Curl_add_custom_headers()
1525 result = Curl_hyper_header(data, req, compare); in Curl_add_custom_headers()
1544 CURLcode Curl_add_timecondition(struct Curl_easy *data, in Curl_add_timecondition() argument
1559 if(data->set.timecondition == CURL_TIMECOND_NONE) in Curl_add_timecondition()
1563 result = Curl_gmtime(data->set.timevalue, &keeptime); in Curl_add_timecondition()
1565 failf(data, "Invalid TIMEVALUE"); in Curl_add_timecondition()
1570 switch(data->set.timecondition) { in Curl_add_timecondition()
1572 DEBUGF(infof(data, "invalid time condition")); in Curl_add_timecondition()
1589 if(Curl_checkheaders(data, condp, len)) { in Curl_add_timecondition()
1616 result = Curl_hyper_header(data, req, datestr); in Curl_add_timecondition()
1623 CURLcode Curl_add_timecondition(struct Curl_easy *data, in Curl_add_timecondition() argument
1626 (void)data; in Curl_add_timecondition()
1632 void Curl_http_method(struct Curl_easy *data, struct connectdata *conn, in Curl_http_method() argument
1635 Curl_HttpReq httpreq = (Curl_HttpReq)data->state.httpreq; in Curl_http_method()
1638 data->state.upload) in Curl_http_method()
1642 if(data->set.str[STRING_CUSTOMREQUEST]) in Curl_http_method()
1643 request = data->set.str[STRING_CUSTOMREQUEST]; in Curl_http_method()
1645 if(data->req.no_body) in Curl_http_method()
1672 CURLcode Curl_http_useragent(struct Curl_easy *data) in Curl_http_useragent() argument
1678 if(Curl_checkheaders(data, STRCONST("User-Agent"))) { in Curl_http_useragent()
1679 free(data->state.aptr.uagent); in Curl_http_useragent()
1680 data->state.aptr.uagent = NULL; in Curl_http_useragent()
1686 CURLcode Curl_http_host(struct Curl_easy *data, struct connectdata *conn) in Curl_http_host() argument
1689 struct dynamically_allocated_data *aptr = &data->state.aptr; in Curl_http_host()
1690 if(!data->state.this_is_a_follow) { in Curl_http_host()
1692 free(data->state.first_host); in Curl_http_host()
1694 data->state.first_host = strdup(conn->host.name); in Curl_http_host()
1695 if(!data->state.first_host) in Curl_http_host()
1698 data->state.first_remote_port = conn->remote_port; in Curl_http_host()
1699 data->state.first_remote_protocol = conn->handler->protocol; in Curl_http_host()
1703 ptr = Curl_checkheaders(data, STRCONST("Host")); in Curl_http_host()
1704 if(ptr && (!data->state.this_is_a_follow || in Curl_http_host()
1705 strcasecompare(data->state.first_host, conn->host.name))) { in Curl_http_host()
1776 CURLcode Curl_http_target(struct Curl_easy *data, in Curl_http_target() argument
1781 const char *path = data->state.up.path; in Curl_http_target()
1782 const char *query = data->state.up.query; in Curl_http_target()
1784 if(data->set.str[STRING_TARGET]) { in Curl_http_target()
1785 path = data->set.str[STRING_TARGET]; in Curl_http_target()
1800 CURLU *h = curl_url_dup(data->state.uh); in Curl_http_target()
1817 if(strcasecompare("http", data->state.up.scheme)) { in Curl_http_target()
1840 result = Curl_dyn_add(r, data->set.str[STRING_TARGET] ? in Curl_http_target()
1841 data->set.str[STRING_TARGET] : url); in Curl_http_target()
1846 if(strcasecompare("ftp", data->state.up.scheme)) { in Curl_http_target()
1847 if(data->set.proxy_transfer_mode) { in Curl_http_target()
1862 data->state.prefer_ascii ? 'a' : 'i'); in Curl_http_target()
1886 static CURLcode set_post_reader(struct Curl_easy *data, Curl_HttpReq httpreq) in set_post_reader() argument
1893 data->state.mimepost = &data->set.mimepost; in set_post_reader()
1900 if(!data->state.formp) { in set_post_reader()
1901 data->state.formp = calloc(1, sizeof(curl_mimepart)); in set_post_reader()
1902 if(!data->state.formp) in set_post_reader()
1904 Curl_mime_cleanpart(data->state.formp); in set_post_reader()
1905 result = Curl_getformdata(data, data->state.formp, data->set.httppost, in set_post_reader()
1906 data->state.fread_func); in set_post_reader()
1908 Curl_safefree(data->state.formp); in set_post_reader()
1911 data->state.mimepost = data->state.formp; in set_post_reader()
1916 data->state.mimepost = NULL; in set_post_reader()
1925 if(data->state.mimepost) { in set_post_reader()
1926 const char *cthdr = Curl_checkheaders(data, STRCONST("Content-Type")); in set_post_reader()
1929 data->state.mimepost->flags |= MIME_BODY_ONLY; in set_post_reader()
1936 else if(data->state.mimepost->kind == MIMEKIND_MULTIPART) in set_post_reader()
1939 curl_mime_headers(data->state.mimepost, data->set.headers, 0); in set_post_reader()
1940 result = Curl_mime_prepare_headers(data, data->state.mimepost, cthdr, in set_post_reader()
1944 curl_mime_headers(data->state.mimepost, NULL, 0); in set_post_reader()
1945 result = Curl_creader_set_mime(data, data->state.mimepost); in set_post_reader()
1952 result = Curl_creader_set_null(data); in set_post_reader()
1954 data->state.infilesize = Curl_creader_total_length(data); in set_post_reader()
1958 return Curl_creader_set_null(data); in set_post_reader()
1964 static CURLcode set_reader(struct Curl_easy *data, Curl_HttpReq httpreq) in set_reader() argument
1967 curl_off_t postsize = data->state.infilesize; in set_reader()
1969 DEBUGASSERT(data->conn); in set_reader()
1971 if(data->req.authneg) { in set_reader()
1972 return Curl_creader_set_null(data); in set_reader()
1977 return postsize ? Curl_creader_set_fread(data, postsize) : in set_reader()
1978 Curl_creader_set_null(data); in set_reader()
1983 return set_post_reader(data, httpreq); in set_reader()
1990 result = Curl_creader_set_null(data); in set_reader()
1992 else if(data->set.postfields) { in set_reader()
1994 result = Curl_creader_set_buf(data, data->set.postfields, in set_reader()
1997 result = Curl_creader_set_null(data); in set_reader()
2005 char *ptr = Curl_checkheaders(data, STRCONST("Transfer-Encoding")); in set_reader()
2011 result = Curl_creader_set_fread(data, chunked ? -1 : postsize); in set_reader()
2017 data->state.infilesize = 0; in set_reader()
2018 return Curl_creader_set_null(data); in set_reader()
2023 static CURLcode http_resume(struct Curl_easy *data, Curl_HttpReq httpreq) in http_resume() argument
2026 data->state.resume_from) { in http_resume()
2036 if(data->state.resume_from < 0) { in http_resume()
2041 data->state.resume_from = 0; in http_resume()
2044 if(data->state.resume_from && !data->req.authneg) { in http_resume()
2047 result = Curl_creader_resume_from(data, data->state.resume_from); in http_resume()
2049 failf(data, "Unable to resume from offset %" FMT_OFF_T, in http_resume()
2050 data->state.resume_from); in http_resume()
2058 CURLcode Curl_http_req_set_reader(struct Curl_easy *data, in Curl_http_req_set_reader() argument
2065 result = set_reader(data, httpreq); in Curl_http_req_set_reader()
2069 result = http_resume(data, httpreq); in Curl_http_req_set_reader()
2073 ptr = Curl_checkheaders(data, STRCONST("Transfer-Encoding")); in Curl_http_req_set_reader()
2076 data->req.upload_chunky = in Curl_http_req_set_reader()
2079 if(data->req.upload_chunky && in Curl_http_req_set_reader()
2080 Curl_use_http_1_1plus(data, data->conn) && in Curl_http_req_set_reader()
2081 (data->conn->httpversion >= 20)) { in Curl_http_req_set_reader()
2082 infof(data, "suppressing chunked transfer encoding on connection " in Curl_http_req_set_reader()
2084 data->req.upload_chunky = FALSE; in Curl_http_req_set_reader()
2088 curl_off_t req_clen = Curl_creader_total_length(data); in Curl_http_req_set_reader()
2092 if(Curl_use_http_1_1plus(data, data->conn)) { in Curl_http_req_set_reader()
2095 data->req.upload_chunky = (data->conn->httpversion < 20); in Curl_http_req_set_reader()
2098 failf(data, "Chunky upload is not supported by HTTP 1.0"); in Curl_http_req_set_reader()
2104 data->req.upload_chunky = FALSE; in Curl_http_req_set_reader()
2107 if(data->req.upload_chunky) in Curl_http_req_set_reader()
2113 static CURLcode addexpect(struct Curl_easy *data, struct dynbuf *r, in addexpect() argument
2121 if(data->req.upgr101 != UPGR101_INIT) in addexpect()
2128 ptr = Curl_checkheaders(data, STRCONST("Expect")); in addexpect()
2133 else if(!data->state.disableexpect && in addexpect()
2134 Curl_use_http_1_1plus(data, data->conn) && in addexpect()
2135 (data->conn->httpversion < 20)) { in addexpect()
2139 curl_off_t client_len = Curl_creader_client_length(data); in addexpect()
2150 CURLcode Curl_http_req_complete(struct Curl_easy *data, in Curl_http_req_complete() argument
2157 DEBUGASSERT(data->conn); in Curl_http_req_complete()
2159 if(data->req.upload_chunky) { in Curl_http_req_complete()
2160 result = Curl_httpchunk_add_reader(data); in Curl_http_req_complete()
2167 req_clen = Curl_creader_total_length(data); in Curl_http_req_complete()
2181 if(req_clen >= 0 && !data->req.upload_chunky && in Curl_http_req_complete()
2182 (data->req.authneg || in Curl_http_req_complete()
2183 !Curl_checkheaders(data, STRCONST("Content-Length")))) { in Curl_http_req_complete()
2194 if(data->state.mimepost && in Curl_http_req_complete()
2198 for(hdr = data->state.mimepost->curlheaders; hdr; hdr = hdr->next) { in Curl_http_req_complete()
2199 result = Curl_dyn_addf(r, "%s\r\n", hdr->data); in Curl_http_req_complete()
2206 if(!Curl_checkheaders(data, STRCONST("Content-Type"))) { in Curl_http_req_complete()
2213 result = addexpect(data, r, &announced_exp100); in Curl_http_req_complete()
2224 Curl_pgrsSetUploadSize(data, req_clen); in Curl_http_req_complete()
2226 result = http_exp100_add_reader(data); in Curl_http_req_complete()
2232 Curl_xfer_setup1(data, CURL_XFER_SENDRECV, -1, TRUE); in Curl_http_req_complete()
2239 CURLcode Curl_http_cookies(struct Curl_easy *data, in Curl_http_cookies() argument
2246 if(data->set.str[STRING_COOKIE] && in Curl_http_cookies()
2247 !Curl_checkheaders(data, STRCONST("Cookie"))) in Curl_http_cookies()
2248 addcookies = data->set.str[STRING_COOKIE]; in Curl_http_cookies()
2250 if(data->cookies || addcookies) { in Curl_http_cookies()
2255 if(data->cookies && data->state.cookie_engine) { in Curl_http_cookies()
2256 const char *host = data->state.aptr.cookiehost ? in Curl_http_cookies()
2257 data->state.aptr.cookiehost : conn->host.name; in Curl_http_cookies()
2263 Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE); in Curl_http_cookies()
2264 rc = Curl_cookie_getlist(data, data->cookies, host, data->state.up.path, in Curl_http_cookies()
2266 Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE); in Curl_http_cookies()
2284 infof(data, "Restricted outgoing cookies due to header size, " in Curl_http_cookies()
2317 CURLcode Curl_http_range(struct Curl_easy *data, in Curl_http_range() argument
2320 if(data->state.use_range) { in Curl_http_range()
2327 !Curl_checkheaders(data, STRCONST("Range"))) { in Curl_http_range()
2329 free(data->state.aptr.rangeline); in Curl_http_range()
2330 data->state.aptr.rangeline = aprintf("Range: bytes=%s\r\n", in Curl_http_range()
2331 data->state.range); in Curl_http_range()
2334 !Curl_checkheaders(data, STRCONST("Content-Range"))) { in Curl_http_range()
2335 curl_off_t req_clen = Curl_creader_total_length(data); in Curl_http_range()
2337 free(data->state.aptr.rangeline); in Curl_http_range()
2339 if(data->set.set_resume_from < 0) { in Curl_http_range()
2343 data->state.aptr.rangeline = in Curl_http_range()
2348 else if(data->state.resume_from) { in Curl_http_range()
2353 curl_off_t total_len = data->req.authneg ? in Curl_http_range()
2354 data->state.infilesize : in Curl_http_range()
2355 (data->state.resume_from + req_clen); in Curl_http_range()
2356 data->state.aptr.rangeline = in Curl_http_range()
2358 data->state.range, total_len-1, total_len); in Curl_http_range()
2363 data->state.aptr.rangeline = in Curl_http_range()
2365 data->state.range, req_clen); in Curl_http_range()
2367 if(!data->state.aptr.rangeline) in Curl_http_range()
2374 CURLcode Curl_http_firstwrite(struct Curl_easy *data) in Curl_http_firstwrite() argument
2376 struct connectdata *conn = data->conn; in Curl_http_firstwrite()
2377 struct SingleRequest *k = &data->req; in Curl_http_firstwrite()
2379 if(data->req.newurl) { in Curl_http_firstwrite()
2390 infof(data, "Ignoring the response-body"); in Curl_http_firstwrite()
2392 if(data->state.resume_from && !k->content_range && in Curl_http_firstwrite()
2393 (data->state.httpreq == HTTPREQ_GET) && in Curl_http_firstwrite()
2396 if(k->size == data->state.resume_from) { in Curl_http_firstwrite()
2399 infof(data, "The entire document is already downloaded"); in Curl_http_firstwrite()
2410 failf(data, "HTTP server does not seem to support " in Curl_http_firstwrite()
2415 if(data->set.timecondition && !data->state.range) { in Curl_http_firstwrite()
2420 if(!Curl_meets_timecondition(data, k->timeofdoc)) { in Curl_http_firstwrite()
2424 data->info.httpcode = 304; in Curl_http_firstwrite()
2425 infof(data, "Simulate an HTTP 304 response"); in Curl_http_firstwrite()
2437 CURLcode Curl_transferencode(struct Curl_easy *data) in Curl_transferencode() argument
2439 if(!Curl_checkheaders(data, STRCONST("TE")) && in Curl_transferencode()
2440 data->set.http_transfer_encoding) { in Curl_transferencode()
2446 char *cptr = Curl_checkheaders(data, STRCONST("Connection")); in Curl_transferencode()
2449 Curl_safefree(data->state.aptr.te); in Curl_transferencode()
2458 data->state.aptr.te = aprintf("Connection: %s%sTE\r\n" TE_HEADER, in Curl_transferencode()
2462 if(!data->state.aptr.te) in Curl_transferencode()
2475 CURLcode Curl_http(struct Curl_easy *data, bool *done) in Curl_http() argument
2477 struct connectdata *conn = data->conn; in Curl_http()
2494 DEBUGASSERT(Curl_conn_is_http3(data, conn, FIRSTSOCKET)); in Curl_http()
2498 if(!Curl_conn_is_http2(data, conn, FIRSTSOCKET) && in Curl_http()
2501 result = Curl_http2_switch(data, conn, FIRSTSOCKET); in Curl_http()
2507 DEBUGASSERT(Curl_conn_is_http2(data, conn, FIRSTSOCKET)); in Curl_http()
2514 if(Curl_http2_may_switch(data, conn, FIRSTSOCKET)) { in Curl_http()
2515 DEBUGF(infof(data, "HTTP/2 over clean TCP")); in Curl_http()
2516 result = Curl_http2_switch(data, conn, FIRSTSOCKET); in Curl_http()
2526 result = Curl_headers_init(data); in Curl_http()
2530 result = Curl_http_host(data, conn); in Curl_http()
2534 result = Curl_http_useragent(data); in Curl_http()
2538 Curl_http_method(data, conn, &request, &httpreq); in Curl_http()
2543 if(data->state.up.query) { in Curl_http()
2544 pq = aprintf("%s?%s", data->state.up.path, data->state.up.query); in Curl_http()
2548 result = Curl_http_output_auth(data, conn, request, httpreq, in Curl_http()
2549 (pq ? pq : data->state.up.path), FALSE); in Curl_http()
2555 Curl_safefree(data->state.aptr.ref); in Curl_http()
2556 if(data->state.referer && !Curl_checkheaders(data, STRCONST("Referer"))) { in Curl_http()
2557 data->state.aptr.ref = aprintf("Referer: %s\r\n", data->state.referer); in Curl_http()
2558 if(!data->state.aptr.ref) in Curl_http()
2562 if(!Curl_checkheaders(data, STRCONST("Accept-Encoding")) && in Curl_http()
2563 data->set.str[STRING_ENCODING]) { in Curl_http()
2564 Curl_safefree(data->state.aptr.accept_encoding); in Curl_http()
2565 data->state.aptr.accept_encoding = in Curl_http()
2566 aprintf("Accept-Encoding: %s\r\n", data->set.str[STRING_ENCODING]); in Curl_http()
2567 if(!data->state.aptr.accept_encoding) in Curl_http()
2571 Curl_safefree(data->state.aptr.accept_encoding); in Curl_http()
2575 result = Curl_transferencode(data); in Curl_http()
2580 result = Curl_http_req_set_reader(data, httpreq, &te); in Curl_http()
2584 p_accept = Curl_checkheaders(data, in Curl_http()
2587 result = Curl_http_range(data, httpreq); in Curl_http()
2591 httpstring = get_http_string(data, conn); in Curl_http()
2598 Curl_dyn_reset(&data->state.headerb); in Curl_http()
2604 result = Curl_http_target(data, conn, &req); in Curl_http()
2611 if(conn->bits.altused && !Curl_checkheaders(data, STRCONST("Alt-Used"))) { in Curl_http()
2637 (data->state.aptr.host ? data->state.aptr.host : ""), in Curl_http()
2639 data->state.aptr.proxyuserpwd ? in Curl_http()
2640 data->state.aptr.proxyuserpwd : "", in Curl_http()
2644 data->state.aptr.userpwd ? data->state.aptr.userpwd : "", in Curl_http()
2645 (data->state.use_range && data->state.aptr.rangeline) ? in Curl_http()
2646 data->state.aptr.rangeline : "", in Curl_http()
2647 (data->set.str[STRING_USERAGENT] && in Curl_http()
2648 *data->set.str[STRING_USERAGENT] && in Curl_http()
2649 data->state.aptr.uagent) ? in Curl_http()
2650 data->state.aptr.uagent : "", in Curl_http()
2652 data->state.aptr.te ? data->state.aptr.te : "", in Curl_http()
2653 (data->set.str[STRING_ENCODING] && in Curl_http()
2654 *data->set.str[STRING_ENCODING] && in Curl_http()
2655 data->state.aptr.accept_encoding) ? in Curl_http()
2656 data->state.aptr.accept_encoding : "", in Curl_http()
2657 (data->state.referer && data->state.aptr.ref) ? in Curl_http()
2658 data->state.aptr.ref : "" /* Referer: <data> */, in Curl_http()
2662 !Curl_checkheaders(data, STRCONST("Proxy-Connection")) && in Curl_http()
2663 !Curl_checkProxyheaders(data, conn, in Curl_http()
2675 Curl_safefree(data->state.aptr.userpwd); in Curl_http()
2677 Curl_safefree(data->state.aptr.proxyuserpwd); in Curl_http()
2688 (data->state.httpwant == CURL_HTTP_VERSION_2)) { in Curl_http()
2691 result = Curl_http2_request_upgrade(&req, data); in Curl_http()
2698 result = Curl_http_cookies(data, conn, &req); in Curl_http()
2701 result = Curl_ws_request(data, &req); in Curl_http()
2704 result = Curl_add_timecondition(data, &req); in Curl_http()
2706 result = Curl_add_custom_headers(data, FALSE, &req); in Curl_http()
2710 result = Curl_http_req_complete(data, &req, httpreq); in Curl_http()
2712 result = Curl_req_send(data, &req); in Curl_http()
2718 if((conn->httpversion >= 20) && data->req.upload_chunky) in Curl_http()
2722 data->req.upload_chunky = FALSE; in Curl_http()
2725 failf(data, "HTTP request too large"); in Curl_http()
2751 checkhttpprefix(struct Curl_easy *data, in checkhttpprefix() argument
2754 struct curl_slist *head = data->set.http200aliases; in checkhttpprefix()
2759 if(checkprefixmax(head->data, s, len)) { in checkhttpprefix()
2774 checkrtspprefix(struct Curl_easy *data, in checkrtspprefix() argument
2779 (void)data; /* unused */ in checkrtspprefix()
2788 checkprotoprefix(struct Curl_easy *data, struct connectdata *conn, in checkprotoprefix() argument
2793 return checkrtspprefix(data, s, len); in checkprotoprefix()
2798 return checkhttpprefix(data, s, len); in checkprotoprefix()
2819 CURLcode Curl_http_header(struct Curl_easy *data, in Curl_http_header() argument
2822 struct connectdata *conn = data->conn; in Curl_http_header()
2824 struct SingleRequest *k = &data->req; in Curl_http_header()
2831 v = (data->asi && in Curl_http_header()
2832 ((data->conn->handler->flags & PROTOPT_SSL) || in Curl_http_header()
2844 return Curl_altsvc_parse(data, data->asi, v, id, conn->host.name, in Curl_http_header()
2852 v = (!k->http_bodyless && !data->set.ignorecl) ? in Curl_http_header()
2864 if(data->set.max_filesize) { in Curl_http_header()
2865 failf(data, "Maximum file size exceeded"); in Curl_http_header()
2869 infof(data, "Overflow Content-Length: value"); in Curl_http_header()
2873 failf(data, "Invalid Content-Length: value"); in Curl_http_header()
2878 v = (!k->http_bodyless && data->set.str[STRING_ENCODING]) ? in Curl_http_header()
2888 return Curl_build_unencoding_stack(data, v, FALSE); in Curl_http_header()
2900 Curl_safefree(data->info.contenttype); in Curl_http_header()
2901 data->info.contenttype = contenttype; in Curl_http_header()
2924 infof(data, "HTTP/1.0 connection set to keep alive"); in Curl_http_header()
2949 if(data->state.resume_from == k->offset) in Curl_http_header()
2955 data->state.resume_from = 0; /* get everything */ in Curl_http_header()
2961 (data->set.timecondition || data->set.get_filetime)) ? in Curl_http_header()
2965 if(data->set.get_filetime) in Curl_http_header()
2966 data->info.filetime = k->timeofdoc; in Curl_http_header()
2971 !data->req.location) { in Curl_http_header()
2980 data->req.location = location; in Curl_http_header()
2982 if(data->set.http_follow_location) { in Curl_http_header()
2983 DEBUGASSERT(!data->req.newurl); in Curl_http_header()
2984 data->req.newurl = strdup(data->req.location); /* clone */ in Curl_http_header()
2985 if(!data->req.newurl) in Curl_http_header()
2990 result = http_perhapsrewind(data, conn); in Curl_http_header()
2995 data->state.this_is_a_follow = TRUE; in Curl_http_header()
3014 infof(data, "HTTP/1.0 proxy connection set to keep alive"); in Curl_http_header()
3023 infof(data, "HTTP/1.1 proxy connection set close"); in Curl_http_header()
3032 result = Curl_http_input_auth(data, TRUE, auth); in Curl_http_header()
3039 struct auth *authp = &data->state.authhost; in Curl_http_header()
3046 infof(data, "Negotiate: noauthpersist -> %d, header part: %s", in Curl_http_header()
3067 data->info.retry_after = retry_after; /* store it */ in Curl_http_header()
3074 v = (data->cookies && data->state.cookie_engine) ? in Curl_http_header()
3079 const char *host = data->state.aptr.cookiehost ? in Curl_http_header()
3080 data->state.aptr.cookiehost : conn->host.name; in Curl_http_header()
3087 Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, in Curl_http_header()
3089 Curl_cookie_add(data, data->cookies, TRUE, FALSE, v, host, in Curl_http_header()
3090 data->state.up.path, secure_context); in Curl_http_header()
3091 Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE); in Curl_http_header()
3097 v = (data->hsts && in Curl_http_header()
3109 Curl_hsts_parse(data->hsts, conn->host.name, v); in Curl_http_header()
3111 infof(data, "Illegal STS header skipped"); in Curl_http_header()
3114 infof(data, "Parsed STS header fine (%zu entries)", in Curl_http_header()
3115 Curl_llist_count(&data->hsts->list)); in Curl_http_header()
3133 (data->state.httpreq != HTTPREQ_HEAD) && in Curl_http_header()
3139 result = Curl_build_unencoding_stack(data, v, TRUE); in Curl_http_header()
3142 if(!k->chunk && data->set.http_transfer_encoding) { in Curl_http_header()
3153 data->req.resp_trailer = TRUE; in Curl_http_header()
3163 result = Curl_http_input_auth(data, FALSE, auth); in Curl_http_header()
3171 result = Curl_rtsp_parseheader(data, hd); in Curl_http_header()
3182 CURLcode Curl_http_statusline(struct Curl_easy *data, in Curl_http_statusline() argument
3185 struct SingleRequest *k = &data->req; in Curl_http_statusline()
3199 failf(data, "Version mismatch (from HTTP/%u to HTTP/%u)", in Curl_http_statusline()
3205 failf(data, "Unsupported HTTP version (%u.%d) in response", in Curl_http_statusline()
3210 data->info.httpcode = k->httpcode; in Curl_http_statusline()
3211 data->info.httpversion = k->httpversion; in Curl_http_statusline()
3214 if(!data->state.httpversion || data->state.httpversion > k->httpversion) in Curl_http_statusline()
3216 data->state.httpversion = (unsigned char)k->httpversion; in Curl_http_statusline()
3226 if(data->state.resume_from && data->state.httpreq == HTTPREQ_GET && in Curl_http_statusline()
3237 infof(data, "HTTP 1.0, assume close after body"); in Curl_http_statusline()
3242 DEBUGF(infof(data, "HTTP/2 found, allow multiplexing")); in Curl_http_statusline()
3252 if(data->set.timecondition) in Curl_http_statusline()
3253 data->info.timecond = TRUE; in Curl_http_statusline()
3276 CURLcode Curl_http_size(struct Curl_easy *data) in Curl_http_size() argument
3278 struct SingleRequest *k = &data->req; in Curl_http_size()
3279 if(data->req.ignore_cl || k->chunk) { in Curl_http_size()
3283 if(data->set.max_filesize && in Curl_http_size()
3285 (k->size > data->set.max_filesize)) { in Curl_http_size()
3286 failf(data, "Maximum file size exceeded"); in Curl_http_size()
3290 infof(data, "setting size while ignoring"); in Curl_http_size()
3291 Curl_pgrsSetDownloadSize(data, k->size); in Curl_http_size()
3297 static CURLcode verify_header(struct Curl_easy *data, in verify_header() argument
3300 struct SingleRequest *k = &data->req; in verify_header()
3304 failf(data, "Nul byte in header"); in verify_header()
3317 failf(data, "Header without colon"); in verify_header()
3324 CURLcode Curl_bump_headersize(struct Curl_easy *data, in Curl_bump_headersize() argument
3331 data->info.header_size += (unsigned int)delta; in Curl_bump_headersize()
3332 data->req.allheadercount += (unsigned int)delta; in Curl_bump_headersize()
3334 data->req.headerbytecount += (unsigned int)delta; in Curl_bump_headersize()
3335 if(data->req.allheadercount > max) in Curl_bump_headersize()
3336 bad = data->req.allheadercount; in Curl_bump_headersize()
3337 else if(data->info.header_size > (max * 20)) { in Curl_bump_headersize()
3338 bad = data->info.header_size; in Curl_bump_headersize()
3343 bad = data->req.allheadercount + delta; in Curl_bump_headersize()
3345 failf(data, "Too large response headers: %zu > %u", bad, max); in Curl_bump_headersize()
3351 static CURLcode http_write_header(struct Curl_easy *data, in http_write_header() argument
3359 Curl_debug(data, CURLINFO_HEADER_IN, (char *)hd, hdlen); in http_write_header()
3362 ((data->req.httpcode/100 == 1) ? CLIENTWRITE_1XX : 0); in http_write_header()
3364 result = Curl_client_write(data, writetype, hd, hdlen); in http_write_header()
3368 result = Curl_bump_headersize(data, hdlen, FALSE); in http_write_header()
3372 data->req.deductheadercount = (100 <= data->req.httpcode && in http_write_header()
3373 199 >= data->req.httpcode) ? in http_write_header()
3374 data->req.headerbytecount : 0; in http_write_header()
3378 static CURLcode http_on_response(struct Curl_easy *data, in http_on_response() argument
3383 struct connectdata *conn = data->conn; in http_on_response()
3385 struct SingleRequest *k = &data->req; in http_on_response()
3393 infof(data, "Lying server, not serving HTTP/2"); in http_on_response()
3400 result = http_write_header(data, last_hd, last_hd_len); in http_on_response()
3407 failf(data, "Unsupported response code in HTTP response"); in http_on_response()
3424 Curl_http_exp100_got100(data); in http_on_response()
3431 failf(data, "unexpected 101 response code"); in http_on_response()
3437 infof(data, "Received 101, Switching to HTTP/2"); in http_on_response()
3439 data->conn->bits.asks_multiplex = FALSE; in http_on_response()
3445 result = Curl_http2_upgrade(data, conn, FIRSTSOCKET, buf, blen); in http_on_response()
3454 result = Curl_ws_accept(data, buf, blen); in http_on_response()
3459 if(data->set.connect_only) in http_on_response()
3486 data->conn->bits.asks_multiplex = FALSE; in http_on_response()
3487 Curl_multi_connchanged(data->multi); in http_on_response()
3493 data->state.httpreq != HTTPREQ_HEAD) { in http_on_response()
3499 infof(data, "no chunk, no close, no size. Assume close to " in http_on_response()
3508 (((data->req.httpcode == 401) && in http_on_response()
3510 ((data->req.httpcode == 407) && in http_on_response()
3512 infof(data, "Connection closure while negotiating auth (HTTP 1.0?)"); in http_on_response()
3513 data->state.authproblem = TRUE; in http_on_response()
3518 (((data->req.httpcode == 401) && in http_on_response()
3520 ((data->req.httpcode == 407) && in http_on_response()
3522 infof(data, "Connection closure while negotiating auth (HTTP 1.0?)"); in http_on_response()
3523 data->state.authproblem = TRUE; in http_on_response()
3526 (data->req.httpcode != 401)) { in http_on_response()
3530 (data->req.httpcode != 407)) { in http_on_response()
3537 if(data->req.upgr101 == UPGR101_WS) { in http_on_response()
3538 failf(data, "Refused WebSockets upgrade: %d", k->httpcode); in http_on_response()
3545 if(http_should_fail(data, data->req.httpcode)) { in http_on_response()
3546 failf(data, "The requested URL returned error: %d", in http_on_response()
3555 result = Curl_http_auth_act(data); in http_on_response()
3560 if((!data->req.authneg) && !conn->bits.close && in http_on_response()
3561 !Curl_creader_will_rewind(data)) { in http_on_response()
3573 switch(data->state.httpreq) { in http_on_response()
3582 if(!Curl_req_done_sending(data)) { in http_on_response()
3583 if((k->httpcode == 417) && Curl_http_exp100_is_selected(data)) { in http_on_response()
3586 if(!k->writebytecount && http_exp100_is_waiting(data)) { in http_on_response()
3587 infof(data, "Got HTTP failure 417 while waiting for a 100"); in http_on_response()
3590 infof(data, "Got HTTP failure 417 while sending data"); in http_on_response()
3593 result = http_perhapsrewind(data, conn); in http_on_response()
3597 data->state.disableexpect = TRUE; in http_on_response()
3598 DEBUGASSERT(!data->req.newurl); in http_on_response()
3599 data->req.newurl = strdup(data->state.url); in http_on_response()
3600 Curl_req_abort_sending(data); in http_on_response()
3602 else if(data->set.http_keep_sending_on_error) { in http_on_response()
3603 infof(data, "HTTP error before end of send, keep sending"); in http_on_response()
3604 http_exp100_send_anyway(data); in http_on_response()
3607 infof(data, "HTTP error before end of send, stop sending"); in http_on_response()
3609 result = Curl_req_abort_sending(data); in http_on_response()
3621 if(Curl_creader_will_rewind(data) && !Curl_req_done_sending(data)) { in http_on_response()
3623 infof(data, "Keep sending data to get tossed away"); in http_on_response()
3632 if(data->req.no_body) in http_on_response()
3641 && !Curl_conn_is_http2(data, conn, FIRSTSOCKET) in http_on_response()
3642 && !Curl_conn_is_http3(data, conn, FIRSTSOCKET)) in http_on_response()
3646 result = Curl_http_firstwrite(data); in http_on_response()
3652 result = Curl_http_size(data); in http_on_response()
3657 CURLcode r2 = http_write_header(data, last_hd, last_hd_len); in http_on_response()
3664 static CURLcode http_rw_hd(struct Curl_easy *data, in http_rw_hd() argument
3670 struct SingleRequest *k = &data->req; in http_rw_hd()
3688 Curl_dyn_reset(&data->state.headerb); in http_rw_hd()
3689 result = http_on_response(data, Curl_dyn_ptr(&last_header), in http_rw_hd()
3708 if(data->conn->handler->protocol & PROTO_FAMILY_HTTP) { in http_rw_hd()
3739 failf(data, "Unsupported HTTP/1 subversion in response"); in http_rw_hd()
3759 failf(data, "Unsupported HTTP version in response"); in http_rw_hd()
3768 statusline check = checkhttpprefix(data, hd, hdlen); in http_rw_hd()
3776 else if(data->conn->handler->protocol & CURLPROTO_RTSP) { in http_rw_hd()
3805 result = Curl_http_statusline(data, data->conn); in http_rw_hd()
3816 result = verify_header(data, hd, hdlen); in http_rw_hd()
3820 result = Curl_http_header(data, hd, hdlen); in http_rw_hd()
3827 Curl_debug(data, CURLINFO_HEADER_IN, (char *)hd, hdlen); in http_rw_hd()
3831 result = Curl_client_write(data, writetype, hd, hdlen); in http_rw_hd()
3835 result = Curl_bump_headersize(data, hdlen, FALSE); in http_rw_hd()
3845 static CURLcode http_parse_headers(struct Curl_easy *data, in http_parse_headers() argument
3849 struct connectdata *conn = data->conn; in http_parse_headers()
3851 struct SingleRequest *k = &data->req; in http_parse_headers()
3864 result = Curl_dyn_addn(&data->state.headerb, buf, blen); in http_parse_headers()
3872 checkprotoprefix(data, conn, in http_parse_headers()
3873 Curl_dyn_ptr(&data->state.headerb), in http_parse_headers()
3874 Curl_dyn_len(&data->state.headerb)); in http_parse_headers()
3881 failf(data, "Invalid status line"); in http_parse_headers()
3884 if(!data->set.http09_allowed) { in http_parse_headers()
3885 failf(data, "Received HTTP/0.9 when not allowed"); in http_parse_headers()
3897 result = Curl_dyn_addn(&data->state.headerb, buf, consumed); in http_parse_headers()
3910 statusline st = checkprotoprefix(data, conn, in http_parse_headers()
3911 Curl_dyn_ptr(&data->state.headerb), in http_parse_headers()
3912 Curl_dyn_len(&data->state.headerb)); in http_parse_headers()
3917 failf(data, "Invalid status line"); in http_parse_headers()
3920 if(!data->set.http09_allowed) { in http_parse_headers()
3921 failf(data, "Received HTTP/0.9 when not allowed"); in http_parse_headers()
3930 result = http_rw_hd(data, Curl_dyn_ptr(&data->state.headerb), in http_parse_headers()
3931 Curl_dyn_len(&data->state.headerb), in http_parse_headers()
3936 Curl_dyn_reset(&data->state.headerb); in http_parse_headers()
3951 Curl_dyn_free(&data->state.headerb); in http_parse_headers()
3956 CURLcode Curl_http_write_resp_hd(struct Curl_easy *data, in Curl_http_write_resp_hd() argument
3964 result = http_rw_hd(data, hd, hdlen, &tmp, 0, &consumed); in Curl_http_write_resp_hd()
3966 result = Curl_client_write(data, (CLIENTWRITE_BODY|CLIENTWRITE_EOS), in Curl_http_write_resp_hd()
3976 CURLcode Curl_http_write_resp_hds(struct Curl_easy *data, in Curl_http_write_resp_hds() argument
3980 if(!data->req.header) { in Curl_http_write_resp_hds()
3987 result = http_parse_headers(data, buf, blen, pconsumed); in Curl_http_write_resp_hds()
3988 if(!result && !data->req.header) { in Curl_http_write_resp_hds()
3989 if(!data->req.no_body && Curl_dyn_len(&data->state.headerb)) { in Curl_http_write_resp_hds()
3993 result = Curl_client_write(data, CLIENTWRITE_BODY, in Curl_http_write_resp_hds()
3994 Curl_dyn_ptr(&data->state.headerb), in Curl_http_write_resp_hds()
3995 Curl_dyn_len(&data->state.headerb)); in Curl_http_write_resp_hds()
3997 Curl_dyn_free(&data->state.headerb); in Curl_http_write_resp_hds()
4003 CURLcode Curl_http_write_resp(struct Curl_easy *data, in Curl_http_write_resp() argument
4011 result = Curl_http_write_resp_hds(data, buf, blen, &consumed); in Curl_http_write_resp()
4012 if(result || data->req.done) in Curl_http_write_resp()
4020 DEBUGASSERT(!blen || !data->req.header); in Curl_http_write_resp()
4021 if(!data->req.header && (blen || is_eos)) { in Curl_http_write_resp()
4026 result = Curl_client_write(data, flags, (char *)buf, blen); in Curl_http_write_resp()
4298 struct httpreq *req, struct Curl_easy *data) in Curl_http_req_to_h2() argument
4312 scheme = Curl_checkheaders(data, STRCONST(HTTP_PSEUDO_SCHEME)); in Curl_http_req_to_h2()
4317 infof(data, "set pseudo header %s to %s", HTTP_PSEUDO_SCHEME, scheme); in Curl_http_req_to_h2()
4320 scheme = (data->conn && data->conn->handler->flags & PROTOPT_SSL) ? in Curl_http_req_to_h2()
4409 static void http_exp100_continue(struct Curl_easy *data, in http_exp100_continue() argument
4415 data->req.keepon |= KEEP_SEND; in http_exp100_continue()
4416 data->req.keepon &= ~KEEP_SEND_TIMED; in http_exp100_continue()
4417 Curl_expire_done(data, EXPIRE_100_TIMEOUT); in http_exp100_continue()
4421 static CURLcode cr_exp100_read(struct Curl_easy *data, in cr_exp100_read() argument
4431 if(!Curl_req_sendbuf_empty(data)) { in cr_exp100_read()
4434 DEBUGF(infof(data, "cr_exp100_read, request not full sent yet")); in cr_exp100_read()
4441 DEBUGF(infof(data, "cr_exp100_read, start AWAITING_CONTINUE, " in cr_exp100_read()
4442 "timeout %ldms", data->set.expect_100_timeout)); in cr_exp100_read()
4445 Curl_expire(data, data->set.expect_100_timeout, EXPIRE_100_TIMEOUT); in cr_exp100_read()
4446 data->req.keepon &= ~KEEP_SEND; in cr_exp100_read()
4447 data->req.keepon |= KEEP_SEND_TIMED; in cr_exp100_read()
4452 DEBUGF(infof(data, "cr_exp100_read, expectation failed, error")); in cr_exp100_read()
4458 if(ms < data->set.expect_100_timeout) { in cr_exp100_read()
4459 DEBUGF(infof(data, "cr_exp100_read, AWAITING_CONTINUE, not expired")); in cr_exp100_read()
4460 data->req.keepon &= ~KEEP_SEND; in cr_exp100_read()
4461 data->req.keepon |= KEEP_SEND_TIMED; in cr_exp100_read()
4467 http_exp100_continue(data, reader); in cr_exp100_read()
4468 infof(data, "Done waiting for 100-continue"); in cr_exp100_read()
4471 DEBUGF(infof(data, "cr_exp100_read, pass through")); in cr_exp100_read()
4472 return Curl_creader_read(data, reader->next, buf, blen, nread, eos); in cr_exp100_read()
4476 static void cr_exp100_done(struct Curl_easy *data, in cr_exp100_done() argument
4481 data->req.keepon &= ~KEEP_SEND_TIMED; in cr_exp100_done()
4482 Curl_expire_done(data, EXPIRE_100_TIMEOUT); in cr_exp100_done()
4500 static CURLcode http_exp100_add_reader(struct Curl_easy *data) in http_exp100_add_reader() argument
4505 result = Curl_creader_create(&reader, data, &cr_exp100, in http_exp100_add_reader()
4508 result = Curl_creader_add(data, reader); in http_exp100_add_reader()
4515 Curl_creader_free(data, reader); in http_exp100_add_reader()
4519 void Curl_http_exp100_got100(struct Curl_easy *data) in Curl_http_exp100_got100() argument
4521 struct Curl_creader *r = Curl_creader_get_by_type(data, &cr_exp100); in Curl_http_exp100_got100()
4523 http_exp100_continue(data, r); in Curl_http_exp100_got100()
4526 static bool http_exp100_is_waiting(struct Curl_easy *data) in http_exp100_is_waiting() argument
4528 struct Curl_creader *r = Curl_creader_get_by_type(data, &cr_exp100); in http_exp100_is_waiting()
4536 static void http_exp100_send_anyway(struct Curl_easy *data) in http_exp100_send_anyway() argument
4538 struct Curl_creader *r = Curl_creader_get_by_type(data, &cr_exp100); in http_exp100_send_anyway()
4540 http_exp100_continue(data, r); in http_exp100_send_anyway()
4543 bool Curl_http_exp100_is_selected(struct Curl_easy *data) in Curl_http_exp100_is_selected() argument
4545 struct Curl_creader *r = Curl_creader_get_by_type(data, &cr_exp100); in Curl_http_exp100_is_selected()