Gin
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
Http Class Reference

Simple HTTP client for making GET requests. More...

#include <gin_http.h>

Classes

struct  HttpResult
 Result of an HTTP request. More...
 

Public Member Functions

 Http (juce::URL url)
 Creates an HTTP client for the specified URL.
 
HttpResult get ()
 Performs a synchronous HTTP GET request.
 

Detailed Description

Simple HTTP client for making GET requests.

Http provides a lightweight, synchronous HTTP client built on top of SecureStreamingSocket. It supports both HTTP and HTTPS protocols, handles chunked transfer encoding, and returns complete response data including status code, headers, and body.

Key Features:

Usage: Create an Http instance with a URL, then call get() to perform the request. The method blocks until the response is received or an error occurs.

Http http(juce::URL("https://api.example.com/data"));
auto result = http.get();
if (result.statusCode == 200)
{
juce::String response = result.data.toString();
DBG("Response: " + response);
}
Simple HTTP client for making GET requests.
Definition gin_http.h:51
A lightweight 2D point class for projects that don't use juce_graphics.
Definition gin_point.h:25

Note: This is a synchronous (blocking) operation. For non-blocking HTTP requests, consider using juce::URL::createInputStream() with a background thread or JUCE's built-in WebInputStream.

See also
SecureStreamingSocket, AsyncWebsocket

Constructor & Destructor Documentation

◆ Http()

Http::Http ( juce::URL  url)

Creates an HTTP client for the specified URL.

Parameters
urlThe URL to request. Supports both http:// and https:// schemes.

Member Function Documentation

◆ get()

HttpResult Http::get ( )

Performs a synchronous HTTP GET request.

Connects to the server, sends the GET request, and reads the complete response including headers and body. This method blocks until the request completes or fails.

Returns
HttpResult containing status code, headers, and response data

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