Error in downloading Image using boost library.
Copy link to clipboard
Copied
Hi All,
We are trying to download the image file from the server using Indesign boost libraries(Indesign CC2014 sdk). But it throws "read_until: End of file" exception. Please help me If anybody has tried it. My Code snippet is as below -
{
boost::asio::io_service io_service;
// Get a list of endpoints corresponding to the server name.
tcp::resolver resolver(io_service);
tcp::resolver::query query(serverName, sPortNo);
tcp::resolver::iterator endpoint_iterator = resolver.resolve(query);
tcp::resolver::iterator end;
// Try each endpoint until we successfully establish a connection.
tcp::socket socket(io_service);
boost::system::error_code error = boost::asio::error::host_not_found;
while (error && endpoint_iterator != end)
{
socket.close();
socket.connect(*endpoint_iterator++, error);
}
boost::asio::streambuf request;
std::ostream request_stream(&request);
request_stream << "GET " << assetUrl << " HTTP/1.1\r\n";
request_stream << "Host: " << serverName << ":" << sPortNo << "\r\n";
request_stream << "Connection: close\r\n";
request_stream << "Accept: */*\r\n";
request_stream << "Cookie: JSESSIONID=" << sTokenkey << "\r\n\r\n";
// Send the request.
int bytesSent = (int)boost::asio::write(socket, request);
// Read the response status line.
boost::asio::streambuf response;
boost::asio::read_until(socket, response, "\r\n"); // throws an exception at this point.
}
Thanks all in advance.
Regards,
Siddhesh
Copy link to clipboard
Copied

