refactor: reemplazar cpp-httplib por HTTP client minimalista
cpp-httplib requiere std::mutex que no compila con MinGW win32 thread model. Se reemplaza por http_client.cpp: sockets crudos, sin threading, sin SSL, funciona en ambos thread models. Elimina vendor/httplib.h (10K lineas). nlohmann/json se mantiene. main.cpp: doble clic sin argumentos intenta la API en localhost:8484 automaticamente. Si falla muestra pantalla de error con boton Retry. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
// Minimal HTTP client — no threading, no SSL, just plain TCP to localhost.
|
||||
// Works with both win32 and posix MinGW thread models.
|
||||
|
||||
#include <string>
|
||||
|
||||
struct HttpResponse {
|
||||
int status = 0;
|
||||
std::string body;
|
||||
bool ok() const { return status >= 200 && status < 300; }
|
||||
};
|
||||
|
||||
// Simple blocking HTTP GET/POST over TCP sockets.
|
||||
// host: "127.0.0.1", port: 8484
|
||||
class HttpClient {
|
||||
public:
|
||||
HttpClient(const std::string& host, int port);
|
||||
|
||||
HttpResponse get(const std::string& path);
|
||||
HttpResponse post(const std::string& path, const std::string& body,
|
||||
const std::string& content_type = "application/json");
|
||||
|
||||
private:
|
||||
std::string host_;
|
||||
int port_;
|
||||
int timeout_sec_ = 5;
|
||||
|
||||
HttpResponse request(const std::string& method, const std::string& path,
|
||||
const std::string& body, const std::string& content_type);
|
||||
};
|
||||
Reference in New Issue
Block a user