Poco c++Net: Http get headers from response


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, (<a href="http://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/HttpResponse.html" rel="nofollow">getFirstHeader()</a>), 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?

</blockquote> res.get("Cache-control");


In the last try block the following can be added to print out the headers to screen:

cout << "RESPONSE:"; string name; string value; NameValueCollection::ConstIterator i = res.begin(); while(i!=res.end()){ name=i->first; value=i->second; cout << name << "=" << value << endl << flush; ++i; }


  • PHP PDO Update prepared statement problem
  • How to check Eclipse plugin performance
  • Inserting NULL/empty string using libpqxx library
  • object play not found in scala application
  • How to wait for all async tasks to finish in Node.js?
  • Sesame : how to remove the inference during queries?
  • How to draw a line dynamically in android [duplicate]
  • New Firebase failed: First argument must be a valid firebase URL and the path can't contain “.”
  • HttpURLConnection.getOutputStream() takes 20 seconds. Why?
  • php script is parsing content from RTE (tt_news) but internal links are not appearing as speaking ur
  • CXF JAXB JAXBEncoderDecoder unmarshalling error : unexpected element when having qualified elements
  • Jquery popup on mouse over of calendar control
  • Android Google Maps API v2 start navigation
  • WPF Visiblity Binding to Boolean Expression with multiple Variables
  • how to upload multiple files in c# windows application
  • MS Access - How to change the linked table path by amend the table
  • JBoss External Properties Files in Classpath
  • Connect .sks to skscene.h
  • System.InvalidCastException: Specified cast is not valid
  • How can I extract results of aggregate queries in slick?
  • Unity3D & Android: Difference between “UnityMain” and “main” threads?
  • Dialing with Intent.ACTION_CALL stopps at # in phone number
  • Why does access(2) check for real and not effective UID?
  • Checking free space on FTP server
  • Debugging ASP.NET on a built-in web server suddenly stops
  • How to redirect a user to a different server and include HTTP basic authentication credentials?
  • script to move all files from one location to another location
  • ILMerge & Keep Assembly Name
  • Symfony2: How to get request parameter
  • Delete MySQLi record without showing the id in the URL
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • SetUp method failed while running tests from teamcity
  • How to get icons for entities from eclipse?
  • InvalidAuthenticityToken between subdomains when logging in with Rails app
  • log4net write single file for each call to log.info
  • Getting error when using KSoap library to consume .NET web services
  • coudnt use logback because of log4j
  • Turn off referential integrity in Derby? is it possible?
  • JaxB to read class hierarchy
  • How to get NHibernate ISession to cache entity not retrieved by primary key