Lines Matching defs:data

62 static CURLcode do_init_stack(struct Curl_easy *data);
68 * blocks of data. Remaining, bare CRs are changed to LFs. The possibly new
69 * size of the data is returned.
71 static size_t convert_lineends(struct Curl_easy *data,
81 if(data->state.prev_block_had_trailing_cr) {
82 /* The previous block of incoming data
85 /* This block of incoming data starts with the
90 data->state.crlf_conversions++;
92 data->state.prev_block_had_trailing_cr = FALSE; /* reset the flag */
106 data->state.crlf_conversions++;
128 data->state.prev_block_had_trailing_cr = TRUE;
137 /* tidy up by null terminating the now shorter data */
147 * Curl_nwrite() is an internal write function that sends data to the
153 CURLcode Curl_nwrite(struct Curl_easy *data,
165 DEBUGASSERT(data);
166 DEBUGASSERT(data->conn);
167 conn = data->conn;
180 nwritten = conn->send[sockindex](data, sockindex, buf, blen, &result);
197 * Curl_write() is an internal write function that sends data to the
203 CURLcode Curl_write(struct Curl_easy *data,
212 DEBUGASSERT(data);
213 DEBUGASSERT(data->conn);
214 conn = data->conn;
216 return Curl_nwrite(data, num, mem, len, written);
219 static CURLcode pausewrite(struct Curl_easy *data,
220 int type, /* what type of data */
225 /* signalled to pause sending on this connection, but since we have data
228 struct SingleRequest *k = &data->req;
229 struct UrlState *s = &data->state;
233 Curl_conn_ev_data_pause(data, TRUE);
239 /* data for this type exists */
270 /* chop_write() writes chunks of data not larger than CURL_MAX_WRITE_SIZE via
274 static CURLcode chop_write(struct Curl_easy *data,
280 struct connectdata *conn = data->conn;
285 void *writebody_ptr = data->set.out;
290 /* If reading is paused, append this data to the already held data for this
292 if(data->req.keepon & KEEP_RECV_PAUSE)
293 return pausewrite(data, type, !skip_body_write, ptr, len);
298 ((type & CLIENTWRITE_HEADER) && data->set.include_header))) {
299 writebody = data->set.fwrite_func;
302 (data->set.fwrite_header || data->set.writeheader)) {
308 data->set.fwrite_header? data->set.fwrite_header: data->set.fwrite_func;
311 /* Chop data, write chunks. */
317 Curl_set_in_callback(data, true);
319 Curl_set_in_callback(data, false);
326 failf(data, "Write callback asked for PAUSE when not supported");
329 return pausewrite(data, type, TRUE, ptr, len);
332 failf(data, "Failure writing output to destination");
350 CURLcode result = Curl_headers_push(data, optr, htype);
359 Curl_set_in_callback(data, true);
360 wrote = writeheader(optr, 1, olen, data->set.writeheader);
361 Curl_set_in_callback(data, false);
364 return pausewrite(data, type, FALSE, optr, olen);
366 failf(data, "Failed writing header");
375 /* Curl_client_write() sends data to the write callback(s)
380 If CURL_DO_LINEEND_CONV is enabled, data is converted IN PLACE to the
382 the future to leave the original data alone.
384 CURLcode Curl_client_write(struct Curl_easy *data,
390 /* FTP data may need conversion. */
392 (data->conn->handler->protocol & PROTO_FAMILY_FTP) &&
393 data->conn->proto.ftpc.transfertype == 'A') {
395 blen = convert_lineends(data, buf, blen);
407 if(!data->req.writer_stack) {
408 result = do_init_stack(data);
411 DEBUGASSERT(data->req.writer_stack);
414 return Curl_cwriter_write(data, data->req.writer_stack, type, buf, blen);
417 CURLcode Curl_client_unpause(struct Curl_easy *data)
421 if(data->state.tempcount) {
425 unsigned int count = data->state.tempcount;
429 for(i = 0; i < data->state.tempcount; i++) {
430 writebuf[i] = data->state.tempwrite[i];
431 Curl_dyn_init(&data->state.tempwrite[i].b, DYN_PAUSE_BUFFER);
433 data->state.tempcount = 0;
439 result = chop_write(data, writebuf[i].type,
449 void Curl_client_cleanup(struct Curl_easy *data)
451 struct Curl_cwriter *writer = data->req.writer_stack;
455 data->req.writer_stack = writer->next;
456 writer->cwt->do_close(data, writer);
458 writer = data->req.writer_stack;
461 for(i = 0; i < data->state.tempcount; i++) {
462 Curl_dyn_free(&data->state.tempwrite[i].b);
464 data->state.tempcount = 0;
465 data->req.bytecount = 0;
466 data->req.headerline = 0;
469 /* Write data using an unencoding writer stack. "nbytes" is not
471 CURLcode Curl_cwriter_write(struct Curl_easy *data,
477 return writer->cwt->do_write(data, writer, type, buf, nbytes);
480 CURLcode Curl_cwriter_def_init(struct Curl_easy *data,
483 (void)data;
488 CURLcode Curl_cwriter_def_write(struct Curl_easy *data,
492 return Curl_cwriter_write(data, writer->next, type, buf, nbytes);
495 void Curl_cwriter_def_close(struct Curl_easy *data,
498 (void) data;
503 static CURLcode cw_client_write(struct Curl_easy *data,
510 return chop_write(data, type, FALSE, (char *)buf, nbytes);
522 static size_t get_max_body_write_len(struct Curl_easy *data, curl_off_t limit)
527 remain_diff = limit - data->req.bytecount;
545 * sees the "real" download body data. */
546 static CURLcode cw_download_write(struct Curl_easy *data,
554 if((type & CLIENTWRITE_CONNECT) && data->set.suppress_connect_headers)
556 return Curl_cwriter_write(data, writer->next, type, buf, nbytes);
559 if(!data->req.bytecount) {
560 Curl_pgrsTime(data, TIMER_STARTTRANSFER);
561 if(data->req.exp100 > EXP100_SEND_DATA)
563 data->req.start100 = Curl_now();
572 if(data->req.no_body && nbytes > 0) {
574 streamclose(data->conn, "ignoring body");
575 DEBUGF(infof(data, "did not want a BODY, but seeing %zu bytes",
577 data->req.download_done = TRUE;
586 if(-1 != data->req.maxdownload) {
587 size_t wmax = get_max_body_write_len(data, data->req.maxdownload);
594 data->req.download_done = TRUE;
600 if(data->set.max_filesize) {
601 size_t wmax = get_max_body_write_len(data, data->set.max_filesize);
608 data->req.bytecount += nwrite;
609 ++data->req.bodywrites;
610 if(!data->req.ignorebody && nwrite) {
611 result = Curl_cwriter_write(data, writer->next, type, buf, nwrite);
615 result = Curl_pgrsSetDownloadCounter(data, data->req.bytecount);
620 if(!data->req.ignorebody) {
621 infof(data,
627 excess_len, data->req.size, data->req.maxdownload,
628 data->req.bytecount);
629 connclose(data->conn, "excess found in a read");
633 failf(data, "Exceeded the maximum allowed file size "
636 data->set.max_filesize, data->req.bytecount);
653 * enabled tracing of raw data. */
654 static CURLcode cw_raw_write(struct Curl_easy *data,
658 if(type & CLIENTWRITE_BODY && data->set.verbose && !data->req.ignorebody) {
659 Curl_debug(data, CURLINFO_DATA_IN, (char *)buf, nbytes);
661 return Curl_cwriter_write(data, writer->next, type, buf, nbytes);
675 struct Curl_easy *data,
689 result = cwt->do_init(data, writer);
698 void Curl_cwriter_free(struct Curl_easy *data,
702 writer->cwt->do_close(data, writer);
707 size_t Curl_cwriter_count(struct Curl_easy *data, Curl_cwriter_phase phase)
712 for(w = data->req.writer_stack; w; w = w->next) {
719 static CURLcode do_init_stack(struct Curl_easy *data)
724 DEBUGASSERT(!data->req.writer_stack);
725 result = Curl_cwriter_create(&data->req.writer_stack,
726 data, &cw_client, CURL_CW_CLIENT);
730 result = Curl_cwriter_create(&writer, data, &cw_download, CURL_CW_PROTOCOL);
733 result = Curl_cwriter_add(data, writer);
735 Curl_cwriter_free(data, writer);
738 result = Curl_cwriter_create(&writer, data, &cw_raw, CURL_CW_RAW);
741 result = Curl_cwriter_add(data, writer);
743 Curl_cwriter_free(data, writer);
748 CURLcode Curl_cwriter_add(struct Curl_easy *data,
752 struct Curl_cwriter **anchor = &data->req.writer_stack;
755 result = do_init_stack(data);
769 void Curl_cwriter_remove_by_name(struct Curl_easy *data,
772 struct Curl_cwriter **anchor = &data->req.writer_stack;
778 Curl_cwriter_free(data, w);
791 CURLcode Curl_read(struct Curl_easy *data, /* transfer */
793 char *buf, /* store read data here */
801 struct connectdata *conn = data->conn;
810 bytesfromsocket = CURLMIN(sizerequested, (size_t)data->set.buffer_size);
813 nread = conn->recv[num](data, num, buffertofill, bytesfromsocket, &result);