VLC 4.0.0-dev
No Matches
message.c File Reference
Include dependency graph for message.c:

Data Structures

struct  vlc_http_msg


static bool vlc_http_is_token (const char *)
static ssize_t vlc_http_msg_find_header (const struct vlc_http_msg *m, const char *name)
static int vlc_http_msg_vadd_header (struct vlc_http_msg *m, const char *name, const char *fmt, va_list ap)
int vlc_http_msg_add_header (struct vlc_http_msg *m, const char *name, const char *fmt,...)
const char * vlc_http_msg_get_header (const struct vlc_http_msg *m, const char *name)
 Looks up an header field.
int vlc_http_msg_get_status (const struct vlc_http_msg *m)
 Gets response status code.
const char * vlc_http_msg_get_method (const struct vlc_http_msg *m)
 Gets request method.
const char * vlc_http_msg_get_scheme (const struct vlc_http_msg *m)
 Gets request scheme.
const char * vlc_http_msg_get_authority (const struct vlc_http_msg *m)
 Gets request authority.
const char * vlc_http_msg_get_path (const struct vlc_http_msg *m)
 Gets request absolute path.
void vlc_http_msg_destroy (struct vlc_http_msg *m)
 Destroys an HTTP message.
struct vlc_http_msgvlc_http_req_create (const char *method, const char *scheme, const char *authority, const char *path)
 Creates an HTTP request.
struct vlc_http_msgvlc_http_resp_create (unsigned status)
 Creates an HTTP response.
void vlc_http_msg_attach (struct vlc_http_msg *m, struct vlc_http_stream *s)
struct vlc_http_msgvlc_http_msg_iterate (struct vlc_http_msg *m)
 Gets next response headers.
struct vlc_http_msgvlc_http_msg_get_initial (struct vlc_http_stream *s)
struct vlc_http_msgvlc_http_msg_get_final (struct vlc_http_msg *m)
 Gets final response headers.
block_tvlc_http_msg_read (struct vlc_http_msg *m)
 Receives HTTP data.
int vlc_http_msg_write (struct vlc_http_msg *m, block_t *block, bool eos)
 Sends HTTP data.
char * vlc_http_msg_format (const struct vlc_http_msg *m, size_t *restrict lenp, bool proxied, bool chunked)
 Formats an HTTP 1.1 message header.
struct vlc_http_msgvlc_http_msg_headers (const char *msg)
 Parses an HTTP 1.1 message header.
struct vlc_h2_framevlc_http_msg_h2_frame (const struct vlc_http_msg *m, uint_fast32_t stream_id, bool eos)
 Formats an HTTP 2.0 HEADER frame.
struct vlc_http_msgvlc_http_msg_h2_headers (unsigned n, const char *const hdrs[][2])
 Parses an HTTP 2.0 header table.
char * vlc_http_authority (const char *host, unsigned port)
 Formats an authority.
static int vlc_http_istoken (int c)
static int vlc_http_isctext (int c)
static size_t vlc_http_token_length (const char *str)
static size_t vlc_http_quoted_length (const char *str)
const char * vlc_http_next_token (const char *value)
 Finds next token.
static const char * vlc_http_get_token (const char *value, const char *token)
static char * vlc_http_get_token_value (const char *value, const char *token)
const char * vlc_http_msg_get_token (const struct vlc_http_msg *msg, const char *field, const char *token)
 Looks up a token in a header field.
static size_t vlc_http_comment_length (const char *str)
static bool vlc_http_is_agent (const char *s)
int vlc_http_msg_add_agent (struct vlc_http_msg *m, const char *str)
 Sets the agent field.
const char * vlc_http_msg_get_agent (const struct vlc_http_msg *m)
 Gets the agent field.
int vlc_http_msg_add_time (struct vlc_http_msg *m, const char *hname, const time_t *t)
 Adds a timestamp header field.
int vlc_http_msg_add_atime (struct vlc_http_msg *m)
 Adds a Date header field.
static time_t vlc_http_mktime (const char *str)
time_t vlc_http_msg_get_time (const struct vlc_http_msg *m, const char *name)
 Parses a timestamp header field.
time_t vlc_http_msg_get_atime (const struct vlc_http_msg *m)
 Gets message date.
time_t vlc_http_msg_get_mtime (const struct vlc_http_msg *m)
 Gets resource date.
unsigned vlc_http_msg_get_retry_after (const struct vlc_http_msg *m)
 Gets retry timeout.
uintmax_t vlc_http_msg_get_size (const struct vlc_http_msg *m)
 Gets HTTP payload length.
void vlc_http_msg_get_cookies (const struct vlc_http_msg *m, vlc_http_cookie_jar_t *jar, const char *host, const char *path)
int vlc_http_msg_add_cookies (struct vlc_http_msg *m, vlc_http_cookie_jar_t *jar)
char * vlc_http_msg_get_basic_realm (const struct vlc_http_msg *m)
int vlc_http_msg_add_creds_basic (struct vlc_http_msg *m, bool proxy, const char *username, const char *password)
 Adds Basic credentials.


static const char vlc_http_error_loc
void *const vlc_http_error = (char *)&vlc_http_error_loc
 Error pointer value.
static const char vlc_http_days [7][4]
static const char vlc_http_months [12][4]

Function Documentation

◆ vlc_http_comment_length()

static size_t vlc_http_comment_length ( const char *  str)

References vlc_http_isctext().

Referenced by vlc_http_is_agent().

◆ vlc_http_get_token()

static const char * vlc_http_get_token ( const char *  value,
const char *  token 

◆ vlc_http_get_token_value()

static char * vlc_http_get_token_value ( const char *  value,
const char *  token 

◆ vlc_http_is_agent()

static bool vlc_http_is_agent ( const char *  s)

◆ vlc_http_is_token()

static bool vlc_http_is_token ( const char *  str)

◆ vlc_http_isctext()

static int vlc_http_isctext ( int  c)

Referenced by vlc_http_comment_length().

◆ vlc_http_istoken()

static int vlc_http_istoken ( int  c)

◆ vlc_http_mktime()

static time_t vlc_http_mktime ( const char *  str)

◆ vlc_http_msg_add_header()

◆ vlc_http_msg_find_header()

static ssize_t vlc_http_msg_find_header ( const struct vlc_http_msg m,
const char *  name 

◆ vlc_http_msg_format()

char * vlc_http_msg_format ( const struct vlc_http_msg m,
size_t *restrict  lenp,
bool  proxied,
bool  chunked 

Formats an HTTP 1.1 message header.

Formats an message header in HTTP 1.x format, using HTTP version 1.1.

mmessage to format/serialize
lenplocation to write the length of the formatted message in bytes [OUT]
proxiedwhether the message is meant for sending to a proxy rather than an origin (only relevant for requests)
chunkedwhether to append a chunked transfer encoding header line
A heap-allocated nul-terminated string or *lenp bytes, or NULL on error

References vlc_http_msg::authority, vlc_http_msg::count, vlc_http_msg::headers, vlc_http_msg::method, vlc_http_msg::path, vlc_http_msg::scheme, vlc_http_msg::status, vlc_memstream::stream, vlc_memstream_close(), vlc_memstream_open(), vlc_memstream_printf(), and vlc_memstream_puts().

Referenced by vlc_h1_stream_open().

◆ vlc_http_msg_h2_frame()

struct vlc_h2_frame * vlc_http_msg_h2_frame ( const struct vlc_http_msg m,
uint_fast32_t  stream_id,
bool  eos 

◆ vlc_http_msg_h2_headers()

struct vlc_http_msg * vlc_http_msg_h2_headers ( unsigned  n,
const char *const  hdrs[][2] 

◆ vlc_http_msg_headers()

struct vlc_http_msg * vlc_http_msg_headers ( const char *  msg)

Parses an HTTP 1.1 message header.

References name, strndup(), unlikely, vlc_http_msg_add_header(), vlc_http_msg_destroy(), and vlc_http_resp_create().

Referenced by vlc_h1_stream_wait().

◆ vlc_http_msg_vadd_header()

static int vlc_http_msg_vadd_header ( struct vlc_http_msg m,
const char *  name,
const char *  fmt,
va_list  ap 

◆ vlc_http_quoted_length()

static size_t vlc_http_quoted_length ( const char *  str)

◆ vlc_http_token_length()

static size_t vlc_http_token_length ( const char *  str)

Variable Documentation

◆ vlc_http_days

const char vlc_http_days[7][4]
Initial value:
= {
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"

Referenced by vlc_http_msg_add_time().

◆ vlc_http_error_loc

const char vlc_http_error_loc

◆ vlc_http_months

const char vlc_http_months[12][4]
Initial value:
= {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"

Referenced by vlc_http_mktime(), and vlc_http_msg_add_time().