Thread: [pion-users] pion net http client not reading long binary response
client and server HTTP(S) library for Boost C++ developers
Brought to you by:
mikedickey
From: Neel B. <nee...@gm...> - 2015-10-09 06:31:51
|
I am trying to read a application/octet-stream of content size > 200MB with pion net synchronously. But What I get is only 1.0MB downloaded. std::string image_stream_name = (boost::format("/var/lib/hc/images/%1%.%2%.hc") % image_id % instance_id).str(); pion::net::TCPConnectionPtr client_connection(new pion::net::TCPConnection(_service)); client_connection->setLifecycle(pion::net::TCPConnection::LIFECYCLE_KEEPALIVE); pion::net::HTTPRequest client_request; client_request.setMethod("GET"); client_request.setResource((boost::format("/v2/images/%1%/file") % image_id).str()); boost::system::error_code ec; ec = client_connection->connect("localhost", _config.glance().endpoint.port); if(!ec){ client_request.send(*(client_connection.get()), ec); if(!ec){ pion::net::HTTPResponse client_response(client_request); client_response.receive(*client_connection.get(), ec); if(!ec){ std::ofstream image_stream; image_stream.open(image_stream_name.c_str()); std::cout << "downloading image into " << image_stream_name << std::endl; std::cout << "image size: " << client_response.getContentLength() << " chunked: " << client_response.isChunked() << std::endl; client_response.write(image_stream, ec); } } } This same works if response size is smaller. However it is not working for larger responses. returned response content length is wrong. in chrome I see Content-Length:228599296 image size: 1048576 chunked: 0 |
From: Sergei N. <ser...@gm...> - 2015-10-09 14:37:39
|
2015-10-09 9:31 GMT+03:00 Neel Basu <nee...@gm...>: > I am trying to read a application/octet-stream of content size > 200MB with > pion net synchronously. But What I get is only 1.0MB downloaded. > It's limited with DEFAULT_CONTENT_MAX constant by default. So it's by design. Check set_max_content_length() API to change default behavior. -- Best Regards, Sergei Nikulov |