curl-library
Mulit Interface is not working with proxy
Date: Wed, 2 Apr 2008 16:54:23 +0530
Hi,
The below code is working fine without proxy. If I enable proxy code by
Uncoomenting the proxy setopts code
The code is failing to connect to proxy. I am using curl 7.18.0 version.
I am not able to figure out what could be the problem. Someone can help me
in resloving this issue that will be of great help.
Thanks in advance,
REgards,
PCREddy.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <curl/curl.h>
#include <io.h>
void* buffer;
size_t length;
CURLM *handler;
static size_t read_callback(void *ptr, size_t size, size_t nmemb, void
*userp)
{
memcpy(ptr,buffer,length);
return length;
}
size_t sicfwrite(void* data,size_t len)
{
buffer = data;
length = len;
int handles;
while(CURLM_CALL_MULTI_PERFORM ==
curl_multi_perform(handler, &handles));
return len;
}
int main(void)
{
CURL *curl;
CURLcode res;
handler = curl_multi_init();
curl = curl_easy_init();
if(curl) {
/* First set the URL that is about to receive our POST. */
curl_easy_setopt(curl, CURLOPT_URL,
"http://128.222.85.20:8080/examples/MyNio");
/* Now specify we want to POST data */
curl_easy_setopt(curl, CURLOPT_POST, 1);
/* we want to use our own read function */
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
/* get verbose debug output please */
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
/*
UNCOMMENT THIS CODE
curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, TRUE);
curl_easy_setopt(curl, CURLOPT_PROXY, "128.222.85.56");
curl_easy_setopt(curl, CURLOPT_PROXYPORT, 8080);
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, "rastoa:temp1234!");
curl_easy_setopt(curl, CURLOPT_PROXYAUTH,
CURLAUTH_NTLM | CURLAUTH_DIGEST | CURLAUTH_BASIC );
*/
curl_multi_add_handle(handler, curl);
/*
If you use POST to a HTTP 1.1 server, you can send data without
knowing
the size before starting the POST if you use chunked encoding. You
enable this by adding a header like "Transfer-Encoding: chunked" with
CURLOPT_HTTPHEADER. With HTTP 1.0 or without chunked transfer, you
must
specify the size in the request.
*/
{
curl_slist *chunk = NULL;
chunk = curl_slist_append(chunk, "Transfer-Encoding: chunked");
res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk);
/* use curl_slist_free_all() after the *perform() call to free this
list again */
}
sicfwrite((void*)"CHENNA REDDY",10);
sicfwrite((void *)"BANGALORE",9);
sicfwrite((void*) "AMIT RASOGI",6);
int i;
scanf("%d", &i);
sicfwrite((void*) "after getch",10);
sicfwrite((void *) "last record",0);
sicfwrite((void *) "last record",10);
/* always cleanup */
while(CURLM_CALL_MULTI_PERFORM ==
curl_multi_perform(handler, &handles))
printf("executing\n");
curl_multi_cleanup(handler);
curl_easy_cleanup(curl);
}
system("PAUSE");
return 0;
}
<curl-library_at_cool.haxx.se>
Received on 2008-04-02