FFmpeg
Loading...
Searching...
No Matches
http.h File Reference
#include <stdint.h>
#include <string.h>
#include <time.h>
#include "libavutil/dict.h"
#include "libavutil/error.h"
#include "libavutil/log.h"
#include "url.h"

Go to the source code of this file.

Data Structures

struct  HTTPStatusLine
 Parsed form of a response status line. More...
 

Macros

#define HTTP_HEADERS_SIZE   4096
 

Functions

int ff_http_parse_status_line (void *logctx, const char *line, HTTPStatusLine *st)
 Parse the status line of an HTTP response.
 
static void ff_http_parse_icy_packet (void *logctx, AVDictionary **metadata, char *data)
 Split an in-band ICY metadata packet into its "Key='Value';" pairs.
 
void ff_http_init_auth_state (URLContext *dest, const URLContext *src)
 Initialize the authentication state based on another HTTP URLContext.
 
int ff_http_do_new_request (URLContext *h, const char *uri)
 Send a new HTTP request, reusing the old connection.
 
int ff_http_do_new_request2 (URLContext *h, const char *uri, AVDictionary **options)
 Send a new HTTP request, reusing the old connection.
 
const char * ff_http_get_new_location (URLContext *h)
 
int ff_http_parse_date (const char *date_str, struct tm *buf)
 Parse an HTTP date like "Wed, 21 Oct 2015 07:28:00 GMT".
 
int ff_http_parse_set_cookie (const char *set_cookie, AVDictionary **cookie, AVDictionary **attributes)
 Parse a Set-Cookie style line.
 
int ff_http_host_is_ip_literal (const char *host)
 
const char * ff_http_cookie_domain (const AVDictionary *cookie_params)
 
int64_t ff_http_cookie_expiry (const AVDictionary *attributes)
 
int ff_http_bind_cookies_to_host (char **cookies, const char *host)
 Restrict the cookies without a Domain to host.
 
static int ff_http_averror (int status_code, int default_averror)
 

Macro Definition Documentation

◆ HTTP_HEADERS_SIZE

#define HTTP_HEADERS_SIZE   4096

Definition at line 34 of file http.h.

Function Documentation

◆ ff_http_parse_status_line()

int ff_http_parse_status_line ( void * logctx,
const char * line,
HTTPStatusLine * st )

Parse the status line of an HTTP response.

Parameters
logctxcontext used for logging, may be NULL
lineNUL terminated status line, without its trailing CRLF
stfilled in with the parsed status line
Returns
0 on success, a negative AVERROR code on failure

Definition at line 952 of file http.c.

Referenced by process_line(), and test().

◆ ff_http_parse_icy_packet()

static void ff_http_parse_icy_packet ( void * logctx,
AVDictionary ** metadata,
char * data )
inlinestatic

Split an in-band ICY metadata packet into its "Key='Value';" pairs.

Parameters
logctxcontext used for logging, may be NULL
metadatadictionary the pairs are stored in
dataNUL terminated packet, split in place

Definition at line 64 of file http.h.

Referenced by store_icy(), and update_icy_metadata().

◆ ff_http_init_auth_state()

void ff_http_init_auth_state ( URLContext * dest,
const URLContext * src )

Initialize the authentication state based on another HTTP URLContext.

This can be used to pre-initialize the authentication parameters if they are known beforehand, to avoid having to do an initial failing request just to get the parameters.

Parameters
destURL context whose authentication state gets updated
srcURL context whose authentication state gets copied

Definition at line 243 of file http.c.

◆ ff_http_do_new_request()

int ff_http_do_new_request ( URLContext * h,
const char * uri )

Send a new HTTP request, reusing the old connection.

Parameters
hpointer to the resource
uriuri used to perform the request
Returns
a negative value if an error condition occurred, 0 otherwise

Definition at line 589 of file http.c.

Referenced by dashenc_io_open(), hlsenc_io_open(), and rtmp_http_send_cmd().

◆ ff_http_do_new_request2()

int ff_http_do_new_request2 ( URLContext * h,
const char * uri,
AVDictionary ** options )

Send a new HTTP request, reusing the old connection.

Parameters
hpointer to the resource
uriuri used to perform the request
optionsA dictionary filled with HTTP options. On return this parameter will be destroyed and replaced with a dict containing options that were not found. May be NULL.
Returns
a negative value if an error condition occurred, 0 otherwise

Definition at line 593 of file http.c.

Referenced by ff_http_do_new_request(), and open_url_keepalive().

◆ ff_http_get_new_location()

const char * ff_http_get_new_location ( URLContext * h)

Definition at line 661 of file http.c.

Referenced by exchange_sdp().

◆ ff_http_parse_date()

int ff_http_parse_date ( const char * date_str,
struct tm * buf )

Parse an HTTP date like "Wed, 21 Oct 2015 07:28:00 GMT".

Returns
0 on success, a negative value otherwise

Definition at line 69 of file httpcookie.c.

Referenced by ff_http_cookie_expiry(), ff_http_parse_set_cookie(), main(), parse_cookie(), parse_expires(), and process_line().

◆ ff_http_parse_set_cookie()

int ff_http_parse_set_cookie ( const char * set_cookie,
AVDictionary ** cookie,
AVDictionary ** attributes )

Parse a Set-Cookie style line.

Parameters
cookiethe name and value of the cookie are added to it
attributesthe attributes of the cookie are added to it
Returns
0 on success, AVERROR_INVALIDDATA if the line holds no cookie, another negative error code otherwise

Definition at line 132 of file httpcookie.c.

Referenced by cookie_list_line(), ff_http_bind_cookies_to_host(), get_cookies(), main(), and parse_cookie().

◆ ff_http_host_is_ip_literal()

int ff_http_host_is_ip_literal ( const char * host)

Definition at line 182 of file httpcookie.c.

Referenced by cookie_list_line(), and host_in_cookie_domain().

◆ ff_http_cookie_domain()

const char * ff_http_cookie_domain ( const AVDictionary * cookie_params)
Returns
the Domain attribute without a leading dot, NULL if there is none

Definition at line 187 of file httpcookie.c.

Referenced by cookie_list_line(), ff_http_bind_cookies_to_host(), get_cookies(), main(), and parse_cookie().

◆ ff_http_cookie_expiry()

int64_t ff_http_cookie_expiry ( const AVDictionary * attributes)
Parameters
attributesattributes parsed by ff_http_parse_set_cookie()
Returns
the time the cookie expires at in seconds since the epoch, 0 if it does not expire

Definition at line 195 of file httpcookie.c.

Referenced by cookie_list_line(), get_cookies(), and main().

◆ ff_http_bind_cookies_to_host()

int ff_http_bind_cookies_to_host ( char ** cookies,
const char * host )

Restrict the cookies without a Domain to host.

Parameters
cookiesnewline separated Set-Cookie style lines, replaced on success
Returns
0 on success, a negative value otherwise

Definition at line 211 of file httpcookie.c.

Referenced by http_open(), main(), and setup_curl().

◆ ff_http_averror()

static int ff_http_averror ( int status_code,
int default_averror )
inlinestatic

Definition at line 161 of file http.h.

Referenced by check_http_code(), ff_rtsp_averror(), header_callback(), and http_open_cnx().