![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
HTTP/1.1 response builder and writer (see n_http_response.h). More...
#include "nilorea/n_http_response.h"#include "nilorea/n_common.h"#include "nilorea/n_log.h"#include "nilorea/n_str.h"#include "nilorea/n_time.h"#include <stdio.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <unistd.h>Go to the source code of this file.
Macros | |
| #define | N_HTTP_RESPONSE_CHUNK 65536 |
Functions | |
| static int | _resp_bodiless (int status) |
| static int | _resp_cat (N_STR **h, const char *str) |
| static void | _resp_drop_body (N_HTTP_RESP *r) |
| static int | _resp_ieq (const char *a, const char *b) |
| static int | _resp_lc (int c) |
| static int | _resp_num (const char *s, size_t n, long long *v) |
| static ssize_t | _resp_pread (int fd, char *buf, size_t len, long long offset) |
| static int | _resp_token (const char *s) |
| static int | _resp_write_all (n_http_write_fn fn, void *ctx, const char *buf, size_t len) |
| N_HTTP_RANGE | n_http_parse_range (const char *value, size_t len, long long total, long long *first, long long *last) |
| interpret a single-range Range header for a body of total bytes | |
| int | n_http_response_add_header (N_HTTP_RESP *r, const char *name, const char *value) |
| add a header line after validating name and value | |
| int | n_http_response_append (N_HTTP_RESP *r, const void *data, size_t len) |
| append bytes to the memory body (drops a file body) | |
| long long | n_http_response_body_length (const N_HTTP_RESP *r) |
| body length the response declares, 0 for a bodiless status | |
| int | n_http_response_file (N_HTTP_RESP *r, int fd, long long offset, long long length) |
| use a file range as the body; the response owns fd from now on | |
| void | n_http_response_free (N_HTTP_RESP **r) |
| free a response (closing its file body) and set *r to NULL | |
| const char * | n_http_response_get_header (const N_HTTP_RESP *r, const char *name) |
| value of the first header of that name (ASCII case-insensitive) | |
| int | n_http_response_head (const N_HTTP_RESP *r, N_STR **out) |
| append the status line and headers, through the blank line | |
| N_HTTP_RESP * | n_http_response_new (int status) |
| new response with a status, keep-alive off, HTTP/1.1 | |
| size_t | n_http_response_remove_header (N_HTTP_RESP *r, const char *name) |
| remove every header of that name (ASCII case-insensitive) | |
| int | n_http_response_set_connection (N_HTTP_RESP *r, int keep_alive, int version_minor, int head_only) |
| connection handling for this response | |
| int | n_http_response_set_header (N_HTTP_RESP *r, const char *name, const char *value) |
| set a header: remove every header of that name, then add it | |
| int | n_http_response_set_status (N_HTTP_RESP *r, int status) |
| change the status code | |
| int | n_http_response_write (const N_HTTP_RESP *r, n_http_write_fn fn, void *ctx) |
| write the whole response (head, then body unless HEAD or bodiless) | |
| const char * | n_http_status_reason (int status) |
| reason phrase of a status code, a class phrase for an unlisted one | |
HTTP/1.1 response builder and writer (see n_http_response.h).
Definition in file n_http_response.c.
| #define N_HTTP_RESPONSE_CHUNK 65536 |
Definition at line 45 of file n_http_response.c.
Referenced by n_http_response_write().
|
static |
Definition at line 182 of file n_http_response.c.
Referenced by n_http_response_body_length(), n_http_response_head(), and n_http_response_write().
|
static |
Definition at line 450 of file n_http_response.c.
References h(), new_nstr(), and nstrcat_ex().
Referenced by n_http_response_head().
|
static |
Definition at line 203 of file n_http_response.c.
References N_HTTP_RESP::body, N_HTTP_RESP::fd, N_HTTP_RESP::fd_length, N_HTTP_RESP::fd_offset, and free_nstr.
Referenced by n_http_response_append(), n_http_response_file(), and n_http_response_free().
|
static |
Definition at line 158 of file n_http_response.c.
References _resp_lc().
Referenced by n_http_response_add_header(), n_http_response_get_header(), n_http_response_remove_header(), and n_http_response_set_header().
|
static |
Definition at line 154 of file n_http_response.c.
Referenced by _resp_ieq().
|
static |
Definition at line 579 of file n_http_response.c.
Referenced by n_http_parse_range().
|
static |
Definition at line 522 of file n_http_response.c.
Referenced by n_http_response_write().
|
static |
Definition at line 168 of file n_http_response.c.
Referenced by n_http_response_add_header().
|
static |
Definition at line 509 of file n_http_response.c.
Referenced by n_http_response_write().