aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2013-12-26 23:50:34 +0100
committerDaniel Stenberg <daniel@haxx.se>2013-12-26 23:50:34 +0100
commit2a4ee0d221555686b4a8eae87e54a19e128f7271 (patch)
treec9cdcd266a6c999397445d58df149bf8f3db87fc /lib
parentf88f9bed008b15d488810cd5e6bea2e5efcaff6b (diff)
FILE: we don't support paused transfers using this protocol
Make sure that we detect such attempts and return a proper error code instead of silently handling this in problematic ways. Updated the documentation to mention this limitation. Bug: http://curl.haxx.se/bug/view.cgi?id=1286
Diffstat (limited to 'lib')
-rw-r--r--lib/sendf.c12
-rw-r--r--lib/transfer.c24
2 files changed, 27 insertions, 9 deletions
diff --git a/lib/sendf.c b/lib/sendf.c
index c274203bf..8ffd43f47 100644
--- a/lib/sendf.c
+++ b/lib/sendf.c
@@ -444,10 +444,18 @@ CURLcode Curl_client_write(struct connectdata *conn,
wrote = len;
}
- if(CURL_WRITEFUNC_PAUSE == wrote)
+ if(conn->handler->flags & PROTOPT_NONETWORK) {
+ /* protocols that work without network cannot be paused. This is
+ actually only FILE:// just now, and it can't pause since the transfer
+ isn't done using the "normal" procedure. */
+ failf(data, "Write callback asked for PAUSE when not supported!");
+ return CURLE_WRITE_ERROR;
+ }
+
+ else if(CURL_WRITEFUNC_PAUSE == wrote)
return pausewrite(data, type, ptr, len);
- if(wrote != len) {
+ else if(wrote != len) {
failf(data, "Failed writing body (%zu != %zu)", wrote, len);
return CURLE_WRITE_ERROR;
}
diff --git a/lib/transfer.c b/lib/transfer.c
index 2ce6597c3..4dbc4e1b7 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -128,14 +128,24 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp)
return CURLE_ABORTED_BY_CALLBACK;
}
else if(nread == CURL_READFUNC_PAUSE) {
- struct SingleRequest *k = &data->req;
- /* CURL_READFUNC_PAUSE pauses read callbacks that feed socket writes */
- k->keepon |= KEEP_SEND_PAUSE; /* mark socket send as paused */
- if(data->req.upload_chunky) {
- /* Back out the preallocation done above */
- data->req.upload_fromhere -= (8 + 2);
+
+ if(conn->handler->flags & PROTOPT_NONETWORK) {
+ /* protocols that work without network cannot be paused. This is
+ actually only FILE:// just now, and it can't pause since the transfer
+ isn't done using the "normal" procedure. */
+ failf(data, "Read callback asked for PAUSE when not supported!");
+ return CURLE_READ_ERROR;
+ }
+ else {
+ struct SingleRequest *k = &data->req;
+ /* CURL_READFUNC_PAUSE pauses read callbacks that feed socket writes */
+ k->keepon |= KEEP_SEND_PAUSE; /* mark socket send as paused */
+ if(data->req.upload_chunky) {
+ /* Back out the preallocation done above */
+ data->req.upload_fromhere -= (8 + 2);
+ }
+ *nreadp = 0;
}
- *nreadp = 0;
return CURLE_OK; /* nothing was read */
}
else if((size_t)nread > buffersize) {