Giter Site home page Giter Site logo

nir3x / httprequest.cpp Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 18 KB

HttpRequest - WinAPI HTTP Request Library

License: GNU Affero General Public License v3.0

Makefile 5.96% C++ 94.04%
c-plus-plus cpp http-request httprequest library winapi winhttp

httprequest.cpp's Introduction

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:

git clone https://github.com/NIR3X/HttpRequest.cpp
cd HttpRequest.cpp
make

Usage

Here is an example of how to use this package:

#include "HttpRequest.h"
#include <iostream>

int 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

GNU AGPLv3 Image

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 as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.