FFmpeg
Loading...
Searching...
No Matches
httpcookie.c File Reference
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "libavutil/avstring.h"
#include "libavutil/bprint.h"
#include "libavutil/common.h"
#include "libavutil/mem.h"
#include "libavutil/parseutils.h"
#include "http.h"

Go to the source code of this file.

Macros

#define WHITESPACES   " \n\t\r"
 

Functions

static int is_date_delimiter (uint8_t c)
 
static int parse_digits (const char *str, int min, int max, int *val)
 
static int parse_time (const char *str, struct tm *tm)
 
static int parse_month (const char *str)
 
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".
 
static char * trim (char *str)
 
static int has_control_char (const char *str)
 
static int is_delta_seconds (const char *str)
 
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.
 

Macro Definition Documentation

◆ WHITESPACES

#define WHITESPACES   " \n\t\r"

Definition at line 32 of file httpcookie.c.

Function Documentation

◆ is_date_delimiter()

static int is_date_delimiter ( uint8_t c)
static

Definition at line 34 of file httpcookie.c.

Referenced by ff_http_parse_date().

◆ parse_digits()

static int parse_digits ( const char * str,
int min,
int max,
int * val )
static

Definition at line 41 of file httpcookie.c.

Referenced by ff_http_parse_date(), and parse_time().

◆ parse_time()

static int parse_time ( const char * str,
struct tm * tm )
static

Definition at line 50 of file httpcookie.c.

Referenced by ff_http_parse_date().

◆ parse_month()

static int parse_month ( const char * str)
static

Definition at line 59 of file httpcookie.c.

Referenced by ff_http_parse_date().

◆ 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().

◆ trim()

static char * trim ( char * str)
static

◆ has_control_char()

static int has_control_char ( const char * str)
static

Definition at line 118 of file httpcookie.c.

Referenced by ff_http_parse_set_cookie().

◆ is_delta_seconds()

static int is_delta_seconds ( const char * str)
static

Definition at line 126 of file httpcookie.c.

Referenced by ff_http_parse_set_cookie().

◆ 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().