Lines Matching refs:data

99 char *Curl_checkheaders(const struct Curl_easy *data,  in Curl_checkheaders()  argument
107 for(head = data->set.headers; head; head = head->next) { in Curl_checkheaders()
108 if(strncasecompare(head->data, thisheader, thislen) && in Curl_checkheaders()
109 Curl_headersep(head->data[thislen]) ) in Curl_checkheaders()
110 return head->data; in Curl_checkheaders()
117 static int data_pending(struct Curl_easy *data) in data_pending() argument
119 struct connectdata *conn = data->conn; in data_pending()
122 return Curl_conn_data_pending(data, SECONDARYSOCKET); in data_pending()
127 Curl_conn_data_pending(data, FIRSTSOCKET); in data_pending()
134 bool Curl_meets_timecondition(struct Curl_easy *data, time_t timeofdoc) in Curl_meets_timecondition() argument
136 if((timeofdoc == 0) || (data->set.timevalue == 0)) in Curl_meets_timecondition()
139 switch(data->set.timecondition) { in Curl_meets_timecondition()
142 if(timeofdoc <= data->set.timevalue) { in Curl_meets_timecondition()
143 infof(data, in Curl_meets_timecondition()
145 data->info.timecond = TRUE; in Curl_meets_timecondition()
150 if(timeofdoc >= data->set.timevalue) { in Curl_meets_timecondition()
151 infof(data, in Curl_meets_timecondition()
153 data->info.timecond = TRUE; in Curl_meets_timecondition()
162 static CURLcode xfer_recv_shutdown(struct Curl_easy *data, bool *done) in xfer_recv_shutdown() argument
166 if(!data || !data->conn) in xfer_recv_shutdown()
168 if(data->conn->sockfd == CURL_SOCKET_BAD) in xfer_recv_shutdown()
170 sockindex = (data->conn->sockfd == data->conn->sock[SECONDARYSOCKET]); in xfer_recv_shutdown()
171 return Curl_conn_shutdown(data, sockindex, done); in xfer_recv_shutdown()
174 static bool xfer_recv_shutdown_started(struct Curl_easy *data) in xfer_recv_shutdown_started() argument
178 if(!data || !data->conn) in xfer_recv_shutdown_started()
180 if(data->conn->sockfd == CURL_SOCKET_BAD) in xfer_recv_shutdown_started()
182 sockindex = (data->conn->sockfd == data->conn->sock[SECONDARYSOCKET]); in xfer_recv_shutdown_started()
183 return Curl_shutdown_started(data, sockindex); in xfer_recv_shutdown_started()
186 CURLcode Curl_xfer_send_shutdown(struct Curl_easy *data, bool *done) in Curl_xfer_send_shutdown() argument
190 if(!data || !data->conn) in Curl_xfer_send_shutdown()
192 if(data->conn->writesockfd == CURL_SOCKET_BAD) in Curl_xfer_send_shutdown()
194 sockindex = (data->conn->writesockfd == data->conn->sock[SECONDARYSOCKET]); in Curl_xfer_send_shutdown()
195 return Curl_conn_shutdown(data, sockindex, done); in Curl_xfer_send_shutdown()
207 static ssize_t xfer_recv_resp(struct Curl_easy *data, in xfer_recv_resp() argument
217 if(!eos_reliable && !data->req.header && data->req.size != -1) { in xfer_recv_resp()
218 curl_off_t totalleft = data->req.size - data->req.bytecount; in xfer_recv_resp()
224 else if(xfer_recv_shutdown_started(data)) { in xfer_recv_resp()
235 *err = Curl_xfer_recv(data, buf, blen, &nread); in xfer_recv_resp()
241 if(data->req.shutdown) { in xfer_recv_resp()
243 *err = xfer_recv_shutdown(data, &done); in xfer_recv_resp()
251 DEBUGF(infof(data, "sendrecv_dl: we are done")); in xfer_recv_resp()
262 static CURLcode sendrecv_dl(struct Curl_easy *data, in sendrecv_dl() argument
266 struct connectdata *conn = data->conn; in sendrecv_dl()
274 result = Curl_multi_xfer_buf_borrow(data, &xfer_buf, &xfer_blen); in sendrecv_dl()
295 if(bytestoread && data->set.max_recv_speed > 0) { in sendrecv_dl()
301 if(data->set.max_recv_speed < (curl_off_t)bytestoread) in sendrecv_dl()
302 bytestoread = (size_t)data->set.max_recv_speed; in sendrecv_dl()
305 nread = xfer_recv_resp(data, buf, bytestoread, is_multiplex, &result); in sendrecv_dl()
310 if(data->req.download_done && data->req.no_body && in sendrecv_dl()
311 !data->req.resp_trailer) { in sendrecv_dl()
312 DEBUGF(infof(data, "EAGAIN, download done, no trailer announced, " in sendrecv_dl()
330 DEBUGF(infof(data, "nread == 0, stream closed, bailing")); in sendrecv_dl()
332 DEBUGF(infof(data, "nread <= 0, server closed connection, bailing")); in sendrecv_dl()
333 result = Curl_req_stop_send_recv(data); in sendrecv_dl()
341 result = Curl_xfer_write_resp(data, buf, blen, is_eos); in sendrecv_dl()
342 if(result || data->req.done) in sendrecv_dl()
348 if((!is_multiplex && data->req.download_done) || is_eos) { in sendrecv_dl()
349 data->req.keepon &= ~KEEP_RECV; in sendrecv_dl()
357 if((maxloops <= 0) || data_pending(data)) { in sendrecv_dl()
360 data->state.select_bits = CURL_CSELECT_IN; in sendrecv_dl()
362 data->state.select_bits |= CURL_CSELECT_OUT; in sendrecv_dl()
370 infof(data, "we are done reading and this is set to close, stop send"); in sendrecv_dl()
371 Curl_req_abort_sending(data); in sendrecv_dl()
375 Curl_multi_xfer_buf_release(data, xfer_buf); in sendrecv_dl()
377 DEBUGF(infof(data, "sendrecv_dl() -> %d", result)); in sendrecv_dl()
384 static CURLcode sendrecv_ul(struct Curl_easy *data, int *didwhat) in sendrecv_ul() argument
389 DEBUGASSERT(!Curl_req_done_sending(data)); in sendrecv_ul()
391 if(!Curl_req_done_sending(data)) { in sendrecv_ul()
393 return Curl_req_send_more(data); in sendrecv_ul()
398 static int select_bits_paused(struct Curl_easy *data, int select_bits) in select_bits_paused() argument
408 !(data->req.keepon & KEEP_RECV_PAUSE)) || in select_bits_paused()
410 !(data->req.keepon & KEEP_SEND_PAUSE))) in select_bits_paused()
413 return (data->req.keepon & (KEEP_RECV_PAUSE|KEEP_SEND_PAUSE)); in select_bits_paused()
420 CURLcode Curl_sendrecv(struct Curl_easy *data, struct curltime *nowp) in Curl_sendrecv() argument
422 struct SingleRequest *k = &data->req; in Curl_sendrecv()
427 if(data->state.select_bits) { in Curl_sendrecv()
428 if(select_bits_paused(data, data->state.select_bits)) { in Curl_sendrecv()
434 data->state.select_bits = 0; in Curl_sendrecv()
438 if(data->conn->datastream) { in Curl_sendrecv()
439 result = data->conn->datastream(data, data->conn, &didwhat, in Curl_sendrecv()
441 if(result || data->req.done) in Curl_sendrecv()
449 result = sendrecv_dl(data, k, &didwhat); in Curl_sendrecv()
450 if(result || data->req.done) in Curl_sendrecv()
455 if(Curl_req_want_send(data) || (data->req.keepon & KEEP_SEND_TIMED)) { in Curl_sendrecv()
456 result = sendrecv_ul(data, &didwhat); in Curl_sendrecv()
466 result = Curl_conn_ev_data_idle(data); in Curl_sendrecv()
471 if(Curl_pgrsUpdate(data)) in Curl_sendrecv()
474 result = Curl_speedcheck(data, *nowp); in Curl_sendrecv()
479 if(0 > Curl_timeleft(data, nowp, FALSE)) { in Curl_sendrecv()
481 failf(data, "Operation timed out after %" FMT_TIMEDIFF_T in Curl_sendrecv()
484 Curl_timediff(*nowp, data->progress.t_startsingle), in Curl_sendrecv()
488 failf(data, "Operation timed out after %" FMT_TIMEDIFF_T in Curl_sendrecv()
490 Curl_timediff(*nowp, data->progress.t_startsingle), in Curl_sendrecv()
502 if(!(data->req.no_body) && (k->size != -1) && in Curl_sendrecv()
504 failf(data, "transfer closed with %" FMT_OFF_T in Curl_sendrecv()
509 if(Curl_pgrsUpdate(data)) { in Curl_sendrecv()
517 data->req.done = TRUE; in Curl_sendrecv()
521 DEBUGF(infof(data, "Curl_sendrecv() -> %d", result)); in Curl_sendrecv()
527 void Curl_init_CONNECT(struct Curl_easy *data) in Curl_init_CONNECT() argument
529 data->state.fread_func = data->set.fread_func_set; in Curl_init_CONNECT()
530 data->state.in = data->set.in_set; in Curl_init_CONNECT()
531 data->state.upload = (data->state.httpreq == HTTPREQ_PUT); in Curl_init_CONNECT()
539 CURLcode Curl_pretransfer(struct Curl_easy *data) in Curl_pretransfer() argument
543 if(!data->state.url && !data->set.uh) { in Curl_pretransfer()
545 failf(data, "No URL set"); in Curl_pretransfer()
550 if(data->state.url_alloc) { in Curl_pretransfer()
552 Curl_safefree(data->state.url); in Curl_pretransfer()
553 data->state.url_alloc = FALSE; in Curl_pretransfer()
556 if(!data->state.url && data->set.uh) { in Curl_pretransfer()
558 free(data->set.str[STRING_SET_URL]); in Curl_pretransfer()
559 uc = curl_url_get(data->set.uh, in Curl_pretransfer()
560 CURLUPART_URL, &data->set.str[STRING_SET_URL], 0); in Curl_pretransfer()
562 failf(data, "No URL set"); in Curl_pretransfer()
567 if(data->set.postfields && data->set.set_resume_from) { in Curl_pretransfer()
569 failf(data, "cannot mix POSTFIELDS with RESUME_FROM"); in Curl_pretransfer()
573 data->state.prefer_ascii = data->set.prefer_ascii; in Curl_pretransfer()
575 data->state.list_only = data->set.list_only; in Curl_pretransfer()
577 data->state.httpreq = data->set.method; in Curl_pretransfer()
578 data->state.url = data->set.str[STRING_SET_URL]; in Curl_pretransfer()
583 result = Curl_ssl_initsessions(data, data->set.general_ssl.max_ssl_sessions); in Curl_pretransfer()
587 data->state.requests = 0; in Curl_pretransfer()
588 data->state.followlocation = 0; /* reset the location-follow counter */ in Curl_pretransfer()
589 data->state.this_is_a_follow = FALSE; /* reset this */ in Curl_pretransfer()
590 data->state.errorbuf = FALSE; /* no error has occurred */ in Curl_pretransfer()
591 data->state.httpwant = data->set.httpwant; in Curl_pretransfer()
592 data->state.httpversion = 0; in Curl_pretransfer()
593 data->state.authproblem = FALSE; in Curl_pretransfer()
594 data->state.authhost.want = data->set.httpauth; in Curl_pretransfer()
595 data->state.authproxy.want = data->set.proxyauth; in Curl_pretransfer()
596 Curl_safefree(data->info.wouldredirect); in Curl_pretransfer()
597 Curl_data_priority_clear_state(data); in Curl_pretransfer()
599 if(data->state.httpreq == HTTPREQ_PUT) in Curl_pretransfer()
600 data->state.infilesize = data->set.filesize; in Curl_pretransfer()
601 else if((data->state.httpreq != HTTPREQ_GET) && in Curl_pretransfer()
602 (data->state.httpreq != HTTPREQ_HEAD)) { in Curl_pretransfer()
603 data->state.infilesize = data->set.postfieldsize; in Curl_pretransfer()
604 if(data->set.postfields && (data->state.infilesize == -1)) in Curl_pretransfer()
605 data->state.infilesize = (curl_off_t)strlen(data->set.postfields); in Curl_pretransfer()
608 data->state.infilesize = 0; in Curl_pretransfer()
611 Curl_cookie_loadfiles(data); in Curl_pretransfer()
614 if(data->state.resolve) in Curl_pretransfer()
615 result = Curl_loadhostpairs(data); in Curl_pretransfer()
618 Curl_hsts_loadfiles(data); in Curl_pretransfer()
624 data->state.allow_port = TRUE; in Curl_pretransfer()
630 if(!data->set.no_signal) in Curl_pretransfer()
631 data->state.prev_signal = signal(SIGPIPE, SIG_IGN); in Curl_pretransfer()
634 Curl_initinfo(data); /* reset session-specific information "variables" */ in Curl_pretransfer()
635 Curl_pgrsResetTransferSizes(data); in Curl_pretransfer()
636 Curl_pgrsStartNow(data); in Curl_pretransfer()
641 data->state.authhost.picked &= data->state.authhost.want; in Curl_pretransfer()
642 data->state.authproxy.picked &= data->state.authproxy.want; in Curl_pretransfer()
645 data->state.wildcardmatch = data->set.wildcard_enabled; in Curl_pretransfer()
646 if(data->state.wildcardmatch) { in Curl_pretransfer()
648 if(!data->wildcard) { in Curl_pretransfer()
649 data->wildcard = calloc(1, sizeof(struct WildcardData)); in Curl_pretransfer()
650 if(!data->wildcard) in Curl_pretransfer()
653 wc = data->wildcard; in Curl_pretransfer()
665 result = Curl_hsts_loadcb(data, data->hsts); in Curl_pretransfer()
673 if(data->set.str[STRING_USERAGENT]) { in Curl_pretransfer()
674 Curl_safefree(data->state.aptr.uagent); in Curl_pretransfer()
675 data->state.aptr.uagent = in Curl_pretransfer()
676 aprintf("User-Agent: %s\r\n", data->set.str[STRING_USERAGENT]); in Curl_pretransfer()
677 if(!data->state.aptr.uagent) in Curl_pretransfer()
681 if(data->set.str[STRING_USERNAME] || in Curl_pretransfer()
682 data->set.str[STRING_PASSWORD]) in Curl_pretransfer()
683 data->state.creds_from = CREDS_OPTION; in Curl_pretransfer()
685 result = Curl_setstropt(&data->state.aptr.user, in Curl_pretransfer()
686 data->set.str[STRING_USERNAME]); in Curl_pretransfer()
688 result = Curl_setstropt(&data->state.aptr.passwd, in Curl_pretransfer()
689 data->set.str[STRING_PASSWORD]); in Curl_pretransfer()
692 result = Curl_setstropt(&data->state.aptr.proxyuser, in Curl_pretransfer()
693 data->set.str[STRING_PROXYUSERNAME]); in Curl_pretransfer()
695 result = Curl_setstropt(&data->state.aptr.proxypasswd, in Curl_pretransfer()
696 data->set.str[STRING_PROXYPASSWORD]); in Curl_pretransfer()
699 data->req.headerbytecount = 0; in Curl_pretransfer()
700 Curl_headers_cleanup(data); in Curl_pretransfer()
707 CURLcode Curl_retry_request(struct Curl_easy *data, char **url) in Curl_retry_request() argument
709 struct connectdata *conn = data->conn; in Curl_retry_request()
716 if(data->state.upload && in Curl_retry_request()
720 if((data->req.bytecount + data->req.headerbytecount == 0) && in Curl_retry_request()
722 (!data->req.no_body || (conn->handler->protocol & PROTO_FAMILY_HTTP)) in Curl_retry_request()
724 && (data->set.rtspreq != RTSPREQ_RECEIVE) in Curl_retry_request()
735 else if(data->state.refused_stream && in Curl_retry_request()
736 (data->req.bytecount + data->req.headerbytecount == 0) ) { in Curl_retry_request()
742 infof(data, "REFUSED_STREAM, retrying a fresh connect"); in Curl_retry_request()
743 data->state.refused_stream = FALSE; /* clear again */ in Curl_retry_request()
748 if(data->state.retrycount++ >= CONN_MAX_RETRIES) { in Curl_retry_request()
749 failf(data, "Connection died, tried %d times before giving up", in Curl_retry_request()
751 data->state.retrycount = 0; in Curl_retry_request()
754 infof(data, "Connection died, retrying a fresh connect (retry count: %d)", in Curl_retry_request()
755 data->state.retrycount); in Curl_retry_request()
756 *url = strdup(data->state.url); in Curl_retry_request()
766 Curl_creader_set_rewind(data, TRUE); in Curl_retry_request()
775 struct Curl_easy *data, /* transfer */ in xfer_setup() argument
787 struct SingleRequest *k = &data->req; in xfer_setup()
788 struct connectdata *conn = data->conn; in xfer_setup()
789 bool want_send = Curl_req_want_send(data); in xfer_setup()
825 Curl_pgrsSetDownloadSize(data, size); in xfer_setup()
828 if(k->getheader || !data->req.no_body) { in xfer_setup()
839 void Curl_xfer_setup_nop(struct Curl_easy *data) in Curl_xfer_setup_nop() argument
841 xfer_setup(data, -1, -1, FALSE, -1, FALSE, FALSE); in Curl_xfer_setup_nop()
844 void Curl_xfer_setup1(struct Curl_easy *data, in Curl_xfer_setup1() argument
852 xfer_setup(data, recv_index, recv_size, getheader, send_index, FALSE, FALSE); in Curl_xfer_setup1()
855 void Curl_xfer_setup2(struct Curl_easy *data, in Curl_xfer_setup2() argument
864 xfer_setup(data, recv_index, recv_size, FALSE, send_index, in Curl_xfer_setup2()
868 CURLcode Curl_xfer_write_resp(struct Curl_easy *data, in Curl_xfer_write_resp() argument
874 if(data->conn->handler->write_resp) { in Curl_xfer_write_resp()
877 result = data->conn->handler->write_resp(data, buf, blen, is_eos); in Curl_xfer_write_resp()
886 result = Curl_client_write(data, cwtype, buf, blen); in Curl_xfer_write_resp()
892 data->req.eos_written = TRUE; in Curl_xfer_write_resp()
893 data->req.download_done = TRUE; in Curl_xfer_write_resp()
895 CURL_TRC_WRITE(data, "xfer_write_resp(len=%zu, eos=%d) -> %d", in Curl_xfer_write_resp()
900 CURLcode Curl_xfer_write_resp_hd(struct Curl_easy *data, in Curl_xfer_write_resp_hd() argument
903 if(data->conn->handler->write_resp_hd) { in Curl_xfer_write_resp_hd()
906 return data->conn->handler->write_resp_hd(data, hd0, hdlen, is_eos); in Curl_xfer_write_resp_hd()
909 return Curl_xfer_write_resp(data, hd0, hdlen, is_eos); in Curl_xfer_write_resp_hd()
912 CURLcode Curl_xfer_write_done(struct Curl_easy *data, bool premature) in Curl_xfer_write_done() argument
915 return Curl_cw_out_done(data); in Curl_xfer_write_done()
918 bool Curl_xfer_needs_flush(struct Curl_easy *data) in Curl_xfer_needs_flush() argument
921 sockindex = ((data->conn->writesockfd != CURL_SOCKET_BAD) && in Curl_xfer_needs_flush()
922 (data->conn->writesockfd == data->conn->sock[SECONDARYSOCKET])); in Curl_xfer_needs_flush()
923 return Curl_conn_needs_flush(data, sockindex); in Curl_xfer_needs_flush()
926 CURLcode Curl_xfer_flush(struct Curl_easy *data) in Curl_xfer_flush() argument
929 sockindex = ((data->conn->writesockfd != CURL_SOCKET_BAD) && in Curl_xfer_flush()
930 (data->conn->writesockfd == data->conn->sock[SECONDARYSOCKET])); in Curl_xfer_flush()
931 return Curl_conn_flush(data, sockindex); in Curl_xfer_flush()
934 CURLcode Curl_xfer_send(struct Curl_easy *data, in Curl_xfer_send() argument
941 DEBUGASSERT(data); in Curl_xfer_send()
942 DEBUGASSERT(data->conn); in Curl_xfer_send()
944 sockindex = ((data->conn->writesockfd != CURL_SOCKET_BAD) && in Curl_xfer_send()
945 (data->conn->writesockfd == data->conn->sock[SECONDARYSOCKET])); in Curl_xfer_send()
946 result = Curl_conn_send(data, sockindex, buf, blen, eos, pnwritten); in Curl_xfer_send()
952 data->info.request_size += *pnwritten; in Curl_xfer_send()
954 DEBUGF(infof(data, "Curl_xfer_send(len=%zu, eos=%d) -> %d, %zu", in Curl_xfer_send()
959 CURLcode Curl_xfer_recv(struct Curl_easy *data, in Curl_xfer_recv() argument
965 DEBUGASSERT(data); in Curl_xfer_recv()
966 DEBUGASSERT(data->conn); in Curl_xfer_recv()
967 DEBUGASSERT(data->set.buffer_size > 0); in Curl_xfer_recv()
969 sockindex = ((data->conn->sockfd != CURL_SOCKET_BAD) && in Curl_xfer_recv()
970 (data->conn->sockfd == data->conn->sock[SECONDARYSOCKET])); in Curl_xfer_recv()
971 if((size_t)data->set.buffer_size < blen) in Curl_xfer_recv()
972 blen = (size_t)data->set.buffer_size; in Curl_xfer_recv()
973 return Curl_conn_recv(data, sockindex, buf, blen, pnrcvd); in Curl_xfer_recv()
976 CURLcode Curl_xfer_send_close(struct Curl_easy *data) in Curl_xfer_send_close() argument
978 Curl_conn_ev_data_done_send(data); in Curl_xfer_send_close()
982 bool Curl_xfer_is_blocked(struct Curl_easy *data) in Curl_xfer_is_blocked() argument
984 bool want_send = ((data)->req.keepon & KEEP_SEND); in Curl_xfer_is_blocked()
985 bool want_recv = ((data)->req.keepon & KEEP_RECV); in Curl_xfer_is_blocked()
987 return (want_recv && Curl_cwriter_is_paused(data)); in Curl_xfer_is_blocked()
989 return (want_send && Curl_creader_is_paused(data)); in Curl_xfer_is_blocked()
991 return Curl_creader_is_paused(data) && Curl_cwriter_is_paused(data); in Curl_xfer_is_blocked()