|
From: David H. <dav...@gm...> - 2011-01-28 23:08:37
|
On Fri, Jan 28, 2011 at 3:22 PM, David Hite <dav...@gm...> wrote:
>
> On Thu, Jan 27, 2011 at 9:45 PM, Dean Michael Berris <
> mik...@gm...> wrote:
>
>> On Fri, Jan 28, 2011 at 9:35 AM, David Hite <dav...@gm...> wrote:
>> > My question is that I have been using stock_reply for the response and
>> am
>> > wondering if there are other methods for sending messages.
>> >
>> > The line I have been using is:
>> > "response = Server::response::stock_reply(ok, msg);"
>> > In all the examples I see and also looking through the code all I can
>> find
>> > is the "stock_reply" method.
>>
>> If you look at the code in the libs/network/test/hello_world.cpp -- or
>> there abouts I don't have the directory handy at the moment -- you
>> should see something like this:
>>
>> response << header("Content-Type", "application/octet-stream")
>> << header("Connection", "close");
>>
>> What that actually means is you're pushing in HTTP headers into the
>> response. It's the same if you intend to push in the body of the
>> response as well:
>>
>> response << body("The quick brown fox jumps over the lazy dog.");
>>
>> You can find information about this in the documentation for the HTTP
>> Response in the library:
>> http://cpp-netlib.github.com/reference_http_response.html
>>
>> HTH
>>
>>
>> --
>> Dean Michael Berris
>> about.me/deanberris
>>
>>
>> ------------------------------------------------------------------------------
>> Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
>> Finally, a world-class log management solution at an even better
>> price-free!
>> Download using promo code Free_Logger_4_Dev2Dev. Offer expires
>> February 28th, so secure your free ArcSight Logger TODAY!
>> http://p.sf.net/sfu/arcsight-sfd2d
>> _______________________________________________
>> Cpp-netlib-devel mailing list
>> Cpp...@li...
>> https://lists.sourceforge.net/lists/listinfo/cpp-netlib-devel
>>
>
> Hi Dean, Thanks for the quick response.
>
> Sorry for the trouble but I'm getting a compile error.
>
> Error: 'body' is not a member of
> 'boost::network::http::basic_response<boost::network::http::tags::http_server>'
>
> Here's the code:
>
> response << Server::response::body(buffer);
>
> using Server defined as
>
> typedef http::server<CgiResourceManager> Server;
>
> I'm using cpp-netlib v0.8
>
> Any ideas?
> Thanks,
> -Dave-
>
Hello,
Ok, so I figured out how to directly set the response message. For example:
response.content = "Hello world!"
response.status = Server::response::ok;
http::request_header<http::tags::http_server> content_type =
{"Content-Type", "text/html"};
response.headers.push_back( content_type );
However, now I have the problem that response.content is a string. How do I
send binary data, such as an image file?
Thanks!
-Dave-
|