How to make an HTTP request in C++?
Hello everyone! Please advise how to properly make an HTTP request (GET/POST) in pure C++ without using third-party libraries like Boost.Beast or cURL? I'm writing a small console client for working with a REST API, but I can't find built-in tools for working with HTTP.
I tried using winsock2 on Windows and sys/socket.h on Linux, but ran into problems: firstly, when sending a GET request, the server returns a 400 Bad Request error, and secondly, I can't correctly handle chunked transfer encoding in the response. Here's an example of my code:
#ifdef _WIN32\n#include <winsock2.h>\n#pragma comment(lib, "ws2_32.lib")\n#else\n#include <sys/socket.h>\n#include <netinet/in.h>\n#include <arpa/inet.h>\n#endif\n\n#include <iostream>\n No answers yet.
Log in to leave an answer