GNU libmicrohttpd 0.9.77
|
Methods for managing response objects. More...
#include "mhd_options.h"
#include "internal.h"
#include "response.h"
#include "mhd_limits.h"
#include "mhd_sockets.h"
#include "mhd_itc.h"
#include "mhd_str.h"
#include "connection.h"
#include "memorypool.h"
#include "mhd_send.h"
#include "mhd_compat.h"
#include "mhd_assert.h"
Go to the source code of this file.
Macros | |
#define | MHD_NO_DEPRECATION 1 |
#define | MHD_FILE_READ_BLOCK_SIZE 4096 /* 4k */ |
#define | _MHD_insert_header_first(presponse, phdr) |
#define | _MHD_insert_header_last(presponse, phdr) |
#define | _MHD_remove_header(presponse, phdr) |
Methods for managing response objects.
Definition in file response.c.
#define _MHD_insert_header_first | ( | presponse, | |
phdr | |||
) |
Insert a new header at the first position of the response
Definition at line 77 of file response.c.
#define _MHD_insert_header_last | ( | presponse, | |
phdr | |||
) |
Insert a new header at the last position of the response
Definition at line 98 of file response.c.
#define _MHD_remove_header | ( | presponse, | |
phdr | |||
) |
Remove a header from the response
Definition at line 120 of file response.c.
#define MHD_FILE_READ_BLOCK_SIZE 4096 /* 4k */ |
Size of single file read operation for file-backed responses.
Definition at line 70 of file response.c.
#define MHD_NO_DEPRECATION 1 |
Definition at line 28 of file response.c.
|
static |
Add a header or footer line to the response.
response | response to add a header to |
kind | header or footer |
header | the header to add |
content | value to add |
Definition at line 157 of file response.c.
References _MHD_insert_header_last, MHD_HTTP_Header::header, MHD_HTTP_Header::header_size, MHD_HTTP_Header::kind, MHD_calloc_(), MHD_NO, MHD_YES, NULL, MHD_HTTP_Header::value, and MHD_HTTP_Header::value_size.
|
static |
Add "Connection:" header to the response with special processing.
"Connection:" header value will be combined with any existing "Connection:" header, "close" token (if any) will be de-duplicated and moved to the first position.
response | the response to add a header to |
value | the value to add |
the length of the "Connection" key
< the length of the value
< the length of the existing "Connection" value
< the size of the buffer
< the length of the normalised value
< the temporal buffer
< existing "Connection" header
< the value has "close" token
< existing "Connection" header has "close" token
< position of addition in the buf
< new "Connection" header
Definition at line 209 of file response.c.
References _MHD_insert_header_first, MHD_Response::flags_auto, MHD_HTTP_Header::header, MHD_HTTP_Header::header_size, MHD_HTTP_Header::kind, mhd_assert, MHD_calloc_(), MHD_get_response_element_n_(), MHD_HEADER_KIND, MHD_HTTP_HEADER_CONNECTION, MHD_NO, MHD_RAF_HAS_CONNECTION_CLOSE, MHD_RAF_HAS_CONNECTION_HDR, MHD_STATICSTR_LEN_, MHD_str_remove_token_caseless_(), MHD_str_remove_tokens_caseless_(), MHD_YES, NULL, SSIZE_MAX, MHD_HTTP_Header::value, and MHD_HTTP_Header::value_size.
Referenced by MHD_add_response_header().
|
static |
Remove tokens from "Connection:" header of the response.
Provided tokens will be removed from "Connection:" header value.
response | the response to manipulate "Connection:" header |
value | the tokens to remove |
< existing "Connection" header
Definition at line 390 of file response.c.
References _MHD_remove_header, MHD_Response::flags_auto, MHD_HTTP_Header::header, MHD_get_response_element_n_(), MHD_HEADER_KIND, MHD_HTTP_HEADER_CONNECTION, MHD_NO, MHD_RAF_HAS_CONNECTION_CLOSE, MHD_RAF_HAS_CONNECTION_HDR, MHD_STATICSTR_LEN_, MHD_str_remove_tokens_caseless_(), MHD_YES, NULL, MHD_HTTP_Header::value, and MHD_HTTP_Header::value_size.
Referenced by MHD_del_response_header().
|
static |
Given a file descriptor, read data from the file to generate the response.
cls | pointer to the response |
pos | offset in the file to access |
buf | where to write the data |
max | number of bytes to write at most |
Definition at line 902 of file response.c.
References MHD_Response::fd, MHD_Response::fd_off, INT32_MAX, MHD_CONTENT_READER_END_OF_STREAM, MHD_CONTENT_READER_END_WITH_ERROR, and SSIZE_MAX.
Referenced by MHD_create_response_from_fd_at_offset64().
|
static |
Destroy file reader context. Closes the file descriptor.
cls | pointer to file descriptor |
Definition at line 1025 of file response.c.
References MHD_Response::fd.
Referenced by MHD_create_response_from_fd_at_offset64(), and MHD_create_response_from_pipe().
bool MHD_check_response_header_token_ci | ( | const struct MHD_Response * | response, |
const char * | key, | ||
size_t | key_len, | ||
const char * | token, | ||
size_t | token_len | ||
) |
Check whether response header contains particular token.
Token could be surrounded by spaces and tabs and delimited by comma. Case-insensitive match used for header names and tokens.
response | the response to query |
key | header name |
key_len | the length of key, not including optional terminating null-character. |
token | the token to find |
token_len | the length of token, not including optional terminating null-character. |
Definition at line 773 of file response.c.
References MHD_Response::first_header, MHD_HTTP_Header::header, MHD_HTTP_Header::header_size, MHD_HTTP_Header::kind, mhd_assert, MHD_HEADER_KIND, MHD_str_equal_caseless_bin_n_(), MHD_str_has_token_caseless_(), MHD_HTTP_Header::next, NULL, and MHD_HTTP_Header::value.
void MHD_increment_response_rc | ( | struct MHD_Response * | response | ) |
Increments the reference counter for the response.
response | object to modify |
Definition at line 2012 of file response.c.
References MHD_mutex_lock_chk_, MHD_mutex_unlock_chk_, MHD_Response::mutex, and MHD_Response::reference_count.
Referenced by MHD_queue_response().
enum MHD_Result MHD_set_response_options | ( | struct MHD_Response * | response, |
enum MHD_ResponseFlags | flags, | ||
... | |||
) |
Set special flags and options for a response.
response | the response to modify |
flags | to set for the response |
... | MHD_RO_END terminated list of options |
Definition at line 866 of file response.c.
References MHD_Response::flags, MHD_NO, MHD_RO_END, and MHD_YES.
|
static |
Given a pipe descriptor, read data from the pipe to generate the response.
cls | pointer to the response |
pos | offset in the pipe to access (ignored) |
buf | where to write the data |
max | number of bytes to write at most |
Definition at line 990 of file response.c.
References MHD_Response::fd, MHD_CONTENT_READER_END_OF_STREAM, MHD_CONTENT_READER_END_WITH_ERROR, SSIZE_MAX, and UINT_MAX.
Referenced by MHD_create_response_from_pipe().