HTTP Range Retreival Request and POCO API?

Please post support and help requests here.
Posts: 1
Joined: 13 Jul 2009, 10:10

HTTP Range Retreival Request and POCO API?

Postby pibara » 13 Jul 2009, 10:19

I want to use POCO's HTTP API for accessing data on a server that supports HTTP Range Retrieval Requests.
The data is stored in real large files (tens to hundreds of GBs), and the application needs random access to these files, so regular
full file streaming is not an option. Looking at the HTTP classes and their interfaces, I can find no clear pointers as to how to
ask POCO to use HTTP Range Retrieval Requests. Can someone point oit to me how to use the API in the desired way?



Posts: 1265
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: HTTP Range Retreival Request and POCO API?

Postby guenter » 13 Jul 2009, 11:39

You have to add a Range header to the HTTP request you're sending to the server.
The server will then respond with a 206 (instead of 200) reply.
Here's a small sample how to do it:

Code: Select all

HTTPClientSession session("localhost", "80");
HTTPRequest req(HTTPRequest::HTTP_GET, "/large.dat", HTTPMessage::HTTP_1_1);
req.set("Range", Poco::format("bytes=%d-%d", 0, 1023)); // receive bytes from 0 to 1023
HTTPResponse res;
std::istream& rs = session.receiveResponse(res);
std::cout << res.getStatus() << " " << res.getReason() << std::endl;
StreamCopier::copyStream(rs, std::cout);

Return to “Support”

Who is online

Users browsing this forum: No registered users and 1 guest