Boost logo

Boost Users :

Subject: Re: [Boost-users] What is the way to access the data contained in a stream buffer?
From: Anders Dalvander (boost_at_[hidden])
Date: 2009-09-13 04:01:31


Ramon F Herrera wrote:
> I have a follow-up question of a more general nature. I think the Boost
> libraries are the greatest thing since sliced bread, but there are times
> when a simpler approach will suffice. We can see in these 2 lines of
> code that we are mixing STL with Boost:
>
> boost::asio::streambuf request;
> std::ostream request_stream(&request);
>
> Is there any STL class that can be used above, instead of
> boost::asio::streambuf?
>
Something like std::ostringstream?

std::ostringstream request_stream;
request_stream << "GET " << argv[2] << " HTTP/1.0\r\n";
request_stream << "Host: " << argv[1] << "\r\n";
request_stream << "Accept: */*\r\n";
request_stream << "Connection: close\r\n\r\n";
std::string request = request_stream.str();

Regards,
Anders Dalvander


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net