This project may not be updated frequently because a better alternative project has been found: https://github.com/libcpr/cpr
-
include_directories(${PROJECT_SOURCE_DIR}/WinHttp) add_executable(${PROJECT_NAME} main.cpp) target_link_libraries(${PROJECT_NAME} ${PROJECT_SOURCE_DIR}/lib/Winhttp_SimpleAPI.lib)
#include <WinhttpAPI.h>
-
#include "..\\WinhttpAPI.h" #pragma comment(lib,"..\\Winhttp_SimpleAPI.lib")
using namespace Winhttp;
HttpRequestT httpRequest;
HttpResponseT httpResponse;
httpRequest.url = "https://www.baidu.com";
httpRequest.protocol = "get";
WinhttpAPI httpAPI;
httpAPI.SetHeader("Connection","keep-alive");
httpAPI.SetHeader("Context-Type","text/html");
httpAPI.Request(httpRequest,httpResponse);
//Get the content and headers returned from a web visit.
std::cout << "[+]" << httpResponse.body << ", " << httpResponse.headers << '\n';
//Retrieve a specific key value from the returned headers
std::cout << "[+]" << httpAPI.GetHeader("Date") << '\n';
HttpRequestT httpRequest = {"https://example.com/1GB.bin", "get", {HttpRequestT::SaveMethodT::FILE_STREAM, "C:\\test.bin"}};
HttpResponseT httpResponse;
WinhttpAPI httpAPI(httpRequest,httpResponse);
httpAPI.request();
//At the same time,the headers exist and the body has empty
- use encode/decode function
// transform string to wstring std::wstring wStr = CodeCvt::StrToWstr("hello world", CP_ACP); // transform wstring to string std::string str = CodeCvt::WstrToStr(L"hello world", CP_ACP);
- Change code style, design mode
- multithreading support