MetaImGUI 1.0.0
ImGui Application Template for C++20
Loading...
Searching...
No Matches
MetaImGUI::HttpClient Class Reference

Thin RAII wrapper around libcurl_easy for application-side fetches. More...

#include <HttpClient.h>

Public Member Functions

 HttpClient ()=default
 
 ~HttpClient ()=default
 
 HttpClient (const HttpClient &)=delete
 
HttpClientoperator= (const HttpClient &)=delete
 
 HttpClient (HttpClient &&)=default
 
HttpClientoperator= (HttpClient &&)=default
 
HttpResponse Get (const HttpRequest &request, const std::stop_token &stopToken) const
 Issue a GET request, honouring stop_token cancellation.
 
HttpResponse Get (const HttpRequest &request) const
 Convenience overload for the common no-cancel case.
 

Detailed Description

Thin RAII wrapper around libcurl_easy for application-side fetches.

Centralises the boilerplate that UpdateChecker and ISSTracker had each re-implemented: SSL verification, stop_token-driven xferinfo abort, GitHub rate-limit header parsing, and exponential backoff on retry.

The design is deliberately stateless — every Get() is independent — so callers can hold a single HttpClient instance for the lifetime of the app and share it across threads.

Definition at line 65 of file HttpClient.h.

Constructor & Destructor Documentation

◆ HttpClient() [1/3]

MetaImGUI::HttpClient::HttpClient ( )
default

◆ ~HttpClient()

MetaImGUI::HttpClient::~HttpClient ( )
default

◆ HttpClient() [2/3]

MetaImGUI::HttpClient::HttpClient ( const HttpClient )
delete

◆ HttpClient() [3/3]

MetaImGUI::HttpClient::HttpClient ( HttpClient &&  )
default

Member Function Documentation

◆ Get() [1/2]

HttpResponse MetaImGUI::HttpClient::Get ( const HttpRequest request) const

Convenience overload for the common no-cancel case.

Definition at line 117 of file HttpClient.cpp.

References Get().

◆ Get() [2/2]

HttpResponse MetaImGUI::HttpClient::Get ( const HttpRequest request,
const std::stop_token &  stopToken 
) const

Issue a GET request, honouring stop_token cancellation.

Retries on HttpStatus::NetworkError up to request.maxRetries times, with exponential backoff (200ms, 400ms, 800ms, ...). Cancellation and rate-limit responses are returned immediately without retry — those aren't transient.

Definition at line 78 of file HttpClient.cpp.

References MetaImGUI::Cancelled, MetaImGUI::HttpRequest::maxRetries, MetaImGUI::NetworkError, and MetaImGUI::HttpResponse::status.

Referenced by Get().

◆ operator=() [1/2]

HttpClient & MetaImGUI::HttpClient::operator= ( const HttpClient )
delete

◆ operator=() [2/2]

HttpClient & MetaImGUI::HttpClient::operator= ( HttpClient &&  )
default

The documentation for this class was generated from the following files: