curl_easy_perform hangs when trying to read response headers
Date: Mon, 10 Nov 2008 16:13:38 +0530
I am trying to get the HTTP response from a simple servlet, but the program
hangs at curl_easy_perform, and does not come out of it even if the servlet
I have a running test Java servlet (deployed on Tomcat), which returns a
response code of 200.
protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
I am attempting to write a C program using libcurl, which will just get the
response header. I have implemented the callback using
CURLOPT_HEADERFUNCTION. Code snippet below. Obviously, there is some mistake
out here. I tried with some other HTTP clients (wfetch), and there the
program completes, and it gets the response code 200.
struct MemoryStruct resHeaders;
size_t WriteHeaderCallback(void *ptr, size_t size, size_t nmemb, void *data)
// Getting the response headers here.
curl_easy_setopt(hCurl, CURLOPT_HEADERFUNCTION, WriteHeaderCallback);
curl_easy_setopt(hCurl, CURLOPT_WRITEHEADER, (void *)&resHeaders);
/* The program hangs at this perform function. The servlet starts and
completes but this does not go ahead.
Other HTTP client completes, so there seems to be no issue with the
if (curl_easy_perform(hCurl) == CURLE_OK)
printf("\tError from cURL: %s\n", curl_easy_strerror(res));
Any guidance would be nice. Where did I make a mistake?
-bash-3.00$ curl --version
curl 7.19.0 (sparc-sun-solaris2.10) libcurl/7.19.0 OpenSSL/0.9.8h zlib/1.2.3
Protocols: dict http file https
Features: Debug IPv6 Largefile NTLM SSL libz
Thanks in advance.
// Pls ignore the disclaimer.
This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails.
Received on 2008-11-10