http.c File Reference
#include "libavutil/avstring.h"
#include "avformat.h"
#include "internal.h"
#include "network.h"
#include "http.h"
#include "os_support.h"
#include "httpauth.h"
#include "url.h"
#include "libavutil/opt.h"
Include dependency graph for http.c:

Go to the source code of this file.

Data Structures

struct  HTTPContext
 

Macros

#define BUFFER_SIZE   MAX_URL_SIZE
 
#define MAX_REDIRECTS   8
 
#define OFFSET(x)   offsetof(HTTPContext, x)
 
#define D   AV_OPT_FLAG_DECODING_PARAM
 
#define E   AV_OPT_FLAG_ENCODING_PARAM
 
#define DEFAULT_USER_AGENT   "Mozilla/5.0 Lavf/" AV_STRINGIFY(LIBAVFORMAT_VERSION)
 
#define HTTP_CLASS(flavor)
 

Functions

 HTTP_CLASS (http)
 
 HTTP_CLASS (https)
 
static int http_connect (URLContext *h, const char *path, const char *local_path, const char *hoststr, const char *auth, const char *proxyauth, int *new_location)
 
void ff_http_init_auth_state (URLContext *dest, const URLContext *src)
 Initialize the authentication state based on another HTTP URLContext. More...
 
static int http_open_cnx (URLContext *h)
 
int ff_http_do_new_request (URLContext *h, const char *uri)
 Send a new HTTP request, reusing the old connection. More...
 
static int http_open (URLContext *h, const char *uri, int flags)
 
static int http_getc (HTTPContext *s)
 
static int http_get_line (HTTPContext *s, char *line, int line_size)
 
static int process_line (URLContext *h, char *line, int line_count, int *new_location)
 
static int get_cookies (HTTPContext *s, char **cookies, const char *path, const char *domain)
 Create a string containing cookie values for use as a HTTP cookie header field value for a particular path and domain from the cookie values stored in the HTTP protocol context. More...
 
static int has_header (const char *str, const char *header)
 
static int http_read_header (URLContext *h, int *new_location)
 
static int http_buf_read (URLContext *h, uint8_t *buf, int size)
 
static int http_read (URLContext *h, uint8_t *buf, int size)
 
static int http_write (URLContext *h, const uint8_t *buf, int size)
 
static int http_shutdown (URLContext *h, int flags)
 
static int http_close (URLContext *h)
 
static int64_t http_seek (URLContext *h, int64_t off, int whence)
 
static int http_get_file_handle (URLContext *h)
 

Variables

static const AVOption options []
 

Macro Definition Documentation

#define BUFFER_SIZE   MAX_URL_SIZE

Definition at line 39 of file http.c.

Referenced by http_getc(), and http_seek().

Definition at line 71 of file http.c.

#define DEFAULT_USER_AGENT   "Mozilla/5.0 Lavf/" AV_STRINGIFY(LIBAVFORMAT_VERSION)

Definition at line 73 of file http.c.

Definition at line 72 of file http.c.

#define HTTP_CLASS (   flavor)
Value:
static const AVClass flavor ## _context_class = {\
.class_name = #flavor,\
.item_name = av_default_item_name,\
.option = options,\
.version = LIBAVUTIL_VERSION_INT,\
}
av_default_item_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:55
static const AVOption options[]
Definition: http.c:74
LIBAVUTIL_VERSION_INT
Definition: eval.c:55
Describe the class of an AVClass context structure.
Definition: log.h:50

Definition at line 87 of file http.c.

#define MAX_REDIRECTS   8

Definition at line 40 of file http.c.

Referenced by http_open_cnx().

#define OFFSET (   x)    offsetof(HTTPContext, x)

Definition at line 70 of file http.c.

Function Documentation

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 216 of file http.c.

Referenced by rtmp_http_send_cmd().

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 102 of file http.c.

Referenced by ff_rtsp_open_transport_ctx().

static int get_cookies ( HTTPContext s,
char **  cookies,
const char *  path,
const char *  domain 
)
static

Create a string containing cookie values for use as a HTTP cookie header field value for a particular path and domain from the cookie values stored in the HTTP protocol context.

The cookie string is stored in *cookies.

Returns
a negative value if an error condition occurred, 0 otherwise

Definition at line 390 of file http.c.

Referenced by http_connect().

static int has_header ( const char *  str,
const char *  header 
)
inlinestatic

Definition at line 478 of file http.c.

Referenced by http_connect().

static int http_buf_read ( URLContext h,
uint8_t buf,
int  size 
)
static

Definition at line 635 of file http.c.

Referenced by http_get_file_handle(), and http_read().

HTTP_CLASS ( http  )
HTTP_CLASS ( https  )
static int http_close ( URLContext h)
static

Definition at line 740 of file http.c.

Referenced by http_get_file_handle().

static int http_connect ( URLContext h,
const char *  path,
const char *  local_path,
const char *  hoststr,
const char *  auth,
const char *  proxyauth,
int *  new_location 
)
static

Definition at line 511 of file http.c.

Referenced by http_open_cnx().

static int http_get_file_handle ( URLContext h)
static

Definition at line 792 of file http.c.

static int http_get_line ( HTTPContext s,
char *  line,
int  line_size 
)
static

Definition at line 263 of file http.c.

Referenced by http_read(), and http_read_header().

static int http_getc ( HTTPContext s)
static

Definition at line 246 of file http.c.

Referenced by http_get_line().

static int http_open ( URLContext h,
const char *  uri,
int  flags 
)
static

Definition at line 226 of file http.c.

Referenced by http_get_file_handle().

static int http_open_cnx ( URLContext h)
static

Definition at line 112 of file http.c.

Referenced by ff_http_do_new_request(), http_open(), and http_seek().

static int http_read ( URLContext h,
uint8_t buf,
int  size 
)
static

Definition at line 659 of file http.c.

Referenced by http_get_file_handle().

static int http_read_header ( URLContext h,
int *  new_location 
)
static

Definition at line 486 of file http.c.

Referenced by http_connect(), http_get_file_handle(), and http_read().

static int64_t http_seek ( URLContext h,
int64_t  off,
int  whence 
)
static

Definition at line 755 of file http.c.

Referenced by http_get_file_handle().

static int http_shutdown ( URLContext h,
int  flags 
)
static

Definition at line 724 of file http.c.

Referenced by http_close(), and http_get_file_handle().

static int http_write ( URLContext h,
const uint8_t buf,
int  size 
)
static

Definition at line 698 of file http.c.

Referenced by http_get_file_handle().

static int process_line ( URLContext h,
char *  line,
int  line_count,
int *  new_location 
)
static

Definition at line 287 of file http.c.

Referenced by http_read_header().

Variable Documentation

const AVOption options[]
static
Initial value:
= {
{"seekable", "control seekability of connection", OFFSET(seekable), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, D },
{"chunked_post", "use chunked transfer-encoding for posts", OFFSET(chunked_post), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, E },
{"headers", "set custom HTTP headers, can override built in default headers", OFFSET(headers), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },
{"content_type", "force a content type", OFFSET(content_type), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },
{"user-agent", "override User-Agent header", OFFSET(user_agent), AV_OPT_TYPE_STRING, {.str = DEFAULT_USER_AGENT}, 0, 0, D },
{"multiple_requests", "use persistent connections", OFFSET(multiple_requests), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, D|E },
{"post_data", "set custom HTTP post data", OFFSET(post_data), AV_OPT_TYPE_BINARY, .flags = D|E },
{"timeout", "set timeout of socket I/O operations", OFFSET(rw_timeout), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, D|E },
{"mime_type", "set MIME type", OFFSET(mime_type), AV_OPT_TYPE_STRING, {0}, 0, 0, 0 },
{"cookies", "set cookies to be sent in applicable future requests, use newline delimited Set-Cookie HTTP field value syntax", OFFSET(cookies), AV_OPT_TYPE_STRING, {0}, 0, 0, 0 },
}
FFmpeg currently uses a custom build this text attempts to document some of its obscure features and options Makefile the full command issued by make and its output will be shown on the screen DESTDIR Destination directory for the install useful to prepare packages or install FFmpeg in cross environments Makefile builds all the libraries and the executables fate Run the fate test note you must have installed it fate list Will list all fate regression test targets install Install headers
Definition: build_system.txt:1
#define DEFAULT_USER_AGENT
Definition: http.c:73
#define E
Definition: http.c:72
#define OFFSET(x)
Definition: http.c:70
offset must point to a pointer immediately followed by an int for the length
Definition: opt.h:228
NULL
Definition: eval.c:55
#define D
Definition: http.c:71

Definition at line 74 of file http.c.