在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:flaviotordini/http开源软件地址:https://github.com/flaviotordini/http开源编程语言:C++ 96.8%开源软件介绍:A wrapper for the Qt Network Access APIThis is just a wrapper around Qt's QNetworkAccessManager and friends. I use it in my apps at https://flavio.tordini.org . It has a simpler, higher-level API and some functionality not found in Qt:
DesignThis library uses the Decorator design pattern to modularize features and make it easy to add them and use them as needed. The main class is Http, which implements the base features of a HTTP client. More specialized classes are:
The constructor of these classes takes another Http instance for which they will act as a proxy. (See examples below). Following this design you can create your own Http subclass. For example, a different caching mechanism, an event dispatcher, custom request logging, etc. Build InstructionsIn order to build this library you can use either qmake
CMake
IntegrationYou can use this library as a git submodule. For example, add it to your project inside a lib subdirectory:
Then you can update your git submodules like this:
To integrate the library in your qmake based project just add this to your .pro file:
qmake builds all object files in the same directory. In order to avoid filename clashes use:
If you are using CMake you can integrate the library by adding the following lines to your CMakeLists.txt:
or if you have installed http you can find it via:
ExamplesA basic C++14 example:
Or using two separate signals for success and failure:
This is a real-world example of building a Http object with more complex features. It throttles requests, uses a custom user agent and caches results:
If the full power (and complexity) of QNetworkReply is needed you can always fallback to it:
Note that features like redirection, retries and read timeouts won't work in this mode. LicenseYou can use this library under the MIT license and at your own risk. If you do, you're welcome contributing your changes and fixes. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论