mirror of
https://github.com/moparisthebest/curl
synced 2025-02-28 09:21:50 -05:00
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
This commit is contained in:
parent
e01d0f1030
commit
45c1c54c42
@ -85,6 +85,8 @@ int main(void)
|
|||||||
{
|
{
|
||||||
CURL *curl;
|
CURL *curl;
|
||||||
CURLcode res = CURLE_OK;
|
CURLcode res = CURLE_OK;
|
||||||
|
const char **p;
|
||||||
|
long infilesize;
|
||||||
struct upload_status upload_ctx;
|
struct upload_status upload_ctx;
|
||||||
|
|
||||||
upload_ctx.lines_read = 0;
|
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_READDATA, &upload_ctx);
|
||||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
|
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 */
|
/* Perform the append */
|
||||||
res = curl_easy_perform(curl);
|
res = curl_easy_perform(curl);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user