https://github.com/nir3x/httprequest.cpp
HttpRequest - WinAPI HTTP Request Library
https://github.com/nir3x/httprequest.cpp
c-plus-plus cpp http-request httprequest library winapi winhttp
Last synced: 3 months ago
JSON representation
HttpRequest - WinAPI HTTP Request Library
- Host: GitHub
- URL: https://github.com/nir3x/httprequest.cpp
- Owner: NIR3X
- License: agpl-3.0
- Created: 2024-01-11T05:49:19.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-16T04:03:40.000Z (over 1 year ago)
- Last Synced: 2024-02-16T05:22:52.451Z (over 1 year ago)
- Topics: c-plus-plus, cpp, http-request, httprequest, library, winapi, winhttp
- Language: C++
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# HttpRequest - WinAPI HTTP Request Library
This is a C++ package that implements the `CHttpRequest` class for making HTTP requests using WinHTTP. This library provides a simple and efficient way to make HTTP requests in C++.
## Installation
To use this package, you can clone the repository and compile it using a C++ compiler:
```bash
git clone https://github.com/NIR3X/HttpRequest.cpp
cd HttpRequest.cpp
make
```## Usage
Here is an example of how to use this package:
```cpp
#include "HttpRequest.h"
#includeint main() {
uint32_t statusCode = 0;
auto response = CHttpRequest::Request(L"https://example.com/index.html", CHttpRequest::COptions {}, statusCode);
std::cout << "Response: " << std::string(response.begin(), response.end()) << std::endl;
std::cout << "Status code: " << statusCode << std::endl;statusCode = 0;
CHttpRequest::COptions options = {};
options.method = L"POST";
options.headers[L"Content-Type"] = L"application/x-www-form-urlencoded";
std::string data = "field1=value1&field2=value2";
options.data = { data.begin(), data.end() };
response = CHttpRequest::Request(L"https://example.com/test", options, statusCode);
std::cout << "Response: " << std::string(response.begin(), response.end()) << std::endl;
std::cout << "Status code: " << statusCode << std::endl;
}
```This code example demonstrates making a GET request to "https://example.com/index.html" and printing the response along with the status code. It also shows how to make a POST request to "https://example.com/test" with custom options, including specifying the HTTP method, headers, and data. The response and status code for the POST request are also printed.
## License
[](https://www.gnu.org/licenses/agpl-3.0.html)
This program is Free Software: You can use, study share and improve it at your
will. Specifically you can redistribute and/or modify it under the terms of the
[GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.html) as
published by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.