From: Glyn M. <gly...@gm...> - 2008-08-27 12:44:32
|
Hello, I have some questions about the way HTTP requests are made using the current interface, specifically this (taken from the http_1_0_test.cpp): using namespace boost::network; http::request request("http://www.boost.org/"); http::client client_; http::response response_; response_ = client_.get(request); What exactly is the role of the client here? I'm a little confused by the syntax because it reads as though you're trying to make a get request to an HTTP client. Would it perhaps be better to rename http::client to http::connection? Secondly, why is the domain passed as an argument to the http::request constructor? To me, this doesn't feel like the right unit of encapsulation. Does the following example code make more sense? using namespace boost::network; http::connection c("http://www.boost.org"); http::request request1("/users/news/version_1_36_0"); http::response response1 = c.get(request); http::request request2("/cgi-bin/path"); request2 << body("post_body"); http::response response2 = c.post(request2); Two observations about this: The current implementation creates a new socket for each request that is made, whereas the above suggestion allows a socket to remain open for multiple requests. Additionally, the URI processing is currently done inside the request constructor. I think it would be better to re-factor this into a separate package. Any thoughts? Glyn |