Re: I don't get body when doing a POST-Request and HTTP-Status=400

>>>>> "Kroemer, Jochen" <Jochen.Kroemer@t-systems.de>:

> I have to contact a HTTP-Server with a POST-request. In the body I
> send a list of name/value pairs. When the server accepts my request
> it sends an URL in the body of its response. With this URL I can
> fetch further infos. This works perfectly.
> When the server doesn't accept my request (for example because of
> syntactical errors in the name/value-pairs) it sends a HTTP-Error
> 400 (Bad Request). In the body of its response it sends a detailed
> error description. The server works as described, I checked it with
> an internetbrowser. But my program based on libwww doesn't work as
> expected. In the terminate_handler-event I recieve a status of
> -400. The result_chunk is not equal to NULL but
> HTChunk_data(result_chunk) is NULL. So I'm not able to fetch the
> error description. (Same result, when using example-program
> postform.c)

What I do, is to create a stream where I want an eventual debug
message to show up, and then add it to all outgoing requests with the
following statements:
	    HTRequest_setDebugStream(request, debug);
	    HTRequest_setDebugFormat(request, WWW_SOURCE);
(where "debug" is the HTStream* where you want the error message to
end up)

> When trying to produce a Bad Request when sending a GET-Request the
> situation is as follows:
> In the terminate_handler-event I get a status of -1.
> result_chunk is not equal to NULL
> HTChunk_data(result_chunk) points to a String with the complete
> response (header and body).

> Any hints how I can get the header and body with a POST-request too?

Maybe you can adjust the default output format of the POST request?
Maybe calling
	HTRequest_setOutputFormat(request, WWW_RAW);
on requests before sending them will do the trick?

Received on Thursday, 19 July 2001 07:53:37 UTC