Hi im writing a mobile application client featuring web-requests, through POCO C++ Net-library. However for performance reasons im in need of caching the http responses( response caching to disk). I hear this can be done, but it seems POCO Net lacks this support? Are there any other network libs that supports response caching (Please point me to an example)?
For example if i request a JSON i want to check if the cached version is up-to-date with the server version, before i fetch it, to make the general appearance of the app more smooth.
(I need to use C++ since im developing cross-platform in C++)
There's no out-of-the-box support, but using Cache Framework with a custom strategy based on AbstractStrategy for disk persistence should be straightforward.
Two things to keep in mind:
Cache Framework performance/size penalty (check the linked doc)
Cache-control header:
a response is cacheable if the requirements of the request method,
request header fields, and the response status indicate that it is
cacheable.
HTH
Related
It's pretty much the tittle.
Im not expecting the whole code to just copy and paste (but feel free to do it). Im just having difficulties to find some data related. If someone knows how to do it, please post some hints, article links, specific words to make some research on it.
Thank you.
As Christian mentioned in his comment, your problem can be solved by implementing an HTTP client that parses JSON responses, independently of the technology used by your server. To do this in C++, I would refer you to the following resources:
High-level library for C++ HTTP client.
libcurl (lower level library for HTTP requests).
RapidJSON library to parse the responses you will get from your server (see this benchmark for a comparison of JSON parsing libraries).
If your C++ application uses a framework such as Qt, it likely includes facilities for requests (e.g. Qt HTTP example).
On the server side, you will have to define HTTP endpoints that return the data you are interested in, encoded as JSON. The beginning of this tutorial shows an easy way to do that.
node.js c++ add on manual
https://nodejs.org/api/addons.html
http://libuv.org/
use libuv function in node.js 0.12.x
I am working on a project where I need to communicate with a server using a network library in C++. Currently im using POCO/Net
Is there any C++ library that has support for response caching, authentication, HTTP and HTTPS similar to the Java version?
Greatful for help!
wwwlib seems to provide the kind of persistant cache you are after and is http 1.1 compliant according to W3lib. I have not yet tried it though, it seems very low level in comparison to POCO. Someone else might have a simpler library...
I have a requirement where I have to implement a timer based application which will periodically call a rest web service implemented in asp.net MVC 3 and store the response JSON data in a SQL Lite database. It will also have to implement a http web client to download media files of huge size which will need decompression. This component has to be written using C++.
Would need some help in isolating the logical task breakdown for this component. Typically a list of items like:
POC to isolate an open source C++ web service communication library
POC to isolate an open source C++ JSON framework
POC to isolate an open source C++ Zlib packages
Also if somebody can provide some good suggestions around some stable and flexible open source libraries in C++ for
Web Service communication
JSON parsing
SQL Lite adapter
Some other lightweight database alternative to SQL Lite
HTTP based downloader. Possibly implementing multithreaded and multipart download
Decompression library
Performance is a primary concern for the application. can somebody suggest designs around implementing faster downloads of huge media files over HTTP.
Facebook Folly provides JSON services, amongst other utilities.
Although not Open Source, Microsoft's Casablanca library
provides Web Client functions.
I am pretty new to web programming.I am developing a HTML5 based user interface which is supposed to use a middle ware written in C/C++.How can I do this?
I do not want to use any browser specific feature/library to communicate with the middle ware. Can we do the same at the server side and then send back the information to the browser? If so how can I achieve this communication with the middle ware at the server side?
Thanks in advance for the reply.
Note : I am planning to use Tomcat as the server in loop back.
As suggested above, you could use CGI (e.g., perl scripts) as a middle-man between the Tomcat server and your C++ middleware. What I also think might work well, and am planning on using myself in the near future, is to use boost::asio, and take the example HTTP server and modify it to use your middleware. You could then communicate between the Tomcat server and the C++ server using AJAX with JSON.
There is also something called pion server http://www.pion.org/projects/pion-network-library
It allows you to write the entire server in your own C++, with most of the common tasks abstracted away.
The Wt "web toolkit" library (pronounced "witty") may be of interest. Essentially all web-aspects are taken care of this, so absolutely no middleware. Here is an intro, quoting from the website:
The API is widget-centric and uses well-tested patterns of desktop GUI
development tailored to the web. To the developer, it offers
abstraction of web-specific implementation details, including
client-server protocols, event handling, graphics support, graceful
degradation (or progressive enhancement), and URL handling.
Unlike many page-based frameworks, Wt was designed for creating
stateful applications that are at the same time highly interactive
(leveraging techinques such as WebSockets and Ajax to their fullest)
and accessible (supporting plain HTML browsers), using automatic
graceful degradation or progressive enhancement. Things that are
natural and simple with Wt would require an impractical amount of
effort otherwise: switching widgets using animations, while being
perfectly indexed by search robots with clean URLs, or having a
persistent chat widget open throughout, that even works in legacy
browsers like Microsoft Internet Explorer 6.
It can run with its own web server (based on a Boost component) or be linked against standard web server libraries.
I wrote a short blog post about how to integrate it with another C++ component I wrote (RInside, which permits to embed R inside C++ apps) and by joining the two, I had a simple 'webapp' exporting R functionality to the web.
You can further enhance it via Javascript but that is something I have not looked into in any detail.
What would be the preferred method of pulling content from a remote database?
I don't think that I would want to pull directly from the database for a number of reasons.
(Such as easily being able to change where it is fetching the info from and a current lack of access from outside the server.)
I've been thinking of using HTTP as a proxy to the database basically just using some PHP to display raw text from the database and then grabbing the page and dumping it to a string for displaying.
I'm not exactly sure how I would go about doing that though. (Sockets?)
Right now I am building it around a blog/news type system. Though the content would expand in the future.
I've got a similar problem at the moment, and the approach I'm taking is to communicate from the client app with a database via a SOAP web service.
The beauty of this approach is that on the client side the networking involved consists of a standard HTTP request. Most platforms these days include an API to perform basic HTTP client functions. You'll then also need an XML or JSON parser to parse the returned SOAP data, but they're also readily available.
As a concrete example, a little about my particular project: It's an iPhone app communicating with an Oracle database. I use a web service to read data from the database and send the data to the app formatted in XML using SOAP. The app can use Apple's NSURLConnection API to perform the necessary HTTP request. The XML is then parsed using the NSXMLParser API.
While the above are pretty iPhone-specific (and are Objective-C based) I think the general message still applies - there's tools out there that will do most of the work for you. I can't think of an example of an HTTP API offhand, but for the XML parsing part of the equation there's Xerces, TinyXML, Expat...
HTH!
You might look at using AJAX (I recommend JSON instead of XML though). This is the technology underlying Google Maps.