Reading the http response body

Joe Orton joe at
Mon Mar 8 07:47:02 EST 2010

On Thu, Mar 04, 2010 at 10:15:26PM -0800, Trfdtrsd Dfhdgfh wrote:
> How do I read a http response body after dispatching a http request?
> ne_request *req = ne_request_create(sess, "GET", "/test.cgi?debug=1");
> if(ne_request_dispatch(req)==0)
> {
>    /*read http body and put it on stdout*/

The "ne_request_dispatch" operation includes sending the response and 
reading the response.

You can use ne_add_response_body_reader() to add a callback which 
receives blocks of the response body, or use 
ne_begin_request/ne_read_response_block/ne_end_request directly.

THe header gives an example of how to do tihs:

 *  1. ne_begin_request (fail if returns non-NE_OK)
 *  2. while(ne_read_response_block(...) > 0) ... loop ...;
 *     (fail if ne_read_response_block returns <0)
 *  3. ne_end_request

Regards, Joe

More information about the neon mailing list