aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorJay Satiro <raysatiro@yahoo.com>2016-09-14 01:55:13 -0400
committerJay Satiro <raysatiro@yahoo.com>2016-09-18 02:19:17 -0400
commit45c1c54c423cb8b2004e11f67131955f36d1cad8 (patch)
tree38dafc0bf467510f24b717da74119505667a4963 /docs
parente01d0f1030b984e0530f4bcd37896ce73cb663ff (diff)
examples/imap-append: Set size of data to be uploaded
Prior to this commit this example failed with error 'Cannot APPEND with unknown input file size'. Bug: https://github.com/curl/curl/issues/1008 Reported-by: lukaszgn@users.noreply.github.com Closes https://github.com/curl/curl/pull/1011
Diffstat (limited to 'docs')
-rw-r--r--docs/examples/imap-append.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/docs/examples/imap-append.c b/docs/examples/imap-append.c
index 3f832897d..bbf9fe436 100644
--- a/docs/examples/imap-append.c
+++ b/docs/examples/imap-append.c
@@ -85,6 +85,8 @@ int main(void)
{
CURL *curl;
CURLcode res = CURLE_OK;
+ const char **p;
+ long infilesize;
struct upload_status upload_ctx;
upload_ctx.lines_read = 0;
@@ -107,6 +109,12 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_READDATA, &upload_ctx);
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
+ infilesize = 0;
+ for(p = payload_text; *p; ++p) {
+ infilesize += (long)strlen(*p);
+ }
+ curl_easy_setopt(curl, CURLOPT_INFILESIZE, infilesize);
+
/* Perform the append */
res = curl_easy_perform(curl);