glitchedhttps
Macros | Functions
glitchedhttps.h File Reference

Simple, lightweight and straight-forward way of doing HTTP(S) requests in C with the help of ARM's open-source MbedTLS library. More...

#include "glitchedhttps_api.h"
#include "glitchedhttps_request.h"
#include "glitchedhttps_response.h"
#include "glitchedhttps_exitcodes.h"
Include dependency graph for glitchedhttps.h:

Go to the source code of this file.

Macros

#define GLITCHEDHTTPS_VERSION   100
 
#define GLITCHEDHTTPS_VERSION_STR   "1.0.0"
 
#define GLITCHEDHTTPS_STACK_BUFFERSIZE   8192
 

Functions

GLITCHEDHTTPS_API int glitchedhttps_init ()
 
GLITCHEDHTTPS_API void glitchedhttps_free ()
 
GLITCHEDHTTPS_API int glitchedhttps_submit (const struct glitchedhttps_request *request, struct glitchedhttps_response **out)
 

Detailed Description

Simple, lightweight and straight-forward way of doing HTTP(S) requests in C with the help of ARM's open-source MbedTLS library.

See also
https://github.com/GlitchedPolygons/glitchedhttps

Macro Definition Documentation

◆ GLITCHEDHTTPS_STACK_BUFFERSIZE

#define GLITCHEDHTTPS_STACK_BUFFERSIZE   8192

The maximum size in bytes that a temporary buffer may allocate on the stack before requiring a malloc

◆ GLITCHEDHTTPS_VERSION

#define GLITCHEDHTTPS_VERSION   100

Current version of the used GlitchedHTTPS library.

◆ GLITCHEDHTTPS_VERSION_STR

#define GLITCHEDHTTPS_VERSION_STR   "1.0.0"

Current version of the used GlitchedHTTPS library (nicely-formatted string).

Function Documentation

◆ glitchedhttps_free()

GLITCHEDHTTPS_API void glitchedhttps_free ( )

Releases the library's resources.

Warning
Only call this when you are very sure that there are no more pending requests!

GlitchedHTTPS will NOT check this for you: make sure to only call this when you're truly done making calls to glitchedhttps_submit() !

◆ glitchedhttps_init()

GLITCHEDHTTPS_API int glitchedhttps_init ( )

Initializes the library's resources, allocating everything needed for making HTTPS requests that requires some warmup (e.g. parsing the x509 CA root certificates into a mbedtls_x509_crt context only needs to be done once).

Don't forget to glitchedhttps_free() again once you're done using glitchedhttps!

Returns
0 on success; mbedtls error code on failure.

◆ glitchedhttps_submit()

GLITCHEDHTTPS_API int glitchedhttps_submit ( const struct glitchedhttps_request request,
struct glitchedhttps_response **  out 
)

Submits a given HTTP request and writes the server response into the provided output glitchedhttps_response instance.

This allocates memory, so don't forget to glitchedhttps_response_free() the output glitchedhttps_response instance after usage!!

Parameters
requestThe glitchedhttps_request instance containing the request parameters and data (e.g. url, body, etc...).
outThe output glitchedhttps_response into which to write the response's data and headers. Must be a pointer to a glitchedhttps_response pointer: will be malloc'ed! Make sure it's fresh!!
Returns
GLITCHEDHTTPS_SUCCESS (zero) if the request was submitted successfully; GLITCHEDHTTPS_{ERROR_ID} if the request couldn't even be submitted (e.g. invalid URL/server not found/no internet/whatever..). Check out the glitchedhttps_exitcodes.h header file to find out more about the glitchedhttps error codes!