https://github.com/noahedavis/webrequest
Simple thread-safe C++ WinHttp wrapper for creating synchronous/asynchronous web requests.
https://github.com/noahedavis/webrequest
cpp http http2 web winhttp
Last synced: 12 months ago
JSON representation
Simple thread-safe C++ WinHttp wrapper for creating synchronous/asynchronous web requests.
- Host: GitHub
- URL: https://github.com/noahedavis/webrequest
- Owner: noahedavis
- License: mit
- Created: 2025-01-29T01:03:38.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-07T10:03:46.000Z (about 1 year ago)
- Last Synced: 2025-02-07T11:19:58.521Z (about 1 year ago)
- Topics: cpp, http, http2, web, winhttp
- Language: C++
- Homepage:
- Size: 37.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# webrequest
Simple thread-safe C++ WinHttp wrapper for creating synchronous/asynchronous web requests. Includes easy customization options for mutual tls, retries and authentication.
If you have any suggestions for changes/updates feel free to let me know!
## Examples
To send a web request and get it's response, call the request() method on a WebRequester object:
```C++
WebRequester req;
WebResponse resp = req.request("https://www.github.com");
println(resp.response_str);
```
To send an async web request, use the requestAsync() method. After the request is sent, call the get() method on the returned FutureWebResponse to get the results.
```C++
WebRequester req;
FutureWebResponse resp = req.requestAsync("https://www.github.com");
// Do something ...
println(resp.get().response_str);
```
Other basic examples can be found in the example folder
## Overview
The WinHttp class includes the bare bone features needed to send http requests. This class behaves similarly to the WinHttpRequest class in VBA, but no data on the requests is stored within the class instance itself: request data and response data will exist in the methods that call the WinHttp request method
The WebRequester class is the main class, built over the WinHttp class. This class includes options for specifying number of retries on failure and performing custom-defined authentication procedures.
## Build
This project currently supports C++11 through C++ 20, and requires the Windows SDK.
When building the project, you'll need to include each of the cpp files, and these libraries from the Windows SDK:
winhttp.lib
Crypt32.Lib
RpcRT4.Lib
Those libraries can be usually be found in a path like:
C:\Program Files (x86)\Windows Kits\10\Lib\[VERSION]\um\[CPU ISA]
More information on the Windows SDK and API can be found [here](https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/) and [here](https://learn.microsoft.com/en-us/windows/win32/apiindex/windows-api-list):