summaryrefslogtreecommitdiff
path: root/libs/libcurl/src/sendf.c
diff options
context:
space:
mode:
Diffstat (limited to 'libs/libcurl/src/sendf.c')
-rw-r--r--libs/libcurl/src/sendf.c76
1 files changed, 43 insertions, 33 deletions
diff --git a/libs/libcurl/src/sendf.c b/libs/libcurl/src/sendf.c
index 723ef1458a..34fd0edce0 100644
--- a/libs/libcurl/src/sendf.c
+++ b/libs/libcurl/src/sendf.c
@@ -42,6 +42,7 @@
#include "connect.h"
#include "content_encoding.h"
#include "cw-out.h"
+#include "cw-pause.h"
#include "vtls/vtls.h"
#include "vssh/ssh.h"
#include "easyif.h"
@@ -51,7 +52,7 @@
#include "strdup.h"
#include "http2.h"
#include "progress.h"
-#include "warnless.h"
+#include "curlx/warnless.h"
#include "ws.h"
/* The last 3 #include files should be in this order */
@@ -316,9 +317,6 @@ static CURLcode cw_download_write(struct Curl_easy *data,
}
/* Update stats, write and report progress */
data->req.bytecount += nwrite;
-#ifdef USE_HYPER
- data->req.bodywritten = TRUE;
-#endif
result = Curl_pgrsSetDownloadCounter(data, data->req.bytecount);
if(result)
return result;
@@ -362,7 +360,7 @@ static CURLcode cw_raw_write(struct Curl_easy *data,
const char *buf, size_t nbytes)
{
if(type & CLIENTWRITE_BODY && data->set.verbose && !data->req.ignorebody) {
- Curl_debug(data, CURLINFO_DATA_IN, (char *)buf, nbytes);
+ Curl_debug(data, CURLINFO_DATA_IN, buf, nbytes);
}
return Curl_cwriter_write(data, writer->next, type, buf, nbytes);
}
@@ -436,21 +434,37 @@ static CURLcode do_init_writer_stack(struct Curl_easy *data)
if(result)
return result;
- result = Curl_cwriter_create(&writer, data, &cw_download, CURL_CW_PROTOCOL);
+ /* This places the "pause" writer behind the "download" writer that
+ * is added below. Meaning the "download" can do checks on content length
+ * and other things *before* write outs are buffered for paused transfers. */
+ result = Curl_cwriter_create(&writer, data, &Curl_cwt_pause,
+ CURL_CW_PROTOCOL);
+ if(!result) {
+ result = Curl_cwriter_add(data, writer);
+ if(result)
+ Curl_cwriter_free(data, writer);
+ }
if(result)
return result;
- result = Curl_cwriter_add(data, writer);
- if(result) {
- Curl_cwriter_free(data, writer);
+
+ result = Curl_cwriter_create(&writer, data, &cw_download, CURL_CW_PROTOCOL);
+ if(!result) {
+ result = Curl_cwriter_add(data, writer);
+ if(result)
+ Curl_cwriter_free(data, writer);
}
+ if(result)
+ return result;
result = Curl_cwriter_create(&writer, data, &cw_raw, CURL_CW_RAW);
+ if(!result) {
+ result = Curl_cwriter_add(data, writer);
+ if(result)
+ Curl_cwriter_free(data, writer);
+ }
if(result)
return result;
- result = Curl_cwriter_add(data, writer);
- if(result) {
- Curl_cwriter_free(data, writer);
- }
+
return result;
}
@@ -497,20 +511,14 @@ struct Curl_cwriter *Curl_cwriter_get_by_type(struct Curl_easy *data,
return NULL;
}
-void Curl_cwriter_remove_by_name(struct Curl_easy *data,
- const char *name)
+bool Curl_cwriter_is_content_decoding(struct Curl_easy *data)
{
- struct Curl_cwriter **anchor = &data->req.writer_stack;
-
- while(*anchor) {
- if(!strcmp(name, (*anchor)->cwt->name)) {
- struct Curl_cwriter *w = (*anchor);
- *anchor = w->next;
- Curl_cwriter_free(data, w);
- continue;
- }
- anchor = &((*anchor)->next);
+ struct Curl_cwriter *writer;
+ for(writer = data->req.writer_stack; writer; writer = writer->next) {
+ if(writer->phase == CURL_CW_CONTENT_DECODE)
+ return TRUE;
}
+ return FALSE;
}
bool Curl_cwriter_is_paused(struct Curl_easy *data)
@@ -1022,13 +1030,6 @@ static CURLcode cr_lc_read(struct Curl_easy *data,
if(result)
return result;
start = i + 1;
- if(!data->set.crlf && (data->state.infilesize != -1)) {
- /* we are here only because FTP is in ASCII mode...
- bump infilesize for the LF we just added */
- data->state.infilesize++;
- /* comment: this might work for FTP, but in HTTP we could not change
- * the content length after having started the request... */
- }
}
if(start < i) { /* leftover */
@@ -1305,6 +1306,15 @@ static bool cr_buf_needs_rewind(struct Curl_easy *data,
return ctx->index > 0;
}
+static CURLcode cr_buf_rewind(struct Curl_easy *data,
+ struct Curl_creader *reader)
+{
+ struct cr_buf_ctx *ctx = reader->ctx;
+ (void)data;
+ ctx->index = 0;
+ return CURLE_OK;
+}
+
static curl_off_t cr_buf_total_length(struct Curl_easy *data,
struct Curl_creader *reader)
{
@@ -1344,7 +1354,7 @@ static const struct Curl_crtype cr_buf = {
cr_buf_needs_rewind,
cr_buf_total_length,
cr_buf_resume_from,
- Curl_creader_def_rewind,
+ cr_buf_rewind,
Curl_creader_def_unpause,
Curl_creader_def_is_paused,
Curl_creader_def_done,