ELinks 0.18.0
http.c File Reference
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <limits.h>
#include "elinks.h"
#include "cache/cache.h"
#include "config/options.h"
#include "cookies/cookies.h"
#include "intl/charsets.h"
#include "intl/libintl.h"
#include "main/module.h"
#include "network/connection.h"
#include "network/progress.h"
#include "network/socket.h"
#include "osdep/ascii.h"
#include "osdep/osdep.h"
#include "osdep/sysname.h"
#include "protocol/auth/auth.h"
#include "protocol/auth/digest.h"
#include "protocol/curl/http.h"
#include "protocol/date.h"
#include "protocol/header.h"
#include "protocol/http/blacklist.h"
#include "protocol/http/codes.h"
#include "protocol/http/http.h"
#include "protocol/uri.h"
#include "session/session.h"
#include "terminal/terminal.h"
#include "util/base64.h"
#include "util/conv.h"
#include "util/memory.h"
#include "util/string.h"
Include dependency graph for http.c:

Macros

#define HTTP_0_9(x)   ((x).major == 0 && (x).minor == 9)
 
#define HTTP_1_0(x)   ((x).major == 1 && (x).minor == 0)
 
#define HTTP_1_1(x)   ((x).major == 1 && (x).minor == 1)
 
#define PRE_HTTP_1_0(x)   ((x).major < 1)
 
#define PRE_HTTP_1_1(x)   (PRE_HTTP_1_0(x) || HTTP_1_0(x))
 
#define POST_HTTP_1_0(x)   ((x).major > 1 || ((x).major == 1 && (x).minor > 0))
 
#define POST_HTTP_1_1(x)   ((x).major > 1 || ((x).major == 1 && (x).minor > 1))
 
#define LEN_CHUNKED   -2 /* == we get data in unknown number of chunks */
 
#define LEN_FINISHED   0
 
#define CHUNK_DATA_END   -3
 
#define CHUNK_ZERO_SIZE   -2
 
#define CHUNK_SIZE   -1
 
#define IS_PROXY_URI(x)   ((x)->protocol == PROTOCOL_PROXY)
 
#define connection_is_https_proxy(conn)    (IS_PROXY_URI((conn)->uri) && (conn)->proxied_uri->protocol == PROTOCOL_HTTPS)
 
#define POST_BUFFER_SIZE   4096
 

Functions

static void done_http (struct module *mod)
 
static void init_accept_charset (void)
 
char * subst_user_agent (char *fmt, const char *version, char *sysname, char *termsize)
 
void add_url_to_http_string (struct string *header, struct uri *uri, uri_component_T components)
 
static int revstr2num (char *start, char *end, int *value)
 
static int get_http_code (struct read_buffer *rb, int *code, struct http_version *version)
 
static int check_http_server_bugs (struct uri *uri, struct http_connection_info *http, char *head)
 
static void http_end_request (struct connection *conn, struct connection_state state, int notrunc)
 
static void http_send_header (struct socket *)
 
void http_protocol_handler (struct connection *conn)
 
void proxy_protocol_handler (struct connection *conn)
 
static void done_http_connection (struct connection *conn)
 connection.done points to this function if connection.info points to a struct http_connection_info.
 
struct http_connection_infoinit_http_connection_info (struct connection *conn, int major, int minor, int close)
 
static void accept_encoding_header (struct string *header)
 
static void send_more_post_data (struct socket *socket)
 
static char * decompress_data (struct connection *conn, char *data, int len, int *new_len)
 
static int is_line_in_buffer (struct read_buffer *rb)
 
static void read_http_data (struct socket *socket, struct read_buffer *rb)
 
static void read_more_http_data (struct connection *conn, struct read_buffer *rb, int already_got_anything)
 
static void read_http_data_done (struct connection *conn)
 
static int read_chunked_http_data (struct connection *conn, struct read_buffer *rb)
 
static int read_normal_http_data (struct connection *conn, struct read_buffer *rb)
 
static int get_header (struct read_buffer *rb)
 
static int check_http_authentication (struct connection *conn, struct uri *uri, char *header, const char *header_field)
 
void http_got_header (struct socket *socket, struct read_buffer *rb)
 

Variables

static struct auth_entry proxy_auth
 
static char * accept_charset = NULL
 
static union option_info http_options []
 
struct module http_protocol_module
 

Macro Definition Documentation

◆ CHUNK_DATA_END

#define CHUNK_DATA_END   -3

◆ CHUNK_SIZE

#define CHUNK_SIZE   -1

◆ CHUNK_ZERO_SIZE

#define CHUNK_ZERO_SIZE   -2

◆ connection_is_https_proxy

#define connection_is_https_proxy ( conn)     (IS_PROXY_URI((conn)->uri) && (conn)->proxied_uri->protocol == PROTOCOL_HTTPS)

◆ HTTP_0_9

#define HTTP_0_9 ( x)    ((x).major == 0 && (x).minor == 9)

◆ HTTP_1_0

#define HTTP_1_0 ( x)    ((x).major == 1 && (x).minor == 0)

◆ HTTP_1_1

#define HTTP_1_1 ( x)    ((x).major == 1 && (x).minor == 1)

◆ IS_PROXY_URI

#define IS_PROXY_URI ( x)    ((x)->protocol == PROTOCOL_PROXY)

◆ LEN_CHUNKED

#define LEN_CHUNKED   -2 /* == we get data in unknown number of chunks */

◆ LEN_FINISHED

#define LEN_FINISHED   0

◆ POST_BUFFER_SIZE

#define POST_BUFFER_SIZE   4096

◆ POST_HTTP_1_0

#define POST_HTTP_1_0 ( x)    ((x).major > 1 || ((x).major == 1 && (x).minor > 0))

◆ POST_HTTP_1_1

#define POST_HTTP_1_1 ( x)    ((x).major > 1 || ((x).major == 1 && (x).minor > 1))

◆ PRE_HTTP_1_0

#define PRE_HTTP_1_0 ( x)    ((x).major < 1)

◆ PRE_HTTP_1_1

#define PRE_HTTP_1_1 ( x)    (PRE_HTTP_1_0(x) || HTTP_1_0(x))

Function Documentation

◆ accept_encoding_header()

static void accept_encoding_header ( struct string * header)
static

◆ add_url_to_http_string()

void add_url_to_http_string ( struct string * header,
struct uri * uri,
uri_component_T components )

◆ check_http_authentication()

static int check_http_authentication ( struct connection * conn,
struct uri * uri,
char * header,
const char * header_field )
static

◆ check_http_server_bugs()

static int check_http_server_bugs ( struct uri * uri,
struct http_connection_info * http,
char * head )
static

◆ decompress_data()

static char * decompress_data ( struct connection * conn,
char * data,
int len,
int * new_len )
static

◆ done_http()

static void done_http ( struct module * mod)
static

◆ done_http_connection()

static void done_http_connection ( struct connection * conn)
static

connection.done points to this function if connection.info points to a struct http_connection_info.


◆ get_header()

static int get_header ( struct read_buffer * rb)
static

◆ get_http_code()

static int get_http_code ( struct read_buffer * rb,
int * code,
struct http_version * version )
static

◆ http_end_request()

static void http_end_request ( struct connection * conn,
struct connection_state state,
int notrunc )
static

◆ http_got_header()

void http_got_header ( struct socket * socket,
struct read_buffer * rb )

◆ http_protocol_handler()

void http_protocol_handler ( struct connection * conn)

◆ http_send_header()

static void http_send_header ( struct socket * socket)
static

◆ init_accept_charset()

static void init_accept_charset ( void )
static

◆ init_http_connection_info()

struct http_connection_info * init_http_connection_info ( struct connection * conn,
int major,
int minor,
int close )

◆ is_line_in_buffer()

static int is_line_in_buffer ( struct read_buffer * rb)
static

◆ proxy_protocol_handler()

void proxy_protocol_handler ( struct connection * conn)

◆ read_chunked_http_data()

static int read_chunked_http_data ( struct connection * conn,
struct read_buffer * rb )
static

◆ read_http_data()

static void read_http_data ( struct socket * socket,
struct read_buffer * rb )
static

◆ read_http_data_done()

static void read_http_data_done ( struct connection * conn)
static

◆ read_more_http_data()

static void read_more_http_data ( struct connection * conn,
struct read_buffer * rb,
int already_got_anything )
static

◆ read_normal_http_data()

static int read_normal_http_data ( struct connection * conn,
struct read_buffer * rb )
static

◆ revstr2num()

static int revstr2num ( char * start,
char * end,
int * value )
static

◆ send_more_post_data()

static void send_more_post_data ( struct socket * socket)
static

◆ subst_user_agent()

char * subst_user_agent ( char * fmt,
const char * version,
char * sysname,
char * termsize )

Variable Documentation

◆ accept_charset

char* accept_charset = NULL
static

◆ http_options

union option_info http_options[]
static

◆ http_protocol_module

struct module http_protocol_module
Initial value:
N_("HTTP"),
)
#define NULL
Definition explodename.c:35
#define N_(msg)
Definition libintl.h:25
static union option_info http_options[]
Definition http.c:74
static void done_http(struct module *mod)
Definition http.c:272
#define struct_module(name, options, hooks, submods, data, init, done, getname)
Definition module.h:47

◆ proxy_auth

struct auth_entry proxy_auth
static