Lines Matching refs:data

76   struct Curl_easy *data = userp;
77 struct connectdata *conn = data->conn;
83 DEBUGF(infof(data, "Curl_hyper_recv(%zu)", buflen));
84 result = Curl_read(data, conn->sockfd, (char *)buf, buflen, &nread);
87 DEBUGF(infof(data, "Curl_hyper_recv(%zu) -> EAGAIN", buflen));
88 if(data->hyp.read_waker)
89 hyper_waker_free(data->hyp.read_waker);
90 data->hyp.read_waker = hyper_context_waker(ctx);
91 if(!data->hyp.read_waker) {
92 failf(data, "Couldn't make the read hyper_context_waker");
98 failf(data, "Curl_read failed");
101 DEBUGF(infof(data, "Curl_hyper_recv(%zu) -> %zd", buflen, nread));
108 struct Curl_easy *data = userp;
109 struct connectdata *conn = data->conn;
113 DEBUGF(infof(data, "Curl_hyper_send(%zu)", buflen));
114 result = Curl_write(data, conn->sockfd, (void *)buf, buflen, &nwrote);
118 DEBUGF(infof(data, "Curl_hyper_send(%zu) -> EAGAIN", buflen));
120 if(data->hyp.write_waker)
121 hyper_waker_free(data->hyp.write_waker);
122 data->hyp.write_waker = hyper_context_waker(ctx);
123 if(!data->hyp.write_waker) {
124 failf(data, "Couldn't make the write hyper_context_waker");
130 failf(data, "Curl_write failed");
133 DEBUGF(infof(data, "Curl_hyper_send(%zu) -> %zd", buflen, nwrote));
143 struct Curl_easy *data = (struct Curl_easy *)userdata;
150 failf(data, "Too long response header");
151 data->state.hresult = CURLE_TOO_LARGE;
155 if(!data->req.bytecount)
156 Curl_pgrsTime(data, TIMER_STARTTRANSFER);
158 Curl_dyn_reset(&data->state.headerb);
160 if(Curl_dyn_addf(&data->state.headerb, "%.*s: %.*s\r\n",
165 if(Curl_dyn_addn(&data->state.headerb, STRCONST("\r\n")))
168 len = Curl_dyn_len(&data->state.headerb);
169 headp = Curl_dyn_ptr(&data->state.headerb);
171 result = Curl_http_header(data, data->conn, headp);
173 data->state.hresult = result;
177 Curl_debug(data, CURLINFO_HEADER_IN, headp, len);
180 if(data->state.hconnect)
182 if(data->req.httpcode/100 == 1)
184 result = Curl_client_write(data, writetype, headp, len);
186 data->state.hresult = CURLE_ABORTED_BY_CALLBACK;
190 result = Curl_bump_headersize(data, len, FALSE);
192 data->state.hresult = result;
202 struct Curl_easy *data = (struct Curl_easy *)userdata;
203 struct SingleRequest *k = &data->req;
209 struct connectdata *conn = data->conn;
211 (((data->req.httpcode == 401) &&
213 ((data->req.httpcode == 407) &&
215 infof(data, "Connection closed while negotiating NTLM");
216 data->state.authproblem = TRUE;
217 Curl_safefree(data->req.newurl);
220 if(data->state.expect100header) {
221 Curl_expire_done(data, EXPIRE_100_TIMEOUT);
222 if(data->req.httpcode < 400) {
224 if(data->hyp.exp100_waker) {
225 hyper_waker_wake(data->hyp.exp100_waker);
226 data->hyp.exp100_waker = NULL;
233 if(data->state.hconnect && (data->req.httpcode/100 != 2) &&
234 data->state.authproxy.done) {
239 result = Curl_http_firstwrite(data, data->conn, &done);
241 infof(data, "Return early from hyper_body_chunk");
242 data->state.hresult = result;
246 result = Curl_client_write(data, CLIENTWRITE_BODY, buf, len);
249 data->state.hresult = result;
260 static CURLcode status_line(struct Curl_easy *data,
275 data->req.httpcode = http_status;
277 if(data->state.hconnect)
279 data->info.httpproxycode = http_status;
285 data->state.httpwant = CURL_HTTP_VERSION_1_0;
287 result = Curl_http_statusline(data, conn);
292 Curl_dyn_reset(&data->state.headerb);
294 result = Curl_dyn_addf(&data->state.headerb, "HTTP/%s %03d %.*s\r\n",
300 len = Curl_dyn_len(&data->state.headerb);
301 Curl_debug(data, CURLINFO_HEADER_IN, Curl_dyn_ptr(&data->state.headerb),
305 if(data->state.hconnect)
307 result = Curl_client_write(data, writetype,
308 Curl_dyn_ptr(&data->state.headerb), len);
312 result = Curl_bump_headersize(data, len, FALSE);
320 static CURLcode empty_header(struct Curl_easy *data)
322 CURLcode result = Curl_http_size(data);
324 result = hyper_each_header(data, NULL, 0, NULL, 0) ?
327 failf(data, "hyperstream: couldn't pass blank header");
330 Curl_cwriter_remove_by_name(data, "chunked");
335 CURLcode Curl_hyper_stream(struct Curl_easy *data,
346 struct hyptransfer *h = &data->hyp;
352 struct SingleRequest *k = &data->req;
358 if(ms >= data->set.expect_100_timeout) {
362 Curl_expire_done(data, EXPIRE_100_TIMEOUT);
363 infof(data, "Done waiting for 100-continue");
364 if(data->hyp.exp100_waker) {
365 hyper_waker_wake(data->hyp.exp100_waker);
366 data->hyp.exp100_waker = NULL;
394 if(data->state.hresult) {
396 result = data->state.hresult;
397 infof(data, "hyperstream is done (by early callback)");
403 failf(data, "Hyper: [%d] %.*s", (int)code, (int)errlen, errbuf);
409 if(!data->req.bytecount)
417 data->req.headerbytecount++;
435 infof(data, "hyperstream is done");
439 result = Curl_http_firstwrite(data, data->conn, &stilldone);
456 failf(data, "hyperstream: couldn't get response");
465 if(http_status == 417 && data->state.expect100header) {
466 infof(data, "Got 417 while waiting for a 100");
467 data->state.disableexpect = TRUE;
468 data->req.newurl = strdup(data->state.url);
469 Curl_done_sending(data, k);
472 result = status_line(data, conn,
479 failf(data, "hyperstream: couldn't get response headers");
485 hyper_headers_foreach(headers, hyper_each_header, data);
486 if(data->state.hresult) {
487 result = data->state.hresult;
491 result = empty_header(data);
501 result = Curl_ws_accept(data, NULL, 0);
506 failf(data, "Expected 101, got %u", k->httpcode);
516 result = Curl_http_auth_act(data);
522 failf(data, "hyperstream: couldn't get response body");
526 foreach = hyper_body_foreach(resp_body, hyper_body_chunk, data);
528 failf(data, "hyperstream: body foreach failed");
534 failf(data, "Couldn't hyper_executor_push the body-foreach");
547 static CURLcode debug_request(struct Curl_easy *data,
554 Curl_debug(data, CURLINFO_HEADER_OUT, req, strlen(req));
566 CURLcode Curl_hyper_header(struct Curl_easy *data, hyper_headers *headers,
609 failf(data, "hyper refused to add header '%s'", line);
612 if(data->set.verbose) {
618 Curl_debug(data, CURLINFO_HEADER_OUT, ptr, linelen + 2);
622 Curl_debug(data, CURLINFO_HEADER_OUT, (char *)n, linelen);
630 static CURLcode request_target(struct Curl_easy *data,
640 result = Curl_http_target(data, conn, &r);
646 failf(data, "error setting uri to hyper");
650 result = debug_request(data, method, Curl_dyn_ptr(&r));
660 struct Curl_easy *data = (struct Curl_easy *)userdata;
662 if(data->req.exp100 > EXP100_SEND_DATA) {
663 if(data->req.exp100 == EXP100_FAILED)
667 if(data->hyp.exp100_waker)
668 hyper_waker_free(data->hyp.exp100_waker);
669 data->hyp.exp100_waker = hyper_context_waker(ctx);
672 if(data->req.upload_done)
676 hyper_buf *copy = hyper_buf_copy(data->set.postfields,
677 (size_t)data->req.p.http->postsize);
681 data->state.hresult = CURLE_OUT_OF_MEMORY;
686 data->req.writebytecount += (size_t)data->req.p.http->postsize;
687 Curl_pgrsSetUploadCounter(data, data->req.writebytecount);
688 data->req.upload_done = TRUE;
697 struct Curl_easy *data = (struct Curl_easy *)userdata;
698 struct connectdata *conn = (struct connectdata *)data->conn;
702 if(data->req.exp100 > EXP100_SEND_DATA) {
703 if(data->req.exp100 == EXP100_FAILED)
707 if(data->hyp.exp100_waker)
708 hyper_waker_free(data->hyp.exp100_waker);
709 data->hyp.exp100_waker = hyper_context_waker(ctx);
713 if(data->req.upload_chunky && conn->bits.authneg) {
715 data->req.upload_chunky = FALSE;
719 result = Curl_fillreadbuffer(data, data->set.upload_buffer_size,
723 data->state.hresult = result;
727 if((data->req.keepon & KEEP_SEND_PAUSE) != KEEP_SEND_PAUSE)
732 if(data->hyp.send_body_waker)
733 hyper_waker_free(data->hyp.send_body_waker);
734 data->hyp.send_body_waker = hyper_context_waker(ctx);
739 hyper_buf *copy = hyper_buf_copy((uint8_t *)data->state.ulbuf, fillcount);
743 data->state.hresult = CURLE_OUT_OF_MEMORY;
748 data->req.writebytecount += fillcount;
749 Curl_pgrsSetUploadCounter(data, data->req.writebytecount);
759 static CURLcode bodysend(struct Curl_easy *data,
765 struct HTTP *http = data->req.p.http;
769 Curl_pgrsSetUploadSize(data, 0); /* no request body */
773 result = Curl_http_bodysend(data, conn, &req, httpreq);
776 result = Curl_hyper_header(data, headers, Curl_dyn_ptr(&req));
781 hyper_body_set_userdata(body, data);
782 if(data->set.postfields)
785 result = Curl_get_upload_buffer(data);
791 data->req.upload_fromhere = data->state.ulbuf;
803 static CURLcode cookies(struct Curl_easy *data,
811 result = Curl_http_cookies(data, conn, &req);
813 result = Curl_hyper_header(data, headers, Curl_dyn_ptr(&req));
821 struct Curl_easy *data = (struct Curl_easy *)arg;
829 infof(data, "Got HTTP 1xx informational");
836 result = status_line(data, data->conn,
841 failf(data, "hyperstream: couldn't get 1xx response headers");
845 data->state.hresult = result;
849 hyper_headers_foreach(headers, hyper_each_header, data);
850 /* this callback also sets data->state.hresult on error */
852 if(empty_header(data))
856 if(data->state.hresult)
857 infof(data, "ERROR in 1xx, bail out");
865 CURLcode Curl_http(struct Curl_easy *data, bool *done)
867 struct connectdata *conn = data->conn;
868 struct hyptransfer *h = &data->hyp;
888 Curl_client_cleanup(data);
890 infof(data, "Time for the Hyper dance");
893 result = Curl_http_host(data, conn);
897 Curl_http_method(data, conn, &method, &httpreq);
899 DEBUGASSERT(data->req.bytecount == 0);
904 if(data->state.up.query) {
905 pq = aprintf("%s?%s", data->state.up.path, data->state.up.query);
909 result = Curl_http_output_auth(data, conn, method, httpreq,
910 (pq ? pq : data->state.up.path), FALSE);
916 result = Curl_http_resume(data, conn, httpreq);
920 result = Curl_http_range(data, httpreq);
924 result = Curl_http_useragent(data);
930 failf(data, "Couldn't create hyper IO");
934 /* tell Hyper how to read/write network data */
935 hyper_io_set_userdata(io, data);
943 failf(data, "Couldn't create hyper executor");
951 failf(data, "Couldn't create hyper client options");
956 failf(data, "ALPN protocol h2 not supported with Hyper");
969 failf(data, "Couldn't create hyper client handshake");
977 failf(data, "Couldn't hyper_executor_push the handshake");
985 failf(data, "Couldn't hyper_executor_poll the handshake");
995 failf(data, "Couldn't hyper_request_new");
1000 if(!Curl_use_http_1_1plus(data, conn)) {
1003 failf(data, "error setting HTTP version");
1009 if(!data->state.disableexpect) {
1010 data->state.expect100header = TRUE;
1015 failf(data, "error setting method");
1020 result = request_target(data, conn, method, req);
1026 failf(data, "hyper_request_headers");
1031 rc = hyper_request_on_informational(req, http1xx_cb, data);
1037 result = Curl_http_body(data, conn, httpreq, &te);
1041 if(data->state.aptr.host) {
1042 result = Curl_hyper_header(data, headers, data->state.aptr.host);
1047 if(data->state.aptr.proxyuserpwd) {
1048 result = Curl_hyper_header(data, headers, data->state.aptr.proxyuserpwd);
1053 if(data->state.aptr.userpwd) {
1054 result = Curl_hyper_header(data, headers, data->state.aptr.userpwd);
1059 if((data->state.use_range && data->state.aptr.rangeline)) {
1060 result = Curl_hyper_header(data, headers, data->state.aptr.rangeline);
1065 if(data->set.str[STRING_USERAGENT] &&
1066 *data->set.str[STRING_USERAGENT] &&
1067 data->state.aptr.uagent) {
1068 result = Curl_hyper_header(data, headers, data->state.aptr.uagent);
1073 p_accept = Curl_checkheaders(data,
1076 result = Curl_hyper_header(data, headers, p_accept);
1081 result = Curl_hyper_header(data, headers, te);
1087 if(conn->bits.altused && !Curl_checkheaders(data, STRCONST("Alt-Used"))) {
1094 result = Curl_hyper_header(data, headers, altused);
1103 !Curl_checkheaders(data, STRCONST("Proxy-Connection")) &&
1104 !Curl_checkProxyheaders(data, conn, STRCONST("Proxy-Connection"))) {
1105 result = Curl_hyper_header(data, headers, "Proxy-Connection: Keep-Alive");
1111 Curl_safefree(data->state.aptr.ref);
1112 if(data->state.referer && !Curl_checkheaders(data, STRCONST("Referer"))) {
1113 data->state.aptr.ref = aprintf("Referer: %s\r\n", data->state.referer);
1114 if(!data->state.aptr.ref)
1117 result = Curl_hyper_header(data, headers, data->state.aptr.ref);
1124 result = Curl_transferencode(data);
1127 result = Curl_hyper_header(data, headers, data->state.aptr.te);
1132 if(!Curl_checkheaders(data, STRCONST("Accept-Encoding")) &&
1133 data->set.str[STRING_ENCODING]) {
1134 Curl_safefree(data->state.aptr.accept_encoding);
1135 data->state.aptr.accept_encoding =
1136 aprintf("Accept-Encoding: %s\r\n", data->set.str[STRING_ENCODING]);
1137 if(!data->state.aptr.accept_encoding)
1140 result = Curl_hyper_header(data, headers,
1141 data->state.aptr.accept_encoding);
1146 Curl_safefree(data->state.aptr.accept_encoding);
1148 result = cookies(data, conn, headers);
1153 result = Curl_ws_request(data, headers);
1155 result = Curl_add_timecondition(data, headers);
1159 result = Curl_add_custom_headers(data, FALSE, headers);
1163 result = bodysend(data, conn, headers, req, httpreq);
1167 Curl_debug(data, CURLINFO_HEADER_OUT, (char *)"\r\n", 2);
1169 if(data->req.upload_chunky && conn->bits.authneg) {
1170 data->req.upload_chunky = TRUE;
1173 data->req.upload_chunky = FALSE;
1177 failf(data, "hyper_clientconn_send");
1184 failf(data, "Couldn't hyper_executor_push the send");
1195 Curl_pgrsSetUploadSize(data, 0); /* nothing */
1196 Curl_setup_transfer(data, FIRSTSOCKET, -1, TRUE, -1);
1199 if(data->state.expect100header)
1202 data->req.start100 = Curl_now();
1206 Curl_safefree(data->state.aptr.userpwd);
1207 Curl_safefree(data->state.aptr.proxyuserpwd);
1229 void Curl_hyper_done(struct Curl_easy *data)
1231 struct hyptransfer *h = &data->hyp;