Lines Matching refs:data

71 static CURLcode cr_hyper_add(struct Curl_easy *data);
82 struct Curl_easy *data = io_ctx->data; in Curl_hyper_recv() local
83 struct connectdata *conn = data->conn; in Curl_hyper_recv()
89 DEBUGF(infof(data, "Curl_hyper_recv(%zu)", buflen)); in Curl_hyper_recv()
90 result = Curl_conn_recv(data, io_ctx->sockindex, in Curl_hyper_recv()
94 DEBUGF(infof(data, "Curl_hyper_recv(%zu) -> EAGAIN", buflen)); in Curl_hyper_recv()
95 if(data->hyp.read_waker) in Curl_hyper_recv()
96 hyper_waker_free(data->hyp.read_waker); in Curl_hyper_recv()
97 data->hyp.read_waker = hyper_context_waker(ctx); in Curl_hyper_recv()
98 if(!data->hyp.read_waker) { in Curl_hyper_recv()
99 failf(data, "Couldn't make the read hyper_context_waker"); in Curl_hyper_recv()
105 failf(data, "Curl_read failed"); in Curl_hyper_recv()
108 DEBUGF(infof(data, "Curl_hyper_recv(%zu) -> %zd", buflen, nread)); in Curl_hyper_recv()
116 struct Curl_easy *data = io_ctx->data; in Curl_hyper_send() local
120 DEBUGF(infof(data, "Curl_hyper_send(%zu)", buflen)); in Curl_hyper_send()
121 result = Curl_conn_send(data, io_ctx->sockindex, in Curl_hyper_send()
124 DEBUGF(infof(data, "Curl_hyper_send(%zu) -> EAGAIN", buflen)); in Curl_hyper_send()
126 if(data->hyp.write_waker) in Curl_hyper_send()
127 hyper_waker_free(data->hyp.write_waker); in Curl_hyper_send()
128 data->hyp.write_waker = hyper_context_waker(ctx); in Curl_hyper_send()
129 if(!data->hyp.write_waker) { in Curl_hyper_send()
130 failf(data, "Couldn't make the write hyper_context_waker"); in Curl_hyper_send()
136 failf(data, "Curl_write failed"); in Curl_hyper_send()
139 DEBUGF(infof(data, "Curl_hyper_send(%zu) -> %zd", buflen, nwrote)); in Curl_hyper_send()
149 struct Curl_easy *data = (struct Curl_easy *)userdata; in hyper_each_header() local
156 failf(data, "Too long response header"); in hyper_each_header()
157 data->state.hresult = CURLE_TOO_LARGE; in hyper_each_header()
161 Curl_dyn_reset(&data->state.headerb); in hyper_each_header()
163 if(Curl_dyn_addf(&data->state.headerb, "%.*s: %.*s\r\n", in hyper_each_header()
168 if(Curl_dyn_addn(&data->state.headerb, STRCONST("\r\n"))) in hyper_each_header()
171 len = Curl_dyn_len(&data->state.headerb); in hyper_each_header()
172 headp = Curl_dyn_ptr(&data->state.headerb); in hyper_each_header()
174 result = Curl_http_header(data, headp, len); in hyper_each_header()
176 data->state.hresult = result; in hyper_each_header()
180 Curl_debug(data, CURLINFO_HEADER_IN, headp, len); in hyper_each_header()
183 if(data->state.hconnect) in hyper_each_header()
185 if(data->req.httpcode/100 == 1) in hyper_each_header()
187 result = Curl_client_write(data, writetype, headp, len); in hyper_each_header()
189 data->state.hresult = CURLE_ABORTED_BY_CALLBACK; in hyper_each_header()
193 result = Curl_bump_headersize(data, len, FALSE); in hyper_each_header()
195 data->state.hresult = result; in hyper_each_header()
205 struct Curl_easy *data = (struct Curl_easy *)userdata; in hyper_body_chunk() local
206 struct SingleRequest *k = &data->req; in hyper_body_chunk()
211 struct connectdata *conn = data->conn; in hyper_body_chunk()
213 (((data->req.httpcode == 401) && in hyper_body_chunk()
215 ((data->req.httpcode == 407) && in hyper_body_chunk()
217 infof(data, "Connection closed while negotiating NTLM"); in hyper_body_chunk()
218 data->state.authproblem = TRUE; in hyper_body_chunk()
219 Curl_safefree(data->req.newurl); in hyper_body_chunk()
222 if(Curl_http_exp100_is_selected(data)) { in hyper_body_chunk()
223 if(data->req.httpcode < 400) { in hyper_body_chunk()
224 Curl_http_exp100_got100(data); in hyper_body_chunk()
225 if(data->hyp.send_body_waker) { in hyper_body_chunk()
226 hyper_waker_wake(data->hyp.send_body_waker); in hyper_body_chunk()
227 data->hyp.send_body_waker = NULL; in hyper_body_chunk()
231 Curl_req_abort_sending(data); in hyper_body_chunk()
234 if(data->state.hconnect && (data->req.httpcode/100 != 2) && in hyper_body_chunk()
235 data->state.authproxy.done) { in hyper_body_chunk()
236 data->req.done = TRUE; in hyper_body_chunk()
240 result = Curl_http_firstwrite(data); in hyper_body_chunk()
241 if(result || data->req.done) { in hyper_body_chunk()
242 infof(data, "Return early from hyper_body_chunk"); in hyper_body_chunk()
243 data->state.hresult = result; in hyper_body_chunk()
247 result = Curl_client_write(data, CLIENTWRITE_BODY, buf, len); in hyper_body_chunk()
250 data->state.hresult = result; in hyper_body_chunk()
261 static CURLcode status_line(struct Curl_easy *data, in status_line() argument
276 data->req.httpcode = http_status; in status_line()
277 data->req.httpversion = http_version == HYPER_HTTP_VERSION_1_1 ? 11 : in status_line()
279 if(data->state.hconnect) in status_line()
281 data->info.httpproxycode = http_status; in status_line()
283 conn->httpversion = (unsigned char)data->req.httpversion; in status_line()
285 data->state.httpwant = CURL_HTTP_VERSION_1_0; in status_line()
287 result = Curl_http_statusline(data, conn); in status_line()
292 Curl_dyn_reset(&data->state.headerb); in status_line()
294 result = Curl_dyn_addf(&data->state.headerb, "HTTP/%s %03d %.*s\r\n", in status_line()
300 len = Curl_dyn_len(&data->state.headerb); in status_line()
301 Curl_debug(data, CURLINFO_HEADER_IN, Curl_dyn_ptr(&data->state.headerb), in status_line()
305 if(data->state.hconnect) in status_line()
307 result = Curl_client_write(data, writetype, in status_line()
308 Curl_dyn_ptr(&data->state.headerb), len); in status_line()
312 result = Curl_bump_headersize(data, len, FALSE); in status_line()
320 static CURLcode empty_header(struct Curl_easy *data) in empty_header() argument
322 CURLcode result = Curl_http_size(data); in empty_header()
324 result = hyper_each_header(data, NULL, 0, NULL, 0) ? in empty_header()
327 failf(data, "hyperstream: could not pass blank header"); in empty_header()
330 Curl_cwriter_remove_by_name(data, "chunked"); in empty_header()
335 CURLcode Curl_hyper_stream(struct Curl_easy *data, in Curl_hyper_stream() argument
345 struct hyptransfer *h = &data->hyp; in Curl_hyper_stream()
351 struct SingleRequest *k = &data->req; in Curl_hyper_stream()
354 if(data->hyp.send_body_waker) { in Curl_hyper_stream()
357 hyper_waker_wake(data->hyp.send_body_waker); in Curl_hyper_stream()
358 data->hyp.send_body_waker = NULL; in Curl_hyper_stream()
383 if(data->state.hresult) { in Curl_hyper_stream()
385 result = data->state.hresult; in Curl_hyper_stream()
386 infof(data, "hyperstream is done (by early callback)"); in Curl_hyper_stream()
392 failf(data, "Hyper: [%d] %.*s", (int)code, (int)errlen, errbuf); in Curl_hyper_stream()
398 if(!data->req.bytecount) in Curl_hyper_stream()
406 data->req.headerbytecount++; in Curl_hyper_stream()
414 data->req.done = TRUE; in Curl_hyper_stream()
423 data->req.done = TRUE; in Curl_hyper_stream()
424 infof(data, "hyperstream is done"); in Curl_hyper_stream()
427 result = Curl_http_firstwrite(data); in Curl_hyper_stream()
433 DEBUGF(infof(data, "hyper: some background task done")); in Curl_hyper_stream()
443 failf(data, "hyperstream: could not get response"); in Curl_hyper_stream()
453 if(http_status == 417 && Curl_http_exp100_is_selected(data)) { in Curl_hyper_stream()
454 infof(data, "Got 417 while waiting for a 100"); in Curl_hyper_stream()
455 data->state.disableexpect = TRUE; in Curl_hyper_stream()
456 data->req.newurl = strdup(data->state.url); in Curl_hyper_stream()
457 Curl_req_abort_sending(data); in Curl_hyper_stream()
460 result = status_line(data, conn, in Curl_hyper_stream()
467 failf(data, "hyperstream: could not get response headers"); in Curl_hyper_stream()
473 hyper_headers_foreach(headers, hyper_each_header, data); in Curl_hyper_stream()
474 if(data->state.hresult) { in Curl_hyper_stream()
475 result = data->state.hresult; in Curl_hyper_stream()
479 result = empty_header(data); in Curl_hyper_stream()
489 result = Curl_ws_accept(data, NULL, 0); in Curl_hyper_stream()
494 failf(data, "Expected 101, got %u", k->httpcode); in Curl_hyper_stream()
504 result = Curl_http_auth_act(data); in Curl_hyper_stream()
510 failf(data, "hyperstream: could not get response body"); in Curl_hyper_stream()
514 foreach = hyper_body_foreach(resp_body, hyper_body_chunk, data); in Curl_hyper_stream()
516 failf(data, "hyperstream: body foreach failed"); in Curl_hyper_stream()
522 failf(data, "Couldn't hyper_executor_push the body-foreach"); in Curl_hyper_stream()
531 DEBUGF(infof(data, "hyper: unhandled tasktype %x", t)); in Curl_hyper_stream()
535 if(!result && Curl_xfer_needs_flush(data)) { in Curl_hyper_stream()
536 DEBUGF(infof(data, "Curl_hyper_stream(), connection needs flush")); in Curl_hyper_stream()
537 result = Curl_xfer_flush(data); in Curl_hyper_stream()
541 DEBUGF(infof(data, "Curl_hyper_stream() -> %d", result)); in Curl_hyper_stream()
547 static CURLcode debug_request(struct Curl_easy *data, in debug_request() argument
554 Curl_debug(data, CURLINFO_HEADER_OUT, req, strlen(req)); in debug_request()
566 CURLcode Curl_hyper_header(struct Curl_easy *data, hyper_headers *headers, in Curl_hyper_header() argument
609 failf(data, "hyper refused to add header '%s'", line); in Curl_hyper_header()
612 if(data->set.verbose) { in Curl_hyper_header()
618 Curl_debug(data, CURLINFO_HEADER_OUT, ptr, linelen + 2); in Curl_hyper_header()
622 Curl_debug(data, CURLINFO_HEADER_OUT, (char *)n, linelen); in Curl_hyper_header()
630 static CURLcode request_target(struct Curl_easy *data, in request_target() argument
640 result = Curl_http_target(data, conn, &r); in request_target()
646 failf(data, "error setting uri to hyper"); in request_target()
650 result = debug_request(data, method, Curl_dyn_ptr(&r)); in request_target()
661 struct Curl_easy *data = (struct Curl_easy *)userdata; in uploadstreamed() local
669 result = Curl_multi_xfer_ulbuf_borrow(data, &xfer_ulbuf, &xfer_ulblen); in uploadstreamed()
673 result = Curl_client_read(data, xfer_ulbuf, xfer_ulblen, &fillcount, &eos); in uploadstreamed()
687 data->req.writebytecount += fillcount; in uploadstreamed()
689 data->req.eos_read = TRUE; in uploadstreamed()
690 Curl_pgrsSetUploadCounter(data, data->req.writebytecount); in uploadstreamed()
694 data->req.eos_read = TRUE; in uploadstreamed()
700 if(data->hyp.send_body_waker) in uploadstreamed()
701 hyper_waker_free(data->hyp.send_body_waker); in uploadstreamed()
702 data->hyp.send_body_waker = hyper_context_waker(ctx); in uploadstreamed()
706 if(!data->req.upload_done && data->req.eos_read) { in uploadstreamed()
707 DEBUGF(infof(data, "hyper: uploadstreamed(), upload is done")); in uploadstreamed()
708 result = Curl_req_set_upload_done(data); in uploadstreamed()
712 Curl_multi_xfer_ulbuf_release(data, xfer_ulbuf); in uploadstreamed()
713 data->state.hresult = result; in uploadstreamed()
714 DEBUGF(infof(data, "hyper: uploadstreamed() -> %d", result)); in uploadstreamed()
721 static CURLcode finalize_request(struct Curl_easy *data, in finalize_request() argument
729 Curl_pgrsSetUploadSize(data, 0); /* no request body */ in finalize_request()
734 result = Curl_http_req_complete(data, &req, httpreq); in finalize_request()
741 result = Curl_hyper_header(data, headers, Curl_dyn_ptr(&req)); in finalize_request()
749 hyper_body_set_userdata(body, data); in finalize_request()
758 return cr_hyper_add(data); in finalize_request()
761 static CURLcode cookies(struct Curl_easy *data, in cookies() argument
769 result = Curl_http_cookies(data, conn, &req); in cookies()
771 result = Curl_hyper_header(data, headers, Curl_dyn_ptr(&req)); in cookies()
779 struct Curl_easy *data = (struct Curl_easy *)arg; in http1xx_cb() local
787 infof(data, "Got HTTP 1xx informational"); in http1xx_cb()
794 result = status_line(data, data->conn, in http1xx_cb()
799 failf(data, "hyperstream: could not get 1xx response headers"); in http1xx_cb()
803 data->state.hresult = result; in http1xx_cb()
807 hyper_headers_foreach(headers, hyper_each_header, data); in http1xx_cb()
810 if(empty_header(data)) in http1xx_cb()
814 if(data->state.hresult) in http1xx_cb()
815 infof(data, "ERROR in 1xx, bail out"); in http1xx_cb()
823 CURLcode Curl_http(struct Curl_easy *data, bool *done) in Curl_http() argument
825 struct connectdata *conn = data->conn; in Curl_http()
826 struct hyptransfer *h = &data->hyp; in Curl_http()
846 result = Curl_client_start(data); in Curl_http()
853 result = Curl_headers_init(data); in Curl_http()
857 infof(data, "Time for the Hyper dance"); in Curl_http()
860 result = Curl_http_host(data, conn); in Curl_http()
864 Curl_http_method(data, conn, &method, &httpreq); in Curl_http()
866 DEBUGASSERT(data->req.bytecount == 0); in Curl_http()
871 if(data->state.up.query) { in Curl_http()
872 pq = aprintf("%s?%s", data->state.up.path, data->state.up.query); in Curl_http()
878 result = Curl_http_output_auth(data, conn, method, httpreq, in Curl_http()
879 (pq ? pq : data->state.up.path), FALSE); in Curl_http()
885 result = Curl_http_req_set_reader(data, httpreq, &te); in Curl_http()
889 result = Curl_http_range(data, httpreq); in Curl_http()
893 result = Curl_http_useragent(data); in Curl_http()
899 failf(data, "Couldn't create hyper IO"); in Curl_http()
904 h->io_ctx.data = data; in Curl_http()
914 failf(data, "Couldn't create hyper executor"); in Curl_http()
922 failf(data, "Couldn't create hyper client options"); in Curl_http()
927 failf(data, "ALPN protocol h2 not supported with Hyper"); in Curl_http()
940 failf(data, "Couldn't create hyper client handshake"); in Curl_http()
948 failf(data, "Couldn't hyper_executor_push the handshake"); in Curl_http()
956 failf(data, "Couldn't hyper_executor_poll the handshake"); in Curl_http()
966 failf(data, "Couldn't hyper_request_new"); in Curl_http()
971 if(!Curl_use_http_1_1plus(data, conn)) { in Curl_http()
974 failf(data, "error setting HTTP version"); in Curl_http()
981 failf(data, "error setting method"); in Curl_http()
986 result = request_target(data, conn, method, req); in Curl_http()
992 failf(data, "hyper_request_headers"); in Curl_http()
997 rc = hyper_request_on_informational(req, http1xx_cb, data); in Curl_http()
1003 if(data->state.aptr.host) { in Curl_http()
1004 result = Curl_hyper_header(data, headers, data->state.aptr.host); in Curl_http()
1010 if(data->state.aptr.proxyuserpwd) { in Curl_http()
1011 result = Curl_hyper_header(data, headers, data->state.aptr.proxyuserpwd); in Curl_http()
1017 if(data->state.aptr.userpwd) { in Curl_http()
1018 result = Curl_hyper_header(data, headers, data->state.aptr.userpwd); in Curl_http()
1023 if((data->state.use_range && data->state.aptr.rangeline)) { in Curl_http()
1024 result = Curl_hyper_header(data, headers, data->state.aptr.rangeline); in Curl_http()
1029 if(data->set.str[STRING_USERAGENT] && in Curl_http()
1030 *data->set.str[STRING_USERAGENT] && in Curl_http()
1031 data->state.aptr.uagent) { in Curl_http()
1032 result = Curl_hyper_header(data, headers, data->state.aptr.uagent); in Curl_http()
1037 p_accept = Curl_checkheaders(data, in Curl_http()
1040 result = Curl_hyper_header(data, headers, p_accept); in Curl_http()
1045 result = Curl_hyper_header(data, headers, te); in Curl_http()
1051 if(conn->bits.altused && !Curl_checkheaders(data, STRCONST("Alt-Used"))) { in Curl_http()
1058 result = Curl_hyper_header(data, headers, altused); in Curl_http()
1067 !Curl_checkheaders(data, STRCONST("Proxy-Connection")) && in Curl_http()
1068 !Curl_checkProxyheaders(data, conn, STRCONST("Proxy-Connection"))) { in Curl_http()
1069 result = Curl_hyper_header(data, headers, "Proxy-Connection: Keep-Alive"); in Curl_http()
1075 Curl_safefree(data->state.aptr.ref); in Curl_http()
1076 if(data->state.referer && !Curl_checkheaders(data, STRCONST("Referer"))) { in Curl_http()
1077 data->state.aptr.ref = aprintf("Referer: %s\r\n", data->state.referer); in Curl_http()
1078 if(!data->state.aptr.ref) in Curl_http()
1081 result = Curl_hyper_header(data, headers, data->state.aptr.ref); in Curl_http()
1088 result = Curl_transferencode(data); in Curl_http()
1091 result = Curl_hyper_header(data, headers, data->state.aptr.te); in Curl_http()
1096 if(!Curl_checkheaders(data, STRCONST("Accept-Encoding")) && in Curl_http()
1097 data->set.str[STRING_ENCODING]) { in Curl_http()
1098 Curl_safefree(data->state.aptr.accept_encoding); in Curl_http()
1099 data->state.aptr.accept_encoding = in Curl_http()
1100 aprintf("Accept-Encoding: %s\r\n", data->set.str[STRING_ENCODING]); in Curl_http()
1101 if(!data->state.aptr.accept_encoding) in Curl_http()
1104 result = Curl_hyper_header(data, headers, in Curl_http()
1105 data->state.aptr.accept_encoding); in Curl_http()
1110 Curl_safefree(data->state.aptr.accept_encoding); in Curl_http()
1112 result = cookies(data, conn, headers); in Curl_http()
1117 result = Curl_ws_request(data, headers); in Curl_http()
1119 result = Curl_add_timecondition(data, headers); in Curl_http()
1123 result = Curl_add_custom_headers(data, FALSE, headers); in Curl_http()
1127 result = finalize_request(data, headers, req, httpreq); in Curl_http()
1131 Curl_debug(data, CURLINFO_HEADER_OUT, (char *)"\r\n", 2); in Curl_http()
1133 if(data->req.upload_chunky && data->req.authneg) { in Curl_http()
1134 data->req.upload_chunky = TRUE; in Curl_http()
1137 data->req.upload_chunky = FALSE; in Curl_http()
1141 failf(data, "hyper_clientconn_send"); in Curl_http()
1148 failf(data, "Couldn't hyper_executor_push the send"); in Curl_http()
1159 Curl_pgrsSetUploadSize(data, 0); /* nothing */ in Curl_http()
1160 result = Curl_req_set_upload_done(data); in Curl_http()
1165 Curl_xfer_setup1(data, CURL_XFER_SENDRECV, -1, TRUE); in Curl_http()
1170 Curl_safefree(data->state.aptr.userpwd); in Curl_http()
1172 Curl_safefree(data->state.aptr.proxyuserpwd); in Curl_http()
1191 void Curl_hyper_done(struct Curl_easy *data) in Curl_hyper_done() argument
1193 struct hyptransfer *h = &data->hyp; in Curl_hyper_done()
1212 static CURLcode cr_hyper_unpause(struct Curl_easy *data, in cr_hyper_unpause() argument
1216 if(data->hyp.send_body_waker) { in cr_hyper_unpause()
1217 hyper_waker_wake(data->hyp.send_body_waker); in cr_hyper_unpause()
1218 data->hyp.send_body_waker = NULL; in cr_hyper_unpause()
1239 static CURLcode cr_hyper_add(struct Curl_easy *data) in cr_hyper_add() argument
1244 result = Curl_creader_create(&reader, data, &cr_hyper_protocol, in cr_hyper_add()
1247 result = Curl_creader_add(data, reader); in cr_hyper_add()
1250 Curl_creader_free(data, reader); in cr_hyper_add()