Im using POCO C++ Net libraries for http
I want to try make a strategy for persistent caching.
First of all I think I need to get expires from the cache headers and cross check with cached values (please tell me if I'm wrong).
So how can I extract the cache header from httpResponse
?
I've seen that you can do this in Java, (getFirstHeader()
), but how do I do it in POCO C++?
Below is an ordinary http GET-request using POCO:
try
{
// prepare session
URI uri("http://www.google.se");
HTTPClientSession session(uri.getHost(), uri.getPort());
// prepare path
string path(uri.getPathAndQuery());
if (path.empty()) path = "/";
// send request
printnet(path.c_str());
HTTPRequest req(HTTPRequest::HTTP_GET, path, HTTPMessage::HTTP_1_1);
session.sendRequest(req);
// get response
printnet("Get response");
HTTPResponse res;
cout << res.getStatus() << " " << res.getReason() << endl;
// print response
istream &is = session.receiveResponse(res);
StreamCopier::copyStream(is, cout);
}
catch (Exception &ex)
{
printnet(ex.displayText().c_str());
return -1;
}
return 0;
So how can i extract the cache header from httpResponse?
res.get("Cache-control");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With