snikulov's picture

Hi,

Is it possible to implement http client using pion-network library?
Could you please provide short recipe for that usage?

Thank you.

Mike Dickey's picture
See WebServerTests.cpp

Most of our unit tests use the client API to test our server-side code. The best code we have right now is probably in WebServerTests.cpp (in the net/tests source directory).

There are two methods available for clients: synchronous and asynchronous. For synchronous, you just need to construct an HTTPRequest object, set the appropriate fields, and call HTTPRequest::send(). You can then create an empty HTTPResponse object and call receive() to get the response from the server. For asynchronous, you can use an HTTPRequestWriter class & specify a callback to use after the request has been delivered. Normally, the callback would be a function that uses an HTTPResponseReader to asynchronously parse the response.

I know.. Ideally we would have a tutorial for this, but unfortunately it just hasn't been a high-enough priority yet.. ;-)

Submitted by Mike Dickey on Fri, 11/21/2008 - 10:27.