iPXE
|
Hyper Text Transfer Protocol (HTTP) core functionality. More...
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <byteswap.h>
#include <errno.h>
#include <ctype.h>
#include <assert.h>
#include <ipxe/uri.h>
#include <ipxe/refcnt.h>
#include <ipxe/iobuf.h>
#include <ipxe/xfer.h>
#include <ipxe/open.h>
#include <ipxe/process.h>
#include <ipxe/retry.h>
#include <ipxe/timer.h>
#include <ipxe/linebuf.h>
#include <ipxe/xferbuf.h>
#include <ipxe/blockdev.h>
#include <ipxe/acpi.h>
#include <ipxe/version.h>
#include <ipxe/params.h>
#include <ipxe/profile.h>
#include <ipxe/vsprintf.h>
#include <ipxe/errortab.h>
#include <ipxe/efi/efi_path.h>
#include <ipxe/http.h>
Go to the source code of this file.
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static int | http_rx_linebuf (struct http_transaction *http, struct io_buffer *iobuf, struct line_buffer *linebuf) |
Handle received HTTP line-buffered data. More... | |
char * | http_token (char **line, char **value) |
Get HTTP response token. More... | |
static void | http_free (struct refcnt *refcnt) |
Free HTTP transaction. More... | |
static void | http_close (struct http_transaction *http, int rc) |
Close HTTP transaction. More... | |
static void | http_close_error (struct http_transaction *http, int rc) |
Close HTTP transaction with error (even if none specified) More... | |
static void | http_reopen (struct http_transaction *http) |
Reopen stale HTTP connection. More... | |
static void | http_expired (struct retry_timer *timer, int over __unused) |
Handle retry timer expiry. More... | |
static void | http_step (struct http_transaction *http) |
HTTP transmit process. More... | |
static int | http_conn_deliver (struct http_transaction *http, struct io_buffer *iobuf, struct xfer_metadata *meta __unused) |
Handle received HTTP data. More... | |
static void | http_conn_close (struct http_transaction *http, int rc) |
Handle server connection close. More... | |
static int | http_content_deliver (struct http_transaction *http, struct io_buffer *iobuf, struct xfer_metadata *meta) |
Handle received content-decoded data. More... | |
static struct xfer_buffer * | http_content_buffer (struct http_transaction *http) |
Get underlying data transfer buffer. More... | |
__weak int | http_block_read (struct http_transaction *http __unused, struct interface *data __unused, uint64_t lba __unused, unsigned int count __unused, userptr_t buffer __unused, size_t len __unused) |
Read from block device (when HTTP block device support is not present) More... | |
__weak int | http_block_read_capacity (struct http_transaction *http __unused, struct interface *data __unused) |
Read block device capacity (when HTTP block device support is not present) More... | |
static EFI_DEVICE_PATH_PROTOCOL * | http_efi_describe (struct http_transaction *http) |
Describe as an EFI device path. More... | |
int | http_open (struct interface *xfer, struct http_method *method, struct uri *uri, struct http_request_range *range, struct http_request_content *content) |
Open HTTP transaction. More... | |
static int | http_redirect (struct http_transaction *http, const char *location) |
Redirect HTTP transaction. More... | |
static int | http_transfer_complete (struct http_transaction *http) |
Handle successful transfer completion. More... | |
static int | http_format_headers (struct http_transaction *http, char *buf, size_t len) |
Construct HTTP request headers. More... | |
static int | http_format_host (struct http_transaction *http, char *buf, size_t len) |
Construct HTTP "Host" header. More... | |
static int | http_format_user_agent (struct http_transaction *http __unused, char *buf, size_t len) |
Construct HTTP "User-Agent" header. More... | |
static int | http_format_connection (struct http_transaction *http __unused, char *buf, size_t len) |
Construct HTTP "Connection" header. More... | |
static int | http_format_range (struct http_transaction *http, char *buf, size_t len) |
Construct HTTP "Range" header. More... | |
static int | http_format_content_type (struct http_transaction *http, char *buf, size_t len) |
Construct HTTP "Content-Type" header. More... | |
static int | http_format_content_length (struct http_transaction *http, char *buf, size_t len) |
Construct HTTP "Content-Length" header. More... | |
static int | http_format_accept_encoding (struct http_transaction *http, char *buf, size_t len) |
Construct HTTP "Accept-Encoding" header. More... | |
static int | http_tx_request (struct http_transaction *http) |
Transmit request. More... | |
static int | http_parse_status (struct http_transaction *http, char *line) |
Parse HTTP status line. More... | |
static int | http_parse_header (struct http_transaction *http, char *line) |
Parse HTTP header. More... | |
static int | http_parse_headers (struct http_transaction *http) |
Parse HTTP response headers. More... | |
static int | http_parse_location (struct http_transaction *http, char *line) |
Parse HTTP "Location" header. More... | |
static int | http_parse_transfer_encoding (struct http_transaction *http, char *line) |
Parse HTTP "Transfer-Encoding" header. More... | |
static int | http_parse_connection (struct http_transaction *http, char *line) |
Parse HTTP "Connection" header. More... | |
static int | http_parse_content_length (struct http_transaction *http, char *line) |
Parse HTTP "Content-Length" header. More... | |
static int | http_parse_content_encoding (struct http_transaction *http, char *line) |
Parse HTTP "Content-Encoding" header. More... | |
static int | http_parse_retry_after (struct http_transaction *http, char *line) |
Parse HTTP "Retry-After" header. More... | |
static int | http_rx_headers (struct http_transaction *http, struct io_buffer **iobuf) |
Handle received HTTP headers. More... | |
static int | http_init_transfer_identity (struct http_transaction *http) |
Initialise transfer encoding. More... | |
static int | http_rx_transfer_identity (struct http_transaction *http, struct io_buffer **iobuf) |
Handle received data. More... | |
static void | http_close_transfer_identity (struct http_transaction *http, int rc) |
Handle server connection close. More... | |
static int | http_init_transfer_chunked (struct http_transaction *http) |
Initialise transfer encoding. More... | |
static int | http_rx_chunk_len (struct http_transaction *http, struct io_buffer **iobuf) |
Handle received chunk length. More... | |
static int | http_rx_chunk_data (struct http_transaction *http, struct io_buffer **iobuf) |
Handle received chunk data. More... | |
static int | http_rx_transfer_chunked (struct http_transaction *http, struct io_buffer **iobuf) |
Handle received chunked data. More... | |
static int | http_rx_trailers (struct http_transaction *http, struct io_buffer **iobuf) |
Handle received HTTP trailer. More... | |
static size_t | http_form_params (struct parameters *params, char *buf, size_t len) |
Construct HTTP form parameter list. More... | |
int | http_open_uri (struct interface *xfer, struct uri *uri) |
Open HTTP transaction for simple URI. More... | |
REQUIRING_SYMBOL (http_open) | |
REQUIRE_OBJECT (config_http) | |
Variables | |
static struct profiler http_rx_profiler | __profiler = { .name = "http.rx" } |
Receive profiler. More... | |
struct errortab http_errors [] | __errortab |
Human-readable error messages. More... | |
static struct http_state | http_request |
HTTP request state. More... | |
static struct http_state | http_headers |
HTTP response headers state. More... | |
static struct http_state | http_trailers |
HTTP response trailers state. More... | |
static struct http_transfer_encoding | http_transfer_identity |
Identity transfer encoding. More... | |
struct http_method | http_head |
HTTP HEAD method. More... | |
struct http_method | http_get |
HTTP GET method. More... | |
struct http_method | http_post |
HTTP POST method. More... | |
static struct interface_operation | http_xfer_operations [] |
HTTP data transfer interface operations. More... | |
static struct interface_descriptor | http_xfer_desc |
HTTP data transfer interface descriptor. More... | |
static struct interface_operation | http_content_operations [] |
HTTP content-decoded interface operations. More... | |
static struct interface_descriptor | http_content_desc |
HTTP content-decoded interface descriptor. More... | |
static struct interface_operation | http_transfer_operations [] |
HTTP transfer-decoded interface operations. More... | |
static struct interface_descriptor | http_transfer_desc |
HTTP transfer-decoded interface descriptor. More... | |
static struct interface_operation | http_conn_operations [] |
HTTP server connection interface operations. More... | |
static struct interface_descriptor | http_conn_desc |
HTTP server connection interface descriptor. More... | |
static struct process_descriptor | http_process_desc |
HTTP process descriptor. More... | |
struct http_request_header http_request_host | __http_request_header |
HTTP "Host" header ". More... | |
struct http_response_header http_response_location | __http_response_header |
HTTP "Location" header. More... | |
struct http_transfer_encoding http_transfer_chunked | __http_transfer_encoding |
Chunked transfer encoding. More... | |
Hyper Text Transfer Protocol (HTTP) core functionality.
Definition in file httpcore.c.
#define EACCES_401 __einfo_error ( EINFO_EACCES_401 ) |
Definition at line 63 of file httpcore.c.
#define EINFO_EACCES_401 __einfo_uniqify ( EINFO_EACCES, 0x01, "HTTP 401 Unauthorized" ) |
Definition at line 64 of file httpcore.c.
#define EINVAL_STATUS __einfo_error ( EINFO_EINVAL_STATUS ) |
Definition at line 66 of file httpcore.c.
#define EINFO_EINVAL_STATUS __einfo_uniqify ( EINFO_EINVAL, 0x01, "Invalid status line" ) |
Definition at line 67 of file httpcore.c.
#define EINVAL_HEADER __einfo_error ( EINFO_EINVAL_HEADER ) |
Definition at line 69 of file httpcore.c.
#define EINFO_EINVAL_HEADER __einfo_uniqify ( EINFO_EINVAL, 0x02, "Invalid header" ) |
Definition at line 70 of file httpcore.c.
#define EINVAL_CONTENT_LENGTH __einfo_error ( EINFO_EINVAL_CONTENT_LENGTH ) |
Definition at line 72 of file httpcore.c.
#define EINFO_EINVAL_CONTENT_LENGTH __einfo_uniqify ( EINFO_EINVAL, 0x03, "Invalid content length" ) |
Definition at line 73 of file httpcore.c.
#define EINVAL_CHUNK_LENGTH __einfo_error ( EINFO_EINVAL_CHUNK_LENGTH ) |
Definition at line 75 of file httpcore.c.
#define EINFO_EINVAL_CHUNK_LENGTH __einfo_uniqify ( EINFO_EINVAL, 0x04, "Invalid chunk length" ) |
Definition at line 76 of file httpcore.c.
#define EIO_OTHER __einfo_error ( EINFO_EIO_OTHER ) |
Definition at line 78 of file httpcore.c.
#define EINFO_EIO_OTHER __einfo_uniqify ( EINFO_EIO, 0x01, "Unrecognised HTTP response code" ) |
Definition at line 79 of file httpcore.c.
#define EIO_CONTENT_LENGTH __einfo_error ( EINFO_EIO_CONTENT_LENGTH ) |
Definition at line 81 of file httpcore.c.
#define EINFO_EIO_CONTENT_LENGTH __einfo_uniqify ( EINFO_EIO, 0x02, "Content length mismatch" ) |
Definition at line 82 of file httpcore.c.
#define EIO_4XX __einfo_error ( EINFO_EIO_4XX ) |
Definition at line 84 of file httpcore.c.
#define EINFO_EIO_4XX __einfo_uniqify ( EINFO_EIO, 0x04, "HTTP 4xx Client Error" ) |
Definition at line 85 of file httpcore.c.
#define EIO_5XX __einfo_error ( EINFO_EIO_5XX ) |
Definition at line 87 of file httpcore.c.
#define EINFO_EIO_5XX __einfo_uniqify ( EINFO_EIO, 0x05, "HTTP 5xx Server Error" ) |
Definition at line 88 of file httpcore.c.
#define ENOENT_404 __einfo_error ( EINFO_ENOENT_404 ) |
Definition at line 90 of file httpcore.c.
#define EINFO_ENOENT_404 __einfo_uniqify ( EINFO_ENOENT, 0x01, "Not found" ) |
Definition at line 91 of file httpcore.c.
#define ENOTSUP_CONNECTION __einfo_error ( EINFO_ENOTSUP_CONNECTION ) |
Definition at line 93 of file httpcore.c.
#define EINFO_ENOTSUP_CONNECTION __einfo_uniqify ( EINFO_ENOTSUP, 0x01, "Unsupported connection header" ) |
Definition at line 94 of file httpcore.c.
#define ENOTSUP_TRANSFER __einfo_error ( EINFO_ENOTSUP_TRANSFER ) |
Definition at line 96 of file httpcore.c.
#define EINFO_ENOTSUP_TRANSFER __einfo_uniqify ( EINFO_ENOTSUP, 0x02, "Unsupported transfer encoding" ) |
Definition at line 97 of file httpcore.c.
#define EPERM_403 __einfo_error ( EINFO_EPERM_403 ) |
Definition at line 99 of file httpcore.c.
#define EINFO_EPERM_403 __einfo_uniqify ( EINFO_EPERM, 0x01, "HTTP 403 Forbidden" ) |
Definition at line 100 of file httpcore.c.
#define EPROTO_UNSOLICITED __einfo_error ( EINFO_EPROTO_UNSOLICITED ) |
Definition at line 102 of file httpcore.c.
#define EINFO_EPROTO_UNSOLICITED __einfo_uniqify ( EINFO_EPROTO, 0x01, "Unsolicited data" ) |
Definition at line 103 of file httpcore.c.
#define HTTP_RETRY_SECONDS 5 |
Retry delay used when we cannot understand the Retry-After header.
Definition at line 107 of file httpcore.c.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
static |
Handle received HTTP line-buffered data.
http | HTTP transaction |
iobuf | I/O buffer |
linebuf | Line buffer |
rc | Return status code |
Definition at line 164 of file httpcore.c.
References io_buffer::data, DBGC, iob_len(), iob_pull, line_buffer(), rc, and strerror().
Referenced by http_rx_chunk_len(), http_rx_headers(), and http_rx_trailers().
char* http_token | ( | char ** | line, |
char ** | value | ||
) |
Get HTTP response token.
line | Line position |
value | Token value to fill in (if any) |
token | Token, or NULL |
Definition at line 192 of file httpcore.c.
References c, isspace(), NULL, token, and value.
Referenced by http_parse_connection(), http_parse_digest_auth(), http_parse_status(), and http_parse_www_authenticate().
|
static |
Free HTTP transaction.
refcnt | Reference count |
Definition at line 263 of file httpcore.c.
References container_of, empty_line_buffer(), free, http_response::headers, http_transaction::linebuf, http_transaction::response, http_transaction::uri, and uri_put().
Referenced by http_open().
|
static |
Close HTTP transaction.
http | HTTP transaction |
rc | Reason for close |
Definition at line 279 of file httpcore.c.
References http_transaction::conn, http_transaction::content, intfs_shutdown(), NULL, http_transaction::process, process_del(), rc, stop_timer(), http_transaction::timer, http_transaction::transfer, and http_transaction::xfer.
Referenced by http_close_error(), http_close_transfer_identity(), http_conn_deliver(), http_open(), http_reopen(), http_step(), and http_transfer_complete().
|
static |
Close HTTP transaction with error (even if none specified)
http | HTTP transaction |
rc | Reason for close |
Definition at line 298 of file httpcore.c.
References EPIPE, http_close(), and rc.
|
static |
Reopen stale HTTP connection.
http | HTTP transaction |
Definition at line 309 of file httpcore.c.
References http_transaction::conn, DBGC, ECANCELED, http_close(), http_connect(), http_request, intf_restart(), http_transaction::process, process_add(), rc, http_transaction::state, strerror(), and http_transaction::uri.
Referenced by http_expired(), and http_transfer_complete().
|
static |
Handle retry timer expiry.
timer | Retry timer |
over | Failure indicator |
Definition at line 340 of file httpcore.c.
References container_of, and http_reopen().
Referenced by http_open().
|
static |
HTTP transmit process.
http | HTTP transaction |
Definition at line 353 of file httpcore.c.
References http_transaction::conn, http_close(), rc, http_transaction::state, http_state::tx, http_transaction::xfer, xfer_window(), and xfer_window_changed().
|
static |
Handle received HTTP data.
http | HTTP transaction |
iobuf | I/O buffer |
meta | Transfer metadata |
rc | Return status code |
This function takes ownership of the I/O buffer.
Definition at line 391 of file httpcore.c.
References DBGC, EPROTO_UNSOLICITED, free_iob(), http_close(), iob_len(), profile_start(), profile_stop(), rc, http_state::rx, and http_transaction::state.
|
static |
Handle server connection close.
http | HTTP transaction |
rc | Reason for close |
Definition at line 430 of file httpcore.c.
References assert(), http_state::close, http_transaction::conn, intf_restart(), NULL, rc, and http_transaction::state.
|
static |
Handle received content-decoded data.
http | HTTP transaction |
iobuf | I/O buffer |
meta | Data transfer metadata |
Definition at line 450 of file httpcore.c.
References free_iob(), iob_disown, meta(), profile_start(), profile_stop(), http_response::rc, rc, http_transaction::response, http_transaction::xfer, and xfer_deliver().
|
static |
Get underlying data transfer buffer.
http | HTTP transaction |
xferbuf | Data transfer buffer, or NULL on error |
Definition at line 480 of file httpcore.c.
References NULL, http_response::rc, http_transaction::response, http_transaction::xfer, and xfer_buffer().
__weak int http_block_read | ( | struct http_transaction *http | __unused, |
struct interface *data | __unused, | ||
uint64_t lba | __unused, | ||
unsigned int count | __unused, | ||
userptr_t buffer | __unused, | ||
size_t len | __unused | ||
) |
Read from block device (when HTTP block device support is not present)
http | HTTP transaction |
data | Data interface |
lba | Starting logical block address |
count | Number of logical blocks |
buffer | Data buffer |
len | Length of data buffer |
rc | Return status code |
Definition at line 503 of file httpcore.c.
References ENOTSUP.
__weak int http_block_read_capacity | ( | struct http_transaction *http | __unused, |
struct interface *data | __unused | ||
) |
Read block device capacity (when HTTP block device support is not present)
control | Control interface |
data | Data interface |
rc | Return status code |
Definition at line 518 of file httpcore.c.
References ENOTSUP.
|
static |
Describe as an EFI device path.
http | HTTP transaction |
path | EFI device path, or NULL on error |
Definition at line 531 of file httpcore.c.
References efi_uri_path(), and http_transaction::uri.
int http_open | ( | struct interface * | xfer, |
struct http_method * | method, | ||
struct uri * | uri, | ||
struct http_request_range * | range, | ||
struct http_request_content * | content | ||
) |
Open HTTP transaction.
xfer | Data transfer interface |
method | Request method |
uri | Request URI |
range | Content range (if any) |
content | Request content (if any) |
rc | Return status code |
Definition at line 602 of file httpcore.c.
References http_transaction::conn, http_request::content, http_transaction::content, http_request_content::data, DBGC, DBGC2, ENOMEM, uri::epath, uri::equery, format_uri(), uri::host, http_request::host, http_close(), http_conn_desc, http_connect(), http_content_desc, http_expired(), http_free(), http_process_desc, http_request, http_transfer_desc, http_xfer_desc, intf_init(), intf_plug_plug(), http_request_content::len, memcpy(), memset(), method, http_request::method, NULL, uri::port, http_transaction::process, process_init(), range, http_request::range, rc, ref_init, ref_put, http_transaction::refcnt, http_transaction::request, uri::scheme, http_transaction::state, strerror(), http_transaction::timer, http_transaction::transfer, http_request_content::type, http_request::uri, http_transaction::uri, uri_get(), http_transaction::xfer, and zalloc().
Referenced by http_block_read(), http_block_read_capacity(), http_open_uri(), peerblk_raw_open(), and peerblk_retrieval_open().
|
static |
Redirect HTTP transaction.
http | HTTP transaction |
location | New location |
rc | Return status code |
Definition at line 697 of file httpcore.c.
References DBGC, DBGC2, ENOMEM, LOCATION_URI, parse_uri(), rc, resolve_uri(), strerror(), http_transaction::uri, uri_put(), http_transaction::xfer, and xfer_redirect().
Referenced by http_transfer_complete().
|
static |
Handle successful transfer completion.
http | HTTP transaction |
rc | Return status code |
Definition at line 741 of file httpcore.c.
References assert(), http_request_auth::auth, http_request::auth, http_response_auth::auth, http_response::auth, http_authentication::authenticate, http_transaction::conn, http_transaction::content, DBGC, DBGC2, http_response::flags, http_close(), http_redirect(), http_reopen(), HTTP_RESPONSE_KEEPALIVE, HTTP_RESPONSE_RETRY, intf_plug_plug(), intf_restart(), intf_shutdown(), intfs_restart(), http_transaction::len, http_response::location, http_authentication::name, NULL, pool_recycle(), http_response::rc, rc, http_transaction::remaining, http_transaction::request, http_transaction::response, http_response::retry_after, start_timer_fixed(), http_transaction::state, strerror(), TICKS_PER_SEC, http_transaction::timer, and http_transaction::transfer.
Referenced by http_close_transfer_identity(), http_init_transfer_identity(), http_rx_headers(), http_rx_trailers(), and http_rx_transfer_identity().
|
static |
Construct HTTP request headers.
http | HTTP transaction |
buf | Buffer |
len | Length of buffer |
len | Length, or negative error |
Definition at line 832 of file httpcore.c.
References DBGC2, for_each_param, for_each_table_entry, header, HTTP_REQUEST_HEADERS, len, http_request::method, http_method::name, NULL, param, PARAMETER_HEADER, uri::params, rc, http_transaction::request, ssnprintf(), http_request::uri, and http_transaction::uri.
Referenced by http_tx_request().
|
static |
Construct HTTP "Host" header.
http | HTTP transaction |
buf | Buffer |
len | Length of buffer |
len | Length of header value, or negative error |
Definition at line 906 of file httpcore.c.
References http_request::host, len, http_transaction::request, and snprintf().
|
static |
Construct HTTP "User-Agent" header.
http | HTTP transaction |
buf | Buffer |
len | Length of buffer |
len | Length of header value, or negative error |
Definition at line 927 of file httpcore.c.
References len, product_version, and snprintf().
|
static |
Construct HTTP "Connection" header.
http | HTTP transaction |
buf | Buffer |
len | Length of buffer |
len | Length of header value, or negative error |
Definition at line 948 of file httpcore.c.
References len, and snprintf().
|
static |
Construct HTTP "Range" header.
http | HTTP transaction |
buf | Buffer |
len | Length of buffer |
len | Length of header value, or negative error |
Definition at line 969 of file httpcore.c.
References len, http_request_range::len, http_request::range, http_transaction::request, snprintf(), and http_request_range::start.
|
static |
Construct HTTP "Content-Type" header.
http | HTTP transaction |
buf | Buffer |
len | Length of buffer |
len | Length of header value, or negative error |
Definition at line 997 of file httpcore.c.
References http_request::content, len, http_transaction::request, snprintf(), and http_request_content::type.
|
static |
Construct HTTP "Content-Length" header.
http | HTTP transaction |
buf | Buffer |
len | Length of buffer |
len | Length of header value, or negative error |
Definition at line 1022 of file httpcore.c.
References http_request::content, len, http_request_content::len, http_transaction::request, and snprintf().
|
static |
Construct HTTP "Accept-Encoding" header.
http | HTTP transaction |
buf | Buffer |
len | Length of buffer |
len | Length of header value, or negative error |
Definition at line 1047 of file httpcore.c.
References for_each_table_entry, HTTP_CONTENT_ENCODINGS, len, http_content_encoding::name, ssnprintf(), and http_content_encoding::supported.
|
static |
Transmit request.
http | HTTP transaction |
rc | Return status code |
Definition at line 1077 of file httpcore.c.
References alloc_iob(), assert(), http_transaction::conn, http_request::content, http_request_content::data, DBGC, empty_line_buffer(), ENOMEM, free_iob(), http_response::headers, http_format_headers(), http_headers, iob_disown, iob_put, len, http_request_content::len, memcpy(), memset(), NULL, rc, http_transaction::request, http_transaction::response, http_transaction::state, strerror(), and xfer_deliver_iob().
|
static |
Parse HTTP status line.
http | HTTP transaction |
line | Status line |
rc | Return status code |
Definition at line 1150 of file httpcore.c.
References DBGC, DBGC2, EACCES_401, EINVAL_STATUS, EIO_4XX, EIO_5XX, EIO_OTHER, ENOENT_404, EPERM_403, EXDEV, http_response::flags, HTTP_RESPONSE_KEEPALIVE, http_token(), NULL, http_response::rc, http_transaction::response, status, http_response::status, strncmp(), strtoul(), and version.
Referenced by http_parse_headers().
|
static |
Parse HTTP header.
http | HTTP transaction |
line | Header line |
rc | Return status code |
Definition at line 1226 of file httpcore.c.
References DBGC, DBGC2, EINVAL_HEADER, for_each_table_entry, header, HTTP_RESPONSE_HEADERS, isspace(), name, strcasecmp(), and strchr().
Referenced by http_parse_headers().
|
static |
Parse HTTP response headers.
http | HTTP transaction |
rc | Return status code |
Definition at line 1262 of file httpcore.c.
References assert(), line_buffer::data, http_response::headers, http_parse_header(), http_parse_status(), next, NULL, rc, http_transaction::response, and strlen().
Referenced by http_rx_headers().
|
static |
Parse HTTP "Location" header.
http | HTTP transaction |
line | Remaining header line |
rc | Return status code |
Definition at line 1300 of file httpcore.c.
References http_response::location, and http_transaction::response.
|
static |
Parse HTTP "Transfer-Encoding" header.
http | HTTP transaction |
line | Remaining header line |
rc | Return status code |
Definition at line 1320 of file httpcore.c.
References DBGC, http_response_transfer::encoding, ENOTSUP_TRANSFER, for_each_table_entry, HTTP_TRANSFER_ENCODINGS, http_transfer_encoding::name, http_transaction::response, strcasecmp(), and http_response::transfer.
|
static |
Parse HTTP "Connection" header.
http | HTTP transaction |
line | Remaining header line |
rc | Return status code |
Definition at line 1351 of file httpcore.c.
References http_response::flags, HTTP_RESPONSE_KEEPALIVE, http_token(), NULL, http_transaction::response, strcasecmp(), and token.
|
static |
Parse HTTP "Content-Length" header.
http | HTTP transaction |
line | Remaining header line |
rc | Return status code |
Definition at line 1378 of file httpcore.c.
References http_response::content, DBGC, EINVAL_CONTENT_LENGTH, http_response::flags, HTTP_RESPONSE_CONTENT_LEN, http_response_content::len, http_transaction::response, and strtoul().
|
static |
Parse HTTP "Content-Encoding" header.
http | HTTP transaction |
line | Remaining header line |
rc | Return status code |
Definition at line 1410 of file httpcore.c.
References http_response::content, DBGC, http_response_content::encoding, for_each_table_entry, HTTP_CONTENT_ENCODINGS, http_content_encoding::name, http_transaction::response, strcasecmp(), and http_content_encoding::supported.
|
static |
Parse HTTP "Retry-After" header.
http | HTTP transaction |
line | Remaining header line |
rc | Return status code |
Definition at line 1451 of file httpcore.c.
References DBGC, http_response::flags, HTTP_RESPONSE_RETRY, HTTP_RETRY_SECONDS, http_transaction::response, http_response::retry_after, and strtoul().
|
static |
Handle received HTTP headers.
http | HTTP transaction |
iobuf | I/O buffer (may be claimed) |
rc | Return status code |
Definition at line 1487 of file httpcore.c.
References buffered_line(), http_response::content, DBGC, http_response_transfer::encoding, http_response_content::encoding, http_response::headers, http_head, http_parse_headers(), http_rx_linebuf(), http_transfer_complete(), http_transfer_identity, http_transfer_encoding::init, http_content_encoding::init, http_response_content::len, http_request::method, http_transfer_encoding::name, http_content_encoding::name, NULL, rc, http_transaction::request, http_transaction::response, http_transaction::state, http_transfer_encoding::state, strerror(), http_response::transfer, http_transaction::transfer, and xfer_seek().
|
static |
Initialise transfer encoding.
http | HTTP transaction |
rc | Return status code |
Definition at line 1566 of file httpcore.c.
References http_response::content, http_response::flags, HTTP_RESPONSE_CONTENT_LEN, http_transfer_complete(), http_response_content::len, rc, and http_transaction::response.
|
static |
Handle received data.
http | HTTP transaction |
iobuf | I/O buffer (may be claimed) |
rc | Return status code |
Definition at line 1585 of file httpcore.c.
References http_response::content, DBGC, EIO_CONTENT_LENGTH, http_response::flags, HTTP_RESPONSE_CONTENT_LEN, http_transfer_complete(), iob_disown, iob_len(), len, http_response_content::len, http_transaction::len, rc, http_transaction::response, http_transaction::transfer, and xfer_deliver_iob().
|
static |
Handle server connection close.
http | HTTP transaction |
rc | Reason for close |
Definition at line 1624 of file httpcore.c.
References DBGC, EIO_CONTENT_LENGTH, http_response::flags, http_close(), HTTP_RESPONSE_CONTENT_LEN, http_transfer_complete(), rc, and http_transaction::response.
|
static |
Initialise transfer encoding.
http | HTTP transaction |
rc | Return status code |
Definition at line 1674 of file httpcore.c.
References assert(), line_buffer::len, http_transaction::linebuf, and http_transaction::remaining.
|
static |
Handle received chunk length.
http | HTTP transaction |
iobuf | I/O buffer (may be claimed) |
rc | Return status code |
Definition at line 1690 of file httpcore.c.
References buffered_line(), DBGC, EINVAL_CHUNK_LENGTH, empty_line_buffer(), http_rx_linebuf(), http_trailers, len, http_transaction::len, http_transaction::linebuf, NULL, rc, http_transaction::remaining, http_transaction::state, strtoul(), http_transaction::transfer, and xfer_seek().
Referenced by http_rx_transfer_chunked().
|
static |
Handle received chunk data.
http | HTTP transaction |
iobuf | I/O buffer (may be claimed) |
rc | Return status code |
Definition at line 1736 of file httpcore.c.
References alloc_iob(), assert(), ENOMEM, iob_disown, iob_len(), iob_pull, iob_put, iob_unput, len, http_transaction::len, memcpy(), NULL, rc, http_transaction::remaining, http_transaction::transfer, and xfer_deliver_iob().
Referenced by http_rx_transfer_chunked().
|
static |
Handle received chunked data.
http | HTTP transaction |
iobuf | I/O buffer (may be claimed) |
rc | Return status code |
Definition at line 1801 of file httpcore.c.
References http_rx_chunk_data(), http_rx_chunk_len(), and http_transaction::remaining.
|
static |
Handle received HTTP trailer.
http | HTTP transaction |
iobuf | I/O buffer (may be claimed) |
rc | Return status code |
Definition at line 1836 of file httpcore.c.
References buffered_line(), empty_line_buffer(), http_rx_linebuf(), http_transfer_complete(), http_transaction::linebuf, NULL, and rc.
|
static |
Construct HTTP form parameter list.
params | Parameter list |
buf | Buffer to contain HTTP POST parameters |
len | Length of buffer |
len | Length of parameter list (excluding terminating NUL) |
Definition at line 1881 of file httpcore.c.
References for_each_param, len, param, PARAMETER_FORM, and uri_encode_string().
Referenced by http_open_uri().
Open HTTP transaction for simple URI.
xfer | Data transfer interface |
uri | Request URI |
rc | Return status code |
Definition at line 1938 of file httpcore.c.
References assert(), data, http_request_content::data, ENOMEM, free, http_form_params(), http_get, http_open(), http_post, len, http_request_content::len, method, NULL, uri::params, rc, type, http_request_content::type, and zalloc().
REQUIRING_SYMBOL | ( | http_open | ) |
REQUIRE_OBJECT | ( | config_http | ) |
struct errortab http_errors [] __errortab |
|
static |
HTTP request state.
Definition at line 122 of file httpcore.c.
Referenced by http_open(), and http_reopen().
|
static |
HTTP response headers state.
Definition at line 123 of file httpcore.c.
Referenced by http_tx_request().
|
static |
HTTP response trailers state.
Definition at line 124 of file httpcore.c.
Referenced by http_rx_chunk_len().
|
static |
Identity transfer encoding.
Definition at line 125 of file httpcore.c.
Referenced by http_rx_headers().
struct http_method http_head |
HTTP HEAD method.
Definition at line 135 of file httpcore.c.
Referenced by http_block_read_capacity(), and http_rx_headers().
struct http_method http_get |
HTTP GET method.
Definition at line 140 of file httpcore.c.
Referenced by http_block_read(), http_open_uri(), and peerblk_raw_open().
struct http_method http_post |
HTTP POST method.
Definition at line 145 of file httpcore.c.
Referenced by http_open_uri(), and peerblk_retrieval_open().
|
static |
HTTP data transfer interface operations.
Definition at line 537 of file httpcore.c.
|
static |
HTTP data transfer interface descriptor.
Definition at line 548 of file httpcore.c.
Referenced by http_open().
|
static |
HTTP content-decoded interface operations.
Definition at line 553 of file httpcore.c.
|
static |
HTTP content-decoded interface descriptor.
Definition at line 561 of file httpcore.c.
Referenced by http_open().
|
static |
HTTP transfer-decoded interface operations.
Definition at line 566 of file httpcore.c.
|
static |
HTTP transfer-decoded interface descriptor.
Definition at line 571 of file httpcore.c.
Referenced by http_open().
|
static |
HTTP server connection interface operations.
Definition at line 576 of file httpcore.c.
|
static |
HTTP server connection interface descriptor.
Definition at line 584 of file httpcore.c.
Referenced by http_open().
|
static |
HTTP process descriptor.
Definition at line 589 of file httpcore.c.
Referenced by http_open().
struct http_request_header http_request_accept_encoding __http_request_header |
HTTP "Host" header ".
HTTP "Accept-Encoding" header.
HTTP "Content-Length" header.
HTTP "Content-Type" header.
HTTP "Range" header.
HTTP "Connection" header.
HTTP "User-Agent" header.
Definition at line 914 of file httpcore.c.
struct http_response_header http_response_retry_after __http_response_header |
HTTP "Location" header.
HTTP "Retry-After" header.
HTTP "Content-Encoding" header.
HTTP "Content-Length" header.
HTTP "Connection" header.
HTTP "Transfer-Encoding" header.
Definition at line 1308 of file httpcore.c.
struct http_transfer_encoding http_transfer_chunked __http_transfer_encoding |
Chunked transfer encoding.
Definition at line 1813 of file httpcore.c.