![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
#include <fcntl.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include "nilorea/n_common.h"#include "nilorea/n_http_response.h"#include "nilorea/n_log.h"#include "nilorea/n_str.h"Go to the source code of this file.
Data Structures | |
| struct | sink |
| an in-memory sink for n_http_response_write() More... | |
Macros | |
| #define | RANGE(s, total) |
Functions | |
| static void | expect_true (const char *what, int ok) |
| count a failed check | |
| static int | head_is (const N_HTTP_RESP *r, const char *want) |
| text of the head of r, up to and excluding the Date line's value | |
| int | main (int argc, char **argv) |
| run the checks | |
| static int | process_args (int argc, char **argv) |
| read -V | |
| static ssize_t | sink_write (void *ctx, const void *buf, size_t len) |
| write function: accept at most s->chunk bytes | |
| static void | test_headers (void) |
| headers: validation, set/remove, framing | |
| static void | test_range (void) |
| Range header parsing. | |
| static void | test_status (void) |
| status codes and bodiless responses | |
| static void | test_write (void) |
| writing memory and file bodies, HEAD, partial and failing writes | |
Variables | |
| static int | failures = 0 |
| failed checks | |
| static int | log_level = 3 |
| log level from -V | |
| struct sink |
an in-memory sink for n_http_response_write()
Definition at line 77 of file ex_http_response.c.
| Data Fields | ||
|---|---|---|
| size_t | chunk | most bytes accepted per call (partial writes) |
| N_STR * | data | everything written |
| long | fail_at | fail once this many bytes were written, -1 never |
| #define RANGE | ( | s, | |
| total ) |
Referenced by test_range().
|
static |
|
static |
text of the head of r, up to and excluding the Date line's value
| r | the response |
| want | expected head, with the Date line removed |
Definition at line 102 of file ex_http_response.c.
References free_nstr, h(), LOG_ERR, n_http_response_head(), and n_log.
Referenced by test_headers(), and test_status().
| int main | ( | int | argc, |
| char ** | argv ) |
run the checks
| argc | argument count |
| argv | arguments |
Definition at line 315 of file ex_http_response.c.
References failures, LOG_ERR, log_level, LOG_NOTICE, n_log, process_args(), set_log_level(), test_headers(), test_range(), test_status(), and test_write().
|
static |
read -V
| argc | argument count |
| argv | arguments |
Definition at line 63 of file ex_http_response.c.
References log_level.
|
static |
write function: accept at most s->chunk bytes
| ctx | the sink |
| buf | bytes |
| len | how many |
Definition at line 88 of file ex_http_response.c.
References sink::chunk, sink::data, sink::fail_at, nstrcat_ex(), and N_STR::written.
Referenced by test_status(), and test_write().
|
static |
headers: validation, set/remove, framing
Definition at line 123 of file ex_http_response.c.
References expect_true(), free_nstr, h(), head_is(), n_http_response_add_header(), n_http_response_append(), n_http_response_free(), n_http_response_get_header(), n_http_response_head(), N_HTTP_RESPONSE_HEADERS_MAX, n_http_response_new(), n_http_response_remove_header(), n_http_response_set_connection(), and n_http_response_set_header().
Referenced by main().
|
static |
Range header parsing.
Definition at line 290 of file ex_http_response.c.
References expect_true(), n_http_parse_range(), N_HTTP_RANGE_NONE, N_HTTP_RANGE_OK, N_HTTP_RANGE_UNSATISFIABLE, and RANGE.
Referenced by main().
|
static |
status codes and bodiless responses
Definition at line 187 of file ex_http_response.c.
References N_STR::data, sink::data, expect_true(), free_nstr, head_is(), n_http_response_add_header(), n_http_response_append(), n_http_response_body_length(), n_http_response_free(), n_http_response_new(), n_http_response_set_connection(), n_http_response_set_header(), n_http_response_set_status(), n_http_response_write(), n_http_status_reason(), and sink_write().
Referenced by main().
|
static |
writing memory and file bodies, HEAD, partial and failing writes
Definition at line 217 of file ex_http_response.c.
References N_STR::data, sink::data, expect_true(), free_nstr, n_http_response_append(), n_http_response_body_length(), n_http_response_file(), n_http_response_free(), n_http_response_head(), n_http_response_new(), n_http_response_set_connection(), n_http_response_write(), sink_write(), and N_STR::written.
Referenced by main().
|
static |
failed checks
Definition at line 45 of file ex_http_response.c.
|
static |
log level from -V
Definition at line 43 of file ex_http_response.c.