curl-library
READFUNCTION + WRITEFUNCTION on GET
Date: Thu, 22 Jun 2017 12:35:55 -0700
It doesn't seem possible to have libcurl callback a READFUNCTION on a GET
request. I have the following code:
https://gist.github.com/mfine/f98c32e8bbe11f57896388548683433a
#include <stdio.h>
#include <curl/curl.h>
size_t download_write(char *buf, size_t size, size_t n, void *data)
{
return fwrite(buf, size, n, stdout);
}
size_t upload_read(char *buf, size_t size, size_t n, void *data)
{
printf("XXXXXX READING!!!\n");
return 0;
}
int main(void)
{
CURLcode code = curl_global_init(CURL_GLOBAL_ALL);
if (code != CURLE_OK) {
return -1;
}
CURL *curl = curl_easy_init();
if (curl == NULL) {
return -1;
}
struct curl_slist *chunk = NULL;
chunk = curl_slist_append(chunk, "Transfer-Encoding: chunked");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk);
curl_easy_setopt(curl, CURLOPT_USERAGENT, "my-client/1.0");
curl_easy_setopt(curl, CURLOPT_URL, "myurl");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, download_write);
curl_easy_setopt(curl, CURLOPT_READFUNCTION, upload_read);
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 0L);
code = curl_easy_perform(curl);
if (code != CURLE_OK) {
return -1;
}
return 0;
}
The WRITEFUNCTION callback happens, but I never see the READFUNCTION
callback happen. I need to write out a body in the GET request - I thought
if the file descriptor had its read bit set my callback would get called.
Is that ignored on GET requests? I think I've been able to do this with the
utility and @file. Thanks!
Mark
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2017-06-22