BSB Developer Docs
Loading...
Searching...
No Matches
http_response.h File Reference

Utility functions for parsing HTTP responses. More...

#include <stdint.h>
#include <stdbool.h>
#include "slice.h"

Go to the source code of this file.

Data Structures

struct  HttpResponse
 Parsed HTTP response structure. More...
 

Functions

void http_response_init (HttpResponse *instance)
 Initialise a HttpResponse instance with default values.
 
bool http_response_parse (HttpResponse *instance, const char *data, size_t data_len)
 Parse the response from a raw string representation.
 

Detailed Description

Utility functions for parsing HTTP responses.

Function Documentation

◆ http_response_init()

void http_response_init ( HttpResponse * instance)

Initialise a HttpResponse instance with default values.

After calling this function, all string slices are guaranteed to be zero-length and with non-NULL pointers.

Parameters
[in,out]instancepointer to the instance to be initialised

◆ http_response_parse()

bool http_response_parse ( HttpResponse * instance,
const char * data,
size_t data_len )

Parse the response from a raw string representation.

Note
In case of failure, the value pointed to by instance is left untouched. Therefore, if a valid value is needed at all times, http_response_init must be called first to ensure that the instance is valid before calling this function.
Parameters
[in,out]instancepointer to the instance to be parsed
[in]datapointer to the source string (does NOT need to be zero-terminated)
[in]data_lenlength of the source string in bytes