|
From: David H. <dav...@gm...> - 2011-01-10 21:41:00
|
Hey Dean,
Thanks for the quick reply.
I can't find the example you are talking about... i'm using 0.8 version.
I'm also getting some compile errors when I try to push the content-type
header on the response.headers
Here's my code:
Server::response_header content_type = {"Content-Type",
"application/vnd.google-earth.kml+xml"};
// set message in response
response = Server::response::stock_reply(Server::response::ok,
kml_string);
// set MIME type for response
response.headers.push_back( content_type );
And here's my error:
error: no matching function for call to
'std::vector<boost::network::http::request_header<boost::network::http::tags::http_server>,
std::allocator<boost::network::http::request_header<boost::network::http::tags::http_server>
>
>::push_back(boost::network::http::response_header<boost::network::http::tags::http_server>&)'
/usr/include/c++/4.4/bits/stl_vector.h:733: note: candidates are: void
std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp =
boost::network::http::request_header<boost::network::http::tags::http_server>,
_Alloc =
std::allocator<boost::network::http::request_header<boost::network::http::tags::http_server>
>]
These error messages are impossible to decipher... any ideas?
The only candidate function it's listing is using
boost::network::http::request_header. I tried that too and no dice.
-Dave-
On Sun, Jan 9, 2011 at 9:41 PM, Dean Michael Berris
<mik...@gm...>wrote:
> Hi David,
>
> On Mon, Jan 10, 2011 at 5:32 AM, David Hite <dav...@gm...> wrote:
> > Howdy all,
> > I've just started working with cpp-netlib and I am trying to get an HTTP
> > server (not asynchronous) working with different mime Content-Types.
> > I see that the FileServer example sets the mime-type for different
> responses
> > in the asynchronous server connection_ptr but I can't get anything like
> it
> > to work for a simple synchronous server response.
> > Can anyone give an example of how to set the Content-Type header for a
> > simple synchronous server response?
>
> Certainly. If you look in
> libs/network/test/http/server_hello_world.cpp there is an example of
> setting the headers for the response of a synchronous HTTP server.
> What you'll need to remember is that the response object passed by
> lvalue reference to the handler has a member named `headers` where you
> would put all the headers you want.
>
> In your handler's operator() overload, you would have something like this:
>
> server::response::header_type content_type = {"Content-Type",
> "application/octet-stream"};
> response.headers.push_back(content_type);
>
> This is at least true for the version in the 0.9-devel branch. If
> you're on 0.8, you would need code that looks like this:
>
> server::response_header content_type = {"Content-Type",
> "application/octet-stream"};
> response.headers.push_back(content_type);
>
>
> > Thanks,
> > -Dave-
>
> I hope this helps!
>
> --
> Dean Michael Berris
> about.me/deanberris
>
>
> ------------------------------------------------------------------------------
> Gaining the trust of online customers is vital for the success of any
> company
> that requires sensitive data to be transmitted over the Web. Learn how to
> best implement a security strategy that keeps consumers' information secure
> and instills the confidence they need to proceed with transactions.
> http://p.sf.net/sfu/oracle-sfdevnl
> _______________________________________________
> Cpp-netlib-devel mailing list
> Cpp...@li...
> https://lists.sourceforge.net/lists/listinfo/cpp-netlib-devel
>
|