cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: How to use libcurl to do HTTP GET request and get response in Apache module...

From: <ohaya_at_cox.net>
Date: Sat, 23 Jun 2012 17:34:07 -0400

---- Daniel Stenberg <daniel_at_haxx.se> wrote:
> On Sat, 23 Jun 2012, ohaya_at_cox.net wrote:
>
> > I'm trying to use libcurl in an Apache module that I'm working on, to make
> > an HTTP GET request, and to get and process the response.
>
> In what way would it be different to use libcurl from an Apache module than
> from other code? libcurl's API and functionality remain the same no matter
> what...
>
> --
>
> / daniel.haxx.se
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette: http://curl.haxx.se/mail/etiquette.html

Hi Daniel,

Thanks for that.

I'm new to both writing Apache modules and to using libcurl, and when I was testing my prototype, I was getting that segfault, and had *assumed* that the segfault was occurring because there might be problems with memory allocation, as Apache has a pool mechanism which I had run into problems with earlier (before trying to integrate libcurl into my module).

But when you said what you said ( :) ), I went back and ran Apache under GDB, and noted that the callback was returning a CURLE_WRITE_ERROR. I googled that, and also realized that the sample (the link I pointed to earlier) I had started with wasn't returning a byte/char count from the callback (causing the curl error - http://curl.haxx.se/mail/lib-2007-01/0280.html)

So, I just added an appropriate return to the callback, and now it works :)!!

Thanks,
Jim
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-06-23