VLC 4.0.0-dev
Loading...
Searching...
No Matches

HTTP request/response streams. More...

Collaboration diagram for Streams:

Data Structures

struct  vlc_http_stream_cbs
 HTTP stream callbacks. More...
 
struct  vlc_http_stream
 HTTP stream. More...
 

Functions

void vlc_http_msg_attach (struct vlc_http_msg *m, struct vlc_http_stream *s)
 
struct vlc_http_msgvlc_http_msg_get_initial (struct vlc_http_stream *s) VLC_USED
 
static struct vlc_http_msgvlc_http_stream_read_headers (struct vlc_http_stream *s)
 Reads one message header.
 
static ssize_t vlc_http_stream_write (struct vlc_http_stream *s, const void *base, size_t length, bool eos)
 Write message payload data.
 
static block_tvlc_http_stream_read (struct vlc_http_stream *s)
 Reads message payload data.
 
static void vlc_http_stream_close (struct vlc_http_stream *s, bool abort)
 Closes an HTTP stream.
 

Variables

void *const vlc_http_error
 Error pointer value.
 

Detailed Description

HTTP request/response streams.

A stream is initiated by a client-side request header. It includes a final response header, possibly preceded by one or more continuation response headers. After the response header, a stream usually carries a response payload.

A stream may also carry a request payload (this is not supported so far).

The HTTP stream constitutes the interface between an HTTP connection and the higher-level HTTP messages layer.

Function Documentation

◆ vlc_http_msg_attach()

void vlc_http_msg_attach ( struct vlc_http_msg m,
struct vlc_http_stream s 
)

◆ vlc_http_msg_get_initial()

struct vlc_http_msg * vlc_http_msg_get_initial ( struct vlc_http_stream s)

◆ vlc_http_stream_close()

static void vlc_http_stream_close ( struct vlc_http_stream s,
bool  abort 
)
inlinestatic

Closes an HTTP stream.

Releases all resources associated or held by an HTTP stream. Any unread header or data is discarded.

Parameters
sHTTP stream to close
abortwhether to close the connection and prevent re-use

References vlc_http_stream::cbs, and vlc_http_stream_cbs::close.

Referenced by vlc_chunked_close(), vlc_http_msg_destroy(), and vlc_http_msg_get_initial().

◆ vlc_http_stream_read()

static block_t * vlc_http_stream_read ( struct vlc_http_stream s)
inlinestatic

Reads message payload data.

Reads the next block of data from the message payload of an HTTP stream.

Parameters
sHTTP stream to read from
Returns
a block of data (use block_Release() to free it)
Return values
NULLThe end of the stream was reached.
vlc_http_errorThe stream encountered a fatal error.

References vlc_http_stream::cbs, and vlc_http_stream_cbs::read.

Referenced by vlc_http_msg_read().

◆ vlc_http_stream_read_headers()

static struct vlc_http_msg * vlc_http_stream_read_headers ( struct vlc_http_stream s)
inlinestatic

Reads one message header.

Reads the next message header of an HTTP stream from the network. There is always exactly one request header per stream. There is usually one response header per stream, except for continuation (1xx) headers.

Warning
The caller is responsible for reading headers at appropriate times as intended by the protocol. Failure to do so may result in protocol dead lock, and/or (HTTP 1.x) connection failure.
Parameters
sHTTP stream to read from

References vlc_http_stream::cbs, and vlc_http_stream_cbs::read_headers.

Referenced by vlc_http_msg_get_initial(), and vlc_http_msg_iterate().

◆ vlc_http_stream_write()

static ssize_t vlc_http_stream_write ( struct vlc_http_stream s,
const void *  base,
size_t  length,
bool  eos 
)
inlinestatic

Write message payload data.

Writes data as message payload of an HTTP stream.

Todo:
Take a block structure rather than a byte array.
Parameters
sHTTP stream to write to
basestart address of data to write
lengthlength in bytes of data to write
eoswhether this is the last write on the stream
Return values
lensuccess
-1error

References vlc_http_stream::cbs, and vlc_http_stream_cbs::write.

Referenced by vlc_http_msg_write().

Variable Documentation

◆ vlc_http_error

void* const vlc_http_error
extern

Error pointer value.

This is an error value for some HTTP functions that can return NULL in non-error circumstances. Another return value is necessary to express error/failure, which this is. This compares different to NULL and to any valid pointer.

Warning
Dereferencing this pointer is undefined.

Referenced by vlc_chunked_fatal(), vlc_chunked_read(), vlc_h1_stream_read(), vlc_h2_stream_read(), vlc_http_file_read(), and vlc_http_live_read().