GNU libmicrohttpd 1.0.1
Loading...
Searching...
No Matches
internal.h File Reference

MHD internal shared structures. More...

#include "mhd_options.h"
#include "platform.h"
#include "microhttpd.h"
#include "mhd_assert.h"
#include "mhd_panic.h"
#include "mhd_locks.h"
#include "mhd_sockets.h"
#include "mhd_itc_types.h"
#include "mhd_str_types.h"
Include dependency graph for internal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  MHD_NonceNc
 
struct  MHD_HTTP_Res_Header
 
struct  MHD_HTTP_Req_Header
 
struct  MHD_iovec_track_
 
struct  MHD_Response
 
struct  MHD_RequestLineProcessing
 
struct  MHD_HeaderProcessing
 
union  MHD_HeadersProcessing
 
union  MHD_StartOrSize
 
struct  MHD_Request
 
struct  MHD_Reply_Properties
 
struct  MHD_Reply
 
struct  MHD_Connection
 
struct  MHD_Daemon
 

Macros

#define PRIu64   "llu"
 
#define _MHD_DROP_CONST(ptr)   ((void *) ((uintptr_t) ((const void *) (ptr))))
 
#define _MHD_MACRO_NO   0
 
#define _MHD_MACRO_YES   1
 
#define MHD_fd_close_chk_(fd)
 
#define _MHD_DEBUG_CONNECT   _MHD_MACRO_NO
 
#define _MHD_DEBUG_SEND_DATA   _MHD_MACRO_NO
 
#define _MHD_DEBUG_CLOSE   _MHD_MACRO_NO
 
#define MHD_MAX(a, b)   (((a)<(b)) ? (b) : (a))
 
#define MHD_MIN(a, b)   (((a)<(b)) ? (a) : (b))
 
#define MHD_BUF_INC_SIZE   1500
 
#define MHD_TEST_ALLOW_SUSPEND_RESUME   8192
 
#define MAX_CLIENT_NONCE_LENGTH   129
 
#define MAX_DIGEST_NONCE_LENGTH   ((16 + 6) * 2)
 
#define MHD_IOV_ELMN_MAX_SIZE   SIZE_MAX
 
#define DEBUG_STATES   _MHD_MACRO_NO
 
#define MHD_IS_HTTP_VER_SUPPORTED(ver)
 
#define MHD_IS_HTTP_VER_1_1_COMPAT(ver)
 
#define MHD_D_IS_USING_SELECT_(d)   ((void) (d), ! 0)
 
#define MHD_D_IS_USING_POLL_(d)   ((void) (d), 0)
 
#define MHD_D_IS_USING_EPOLL_(d)   ((void) (d), 0)
 
#define MHD_D_IS_USING_THREADS_(d)   ((void) d, 0)
 
#define MHD_D_IS_USING_THREAD_PER_CONN_(d)   ((void) d, 0)
 
#define MHD_D_IS_THREAD_SAFE_(d)   ((void) d, 0)
 
#define MHD_D_GET_FD_SETSIZE_(d)   (FD_SETSIZE)
 
#define MHD_D_DOES_SCKT_FIT_FDSET_(sckt, d)    MHD_SCKT_FD_FITS_FDSET_SETSIZE_(sckt,NULL,MHD_D_GET_FD_SETSIZE_(d))
 
#define DLL_insert(head, tail, element)
 
#define DLL_remove(head, tail, element)
 
#define XDLL_insert(head, tail, element)
 
#define XDLL_remove(head, tail, element)
 
#define EDLL_insert(head, tail, element)
 
#define EDLL_remove(head, tail, element)
 
#define MHD_check_response_header_s_token_ci(r, k, tkn)
 

Typedefs

typedef struct MHD_IoVec MHD_iovec_
 
typedef size_t MHD_iov_size_
 
typedef ssize_t(* ReceiveCallback) (struct MHD_Connection *conn, void *write_to, size_t max_bytes)
 
typedef ssize_t(* TransmitCallback) (struct MHD_Connection *conn, const void *read_from, size_t max_bytes)
 
typedef void *(* LogCallback) (void *cls, const char *uri, struct MHD_Connection *con)
 
typedef size_t(* UnescapeCallback) (void *cls, struct MHD_Connection *conn, char *uri)
 
typedef enum MHD_Result(* MHD_ArgumentIterator_) (void *cls, const char *key, size_t key_size, const char *value, size_t value_size, enum MHD_ValueKind kind)
 

Enumerations

enum  MHD_tristate {
  _MHD_UNKNOWN = -1 , _MHD_OFF = false , _MHD_NO = false , _MHD_ON = true ,
  _MHD_YES = true
}
 
enum  MHD_EpollState {
  MHD_EPOLL_STATE_UNREADY = 0 , MHD_EPOLL_STATE_READ_READY = 1 , MHD_EPOLL_STATE_WRITE_READY = 2 , MHD_EPOLL_STATE_IN_EREADY_EDLL = 4 ,
  MHD_EPOLL_STATE_IN_EPOLL_SET = 8 , MHD_EPOLL_STATE_SUSPENDED = 16 , MHD_EPOLL_STATE_ERROR = 128
}
 
enum  MHD_ConnectionEventLoopInfo {
  MHD_EVENT_LOOP_INFO_READ = 1 << 0 , MHD_EVENT_LOOP_INFO_WRITE = 1 << 1 , MHD_EVENT_LOOP_INFO_PROCESS = 1 << 2 , MHD_EVENT_LOOP_INFO_PROCESS_READ ,
  MHD_EVENT_LOOP_INFO_CLEANUP = 1 << 3
}
 
enum  MHD_ResponseAutoFlags {
  MHD_RAF_NO_FLAGS = 0 , MHD_RAF_HAS_CONNECTION_HDR = 1 << 0 , MHD_RAF_HAS_CONNECTION_CLOSE = 1 << 1 , MHD_RAF_HAS_TRANS_ENC_CHUNKED = 1 << 2 ,
  MHD_RAF_HAS_CONTENT_LENGTH = 1 << 3 , MHD_RAF_HAS_DATE_HDR = 1 << 4
}
 
enum  MHD_CONNECTION_STATE {
  MHD_CONNECTION_INIT = 0 , MHD_CONNECTION_REQ_LINE_RECEIVING = MHD_CONNECTION_INIT + 1 , MHD_CONNECTION_REQ_LINE_RECEIVED = MHD_CONNECTION_REQ_LINE_RECEIVING + 1 , MHD_CONNECTION_REQ_HEADERS_RECEIVING = MHD_CONNECTION_REQ_LINE_RECEIVED + 1 ,
  MHD_CONNECTION_HEADERS_RECEIVED = MHD_CONNECTION_REQ_HEADERS_RECEIVING + 1 , MHD_CONNECTION_HEADERS_PROCESSED = MHD_CONNECTION_HEADERS_RECEIVED + 1 , MHD_CONNECTION_CONTINUE_SENDING = MHD_CONNECTION_HEADERS_PROCESSED + 1 , MHD_CONNECTION_BODY_RECEIVING = MHD_CONNECTION_CONTINUE_SENDING + 1 ,
  MHD_CONNECTION_BODY_RECEIVED = MHD_CONNECTION_BODY_RECEIVING + 1 , MHD_CONNECTION_FOOTERS_RECEIVING = MHD_CONNECTION_BODY_RECEIVED + 1 , MHD_CONNECTION_FOOTERS_RECEIVED = MHD_CONNECTION_FOOTERS_RECEIVING + 1 , MHD_CONNECTION_FULL_REQ_RECEIVED = MHD_CONNECTION_FOOTERS_RECEIVED + 1 ,
  MHD_CONNECTION_START_REPLY = MHD_CONNECTION_FULL_REQ_RECEIVED + 1 , MHD_CONNECTION_HEADERS_SENDING = MHD_CONNECTION_START_REPLY + 1 , MHD_CONNECTION_HEADERS_SENT = MHD_CONNECTION_HEADERS_SENDING + 1 , MHD_CONNECTION_NORMAL_BODY_UNREADY = MHD_CONNECTION_HEADERS_SENT + 1 ,
  MHD_CONNECTION_NORMAL_BODY_READY = MHD_CONNECTION_NORMAL_BODY_UNREADY + 1 , MHD_CONNECTION_CHUNKED_BODY_UNREADY = MHD_CONNECTION_NORMAL_BODY_READY + 1 , MHD_CONNECTION_CHUNKED_BODY_READY = MHD_CONNECTION_CHUNKED_BODY_UNREADY + 1 , MHD_CONNECTION_CHUNKED_BODY_SENT = MHD_CONNECTION_CHUNKED_BODY_READY + 1 ,
  MHD_CONNECTION_FOOTERS_SENDING = MHD_CONNECTION_CHUNKED_BODY_SENT + 1 , MHD_CONNECTION_FULL_REPLY_SENT = MHD_CONNECTION_FOOTERS_SENDING + 1 , MHD_CONNECTION_CLOSED = MHD_CONNECTION_FULL_REPLY_SENT + 1
}
 
enum  MHD_TLS_CONN_STATE {
  MHD_TLS_CONN_NO_TLS = 0 , MHD_TLS_CONN_INIT , MHD_TLS_CONN_HANDSHAKING , MHD_TLS_CONN_CONNECTED ,
  MHD_TLS_CONN_WR_CLOSING , MHD_TLS_CONN_WR_CLOSED , MHD_TLS_CONN_TLS_CLOSING , MHD_TLS_CONN_TLS_CLOSED ,
  MHD_TLS_CONN_TLS_FAILED , MHD_TLS_CONN_INVALID_STATE
}
 
enum  MHD_ConnKeepAlive { MHD_CONN_MUST_CLOSE = -1 , MHD_CONN_KEEPALIVE_UNKOWN = 0 , MHD_CONN_USE_KEEPALIVE = 1 , MHD_CONN_MUST_UPGRADE = 2 }
 
enum  MHD_HTTP_Version {
  MHD_HTTP_VER_INVALID = -1 , MHD_HTTP_VER_UNKNOWN = 0 , MHD_HTTP_VER_TOO_OLD = 1 , MHD_HTTP_VER_1_0 = 2 ,
  MHD_HTTP_VER_1_1 = 3 , MHD_HTTP_VER_1_2__1_9 = 4 , MHD_HTTP_VER_FUTURE = 100
}
 
enum  MHD_HTTP_Method {
  MHD_HTTP_MTHD_NO_METHOD = 0 , MHD_HTTP_MTHD_GET = 1 , MHD_HTTP_MTHD_HEAD = 2 , MHD_HTTP_MTHD_POST = 3 ,
  MHD_HTTP_MTHD_PUT = 4 , MHD_HTTP_MTHD_DELETE = 5 , MHD_HTTP_MTHD_CONNECT = 6 , MHD_HTTP_MTHD_OPTIONS = 7 ,
  MHD_HTTP_MTHD_TRACE = 8 , MHD_HTTP_MTHD_OTHER = 1000
}
 

Functions

void MHD_unescape_plus (char *arg)
 
enum MHD_Result MHD_parse_arguments_ (struct MHD_Connection *connection, enum MHD_ValueKind kind, char *args, MHD_ArgumentIterator_ cb, void *cls)
 
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)
 
void internal_suspend_connection_ (struct MHD_Connection *connection)
 
_MHD_static_inline struct MHD_DaemonMHD_get_master (struct MHD_Daemon *const daemon)
 

Variables

enum MHD_tristate _MHD_FIXED_ENUM
 
enum MHD_EpollState _MHD_FIXED_FLAGS_ENUM
 

Detailed Description

MHD internal shared structures.

Author
Daniel Pittman
Christian Grothoff
Karlson2k (Evgeny Grin)

Definition in file internal.h.

Macro Definition Documentation

◆ _MHD_DEBUG_CLOSE

#define _MHD_DEBUG_CLOSE   _MHD_MACRO_NO

Add extra debug messages with reasons for closing connections (non-error reasons).

Definition at line 126 of file internal.h.

◆ _MHD_DEBUG_CONNECT

#define _MHD_DEBUG_CONNECT   _MHD_MACRO_NO

Print extra messages when establishing connections? (only adds non-error messages).

Definition at line 111 of file internal.h.

◆ _MHD_DEBUG_SEND_DATA

#define _MHD_DEBUG_SEND_DATA   _MHD_MACRO_NO

Should all data send be printed to stderr?

Definition at line 118 of file internal.h.

◆ _MHD_DROP_CONST

#define _MHD_DROP_CONST (   ptr)    ((void *) ((uintptr_t) ((const void *) (ptr))))

Macro to drop 'const' qualifier from pointer without compiler warning. To be used only to deal with broken external APIs, which require non-const pointer to unmodifiable data. Must not be used to transform pointers for MHD needs.

Definition at line 77 of file internal.h.

◆ _MHD_MACRO_NO

#define _MHD_MACRO_NO   0

"Negative answer"/"false" for use in macros, meaningful for precompiler

Definition at line 83 of file internal.h.

◆ _MHD_MACRO_YES

#define _MHD_MACRO_YES   1

"Positive answer"/"true" for use in macros, meaningful for precompiler

Definition at line 89 of file internal.h.

◆ DEBUG_STATES

#define DEBUG_STATES   _MHD_MACRO_NO

Should all state transitions be printed to stderr?

Definition at line 775 of file internal.h.

◆ DLL_insert

#define DLL_insert (   head,
  tail,
  element 
)
Value:
do { \
mhd_assert (NULL == (element)->next); \
mhd_assert (NULL == (element)->prev); \
(element)->next = (head); \
(element)->prev = NULL; \
if ((tail) == NULL) { \
(tail) = element; \
} else { \
(head)->prev = element; \
} \
(head) = (element); } while (0)
#define NULL

Insert an element at the head of a DLL. Assumes that head, tail and element are structs with prev and next fields.

Parameters
headpointer to the head of the DLL
tailpointer to the tail of the DLL
elementelement to insert

Definition at line 2658 of file internal.h.

◆ DLL_remove

#define DLL_remove (   head,
  tail,
  element 
)
Value:
do { \
mhd_assert ( (NULL != (element)->next) || ((element) == (tail))); \
mhd_assert ( (NULL != (element)->prev) || ((element) == (head))); \
if ((element)->prev == NULL) { \
(head) = (element)->next; \
} else { \
(element)->prev->next = (element)->next; \
} \
if ((element)->next == NULL) { \
(tail) = (element)->prev; \
} else { \
(element)->next->prev = (element)->prev; \
} \
(element)->next = NULL; \
(element)->prev = NULL; } while (0)

Remove an element from a DLL. Assumes that head, tail and element are structs with prev and next fields.

Parameters
headpointer to the head of the DLL
tailpointer to the tail of the DLL
elementelement to remove

Definition at line 2680 of file internal.h.

◆ EDLL_insert

#define EDLL_insert (   head,
  tail,
  element 
)
Value:
do { \
(element)->nextE = (head); \
(element)->prevE = NULL; \
if ((tail) == NULL) { \
(tail) = element; \
} else { \
(head)->prevE = element; \
} \
(head) = (element); } while (0)

Insert an element at the head of a EDLL. Assumes that head, tail and element are structs with prevE and nextE fields.

Parameters
headpointer to the head of the EDLL
tailpointer to the tail of the EDLL
elementelement to insert

Definition at line 2752 of file internal.h.

◆ EDLL_remove

#define EDLL_remove (   head,
  tail,
  element 
)
Value:
do { \
if ((element)->prevE == NULL) { \
(head) = (element)->nextE; \
} else { \
(element)->prevE->nextE = (element)->nextE; \
} \
if ((element)->nextE == NULL) { \
(tail) = (element)->prevE; \
} else { \
(element)->nextE->prevE = (element)->prevE; \
} \
(element)->nextE = NULL; \
(element)->prevE = NULL; } while (0)

Remove an element from a EDLL. Assumes that head, tail and element are structs with prevE and nextE fields.

Parameters
headpointer to the head of the EDLL
tailpointer to the tail of the EDLL
elementelement to remove

Definition at line 2772 of file internal.h.

◆ MAX_CLIENT_NONCE_LENGTH

#define MAX_CLIENT_NONCE_LENGTH   129

Maximum length of a nonce in digest authentication. 64(SHA-256 Hex) + 12(Timestamp Hex) + 1(NULL); hence 77 should suffice, but Opera (already) takes more (see Mantis #1633), so we've increased the value to support something longer...

Definition at line 257 of file internal.h.

◆ MAX_DIGEST_NONCE_LENGTH

#define MAX_DIGEST_NONCE_LENGTH   ((16 + 6) * 2)

The maximum size of MHD-generated nonce when printed with hexadecimal chars.

This is equal to "(32 bytes for SHA-256 (or SHA-512/256) nonce plus 6 bytes for timestamp) multiplied by two hex chars per byte". Please keep it in sync with digestauth.c

Definition at line 269 of file internal.h.

◆ MHD_BUF_INC_SIZE

#define MHD_BUF_INC_SIZE   1500

Minimum reasonable size by which MHD tries to increment read/write buffers. We usually begin with half the available pool space for the IO-buffer, but if absolutely needed we additively grow by the number of bytes given here (up to – theoretically – the full pool space).

Currently set to reasonable maximum MSS size.

Definition at line 142 of file internal.h.

◆ MHD_check_response_header_s_token_ci

#define MHD_check_response_header_s_token_ci (   r,
  k,
  tkn 
)
Value:
(tkn),MHD_STATICSTR_LEN_ (tkn))
#define MHD_STATICSTR_LEN_(macro)
Definition mhd_str.h:45
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)
Definition response.c:930

Check whether response header contains particular static tkn.

Token could be surrounded by spaces and tabs and delimited by comma. Case-insensitive match used for header names and tokens.

Parameters
rthe response to query
kheader name
tknthe static string of token to find
Returns
true if token is found in specified header, false otherwise

Definition at line 2874 of file internal.h.

◆ MHD_D_DOES_SCKT_FIT_FDSET_

#define MHD_D_DOES_SCKT_FIT_FDSET_ (   sckt,
 
)     MHD_SCKT_FD_FITS_FDSET_SETSIZE_(sckt,NULL,MHD_D_GET_FD_SETSIZE_(d))

Check whether socket sckt fits fd_sets used by the daemon d

Definition at line 2601 of file internal.h.

◆ MHD_D_GET_FD_SETSIZE_

#define MHD_D_GET_FD_SETSIZE_ (   d)    (FD_SETSIZE)

Get FD_SETSIZE used by the daemon d

Definition at line 2595 of file internal.h.

◆ MHD_D_IS_THREAD_SAFE_

#define MHD_D_IS_THREAD_SAFE_ (   d)    ((void) d, 0)

Check whether the d daemon has thread-safety enabled.

Definition at line 2583 of file internal.h.

◆ MHD_D_IS_USING_EPOLL_

#define MHD_D_IS_USING_EPOLL_ (   d)    ((void) (d), 0)

Checks whether the d daemon is using epoll

Definition at line 2550 of file internal.h.

◆ MHD_D_IS_USING_POLL_

#define MHD_D_IS_USING_POLL_ (   d)    ((void) (d), 0)

Checks whether the d daemon is using poll()

Definition at line 2546 of file internal.h.

◆ MHD_D_IS_USING_SELECT_

#define MHD_D_IS_USING_SELECT_ (   d)    ((void) (d), ! 0)

Checks whether the d daemon is using select()

Definition at line 2542 of file internal.h.

◆ MHD_D_IS_USING_THREAD_PER_CONN_

#define MHD_D_IS_USING_THREAD_PER_CONN_ (   d)    ((void) d, 0)

Checks whether the d daemon is using thread-per-connection mode

Definition at line 2578 of file internal.h.

◆ MHD_D_IS_USING_THREADS_

#define MHD_D_IS_USING_THREADS_ (   d)    ((void) d, 0)

Checks whether the d daemon is using internal polling thread

Definition at line 2574 of file internal.h.

◆ MHD_fd_close_chk_

#define MHD_fd_close_chk_ (   fd)
Value:
do { \
if ( (0 != close ((fd)) && (EBADF == errno)) ) { \
MHD_PANIC (_ ("Failed to close FD.\n")); \
} \
} while (0)
#define _(String)
Definition mhd_options.h:42
int fd

Close FD and abort execution if error is detected.

Parameters
fdthe FD to close

Definition at line 95 of file internal.h.

◆ MHD_IOV_ELMN_MAX_SIZE

#define MHD_IOV_ELMN_MAX_SIZE   SIZE_MAX

Definition at line 441 of file internal.h.

◆ MHD_IS_HTTP_VER_1_1_COMPAT

#define MHD_IS_HTTP_VER_1_1_COMPAT (   ver)
Value:
(MHD_HTTP_VER_1_1 == (ver) || \
@ MHD_HTTP_VER_1_1
Definition internal.h:865
@ MHD_HTTP_VER_1_2__1_9
Definition internal.h:870

Protocol should be used as HTTP/1.1 protocol.

See the last paragraph of https://datatracker.ietf.org/doc/html/rfc7230#section-2.6

Definition at line 890 of file internal.h.

◆ MHD_IS_HTTP_VER_SUPPORTED

#define MHD_IS_HTTP_VER_SUPPORTED (   ver)
Value:
(MHD_HTTP_VER_1_0 <= (ver) && \
@ MHD_HTTP_VER_1_0
Definition internal.h:860

Returns boolean 'true' if HTTP version is supported by MHD

Definition at line 881 of file internal.h.

◆ MHD_MAX

#define MHD_MAX (   a,
 
)    (((a)<(b)) ? (b) : (a))

Definition at line 129 of file internal.h.

◆ MHD_MIN

#define MHD_MIN (   a,
 
)    (((a)<(b)) ? (a) : (b))

Definition at line 130 of file internal.h.

◆ MHD_TEST_ALLOW_SUSPEND_RESUME

#define MHD_TEST_ALLOW_SUSPEND_RESUME   8192

Additional test value for enum MHD_FLAG to check only for MHD_ALLOW_SUSPEND_RESUME and NOT for MHD_USE_ITC.

Definition at line 249 of file internal.h.

◆ PRIu64

#define PRIu64   "llu"

Definition at line 53 of file internal.h.

◆ XDLL_insert

#define XDLL_insert (   head,
  tail,
  element 
)
Value:
do { \
mhd_assert (NULL == (element)->nextX); \
mhd_assert (NULL == (element)->prevX); \
(element)->nextX = (head); \
(element)->prevX = NULL; \
if (NULL == (tail)) { \
(tail) = element; \
} else { \
(head)->prevX = element; \
} \
(head) = (element); } while (0)

Insert an element at the head of a XDLL. Assumes that head, tail and element are structs with prevX and nextX fields.

Parameters
headpointer to the head of the XDLL
tailpointer to the tail of the XDLL
elementelement to insert

Definition at line 2705 of file internal.h.

◆ XDLL_remove

#define XDLL_remove (   head,
  tail,
  element 
)
Value:
do { \
mhd_assert ( (NULL != (element)->nextX) || ((element) == (tail))); \
mhd_assert ( (NULL != (element)->prevX) || ((element) == (head))); \
if (NULL == (element)->prevX) { \
(head) = (element)->nextX; \
} else { \
(element)->prevX->nextX = (element)->nextX; \
} \
if (NULL == (element)->nextX) { \
(tail) = (element)->prevX; \
} else { \
(element)->nextX->prevX = (element)->prevX; \
} \
(element)->nextX = NULL; \
(element)->prevX = NULL; } while (0)

Remove an element from a XDLL. Assumes that head, tail and element are structs with prevX and nextX fields.

Parameters
headpointer to the head of the XDLL
tailpointer to the tail of the XDLL
elementelement to remove

Definition at line 2727 of file internal.h.

Typedef Documentation

◆ LogCallback

typedef void *(* LogCallback) (void *cls, const char *uri, struct MHD_Connection *con)

Signature of function called to log URI accesses.

Parameters
clsclosure
uriuri being accessed
conconnection handle
Returns
new closure

Definition at line 1834 of file internal.h.

◆ MHD_ArgumentIterator_

typedef enum MHD_Result(* MHD_ArgumentIterator_) (void *cls, const char *key, size_t key_size, const char *value, size_t value_size, enum MHD_ValueKind kind)

Callback invoked when iterating over key / value argument pairs during parsing.

Parameters
clscontext of the iteration
key0-terminated key string, never NULL
key_sizenumber of bytes in key
value0-terminated binary data, may include binary zeros, may be NULL
value_sizenumber of bytes in value
kindorigin of the key-value pair
Returns
MHD_YES on success (continue to iterate) MHD_NO to signal failure (and abort iteration)

Definition at line 2793 of file internal.h.

◆ MHD_iov_size_

typedef size_t MHD_iov_size_

Definition at line 442 of file internal.h.

◆ MHD_iovec_

typedef struct MHD_IoVec MHD_iovec_

Internally used I/O vector type for use when writev or sendmsg is not available.

Definition at line 440 of file internal.h.

◆ ReceiveCallback

typedef ssize_t(* ReceiveCallback) (struct MHD_Connection *conn, void *write_to, size_t max_bytes)

Function to receive plaintext data.

Parameters
connthe connection struct
write_towhere to write received data
max_bytesmaximum number of bytes to receive
Returns
number of bytes written to write_to

Definition at line 794 of file internal.h.

◆ TransmitCallback

typedef ssize_t(* TransmitCallback) (struct MHD_Connection *conn, const void *read_from, size_t max_bytes)

Function to transmit plaintext data.

Parameters
connthe connection struct
read_fromwhere to read data to transmit
max_bytesmaximum number of bytes to transmit
Returns
number of bytes transmitted

Definition at line 808 of file internal.h.

◆ UnescapeCallback

typedef size_t(* UnescapeCallback) (void *cls, struct MHD_Connection *conn, char *uri)

Signature of function called to unescape URIs. See also MHD_http_unescape().

Parameters
clsclosure
connconnection handle
uri0-terminated string to unescape (should be updated)
Returns
length of the resulting string

Definition at line 1848 of file internal.h.

Enumeration Type Documentation

◆ MHD_CONNECTION_STATE

States in a state machine for a connection.

The main transitions are any-state to MHD_CONNECTION_CLOSED, any state to state+1, #MHD_CONNECTION_FOOTERS_SENT to MHD_CONNECTION_INIT. MHD_CONNECTION_CLOSED is the terminal state and MHD_CONNECTION_INIT the initial state.

Note that transitions for reading happen only after the input has been processed; transitions for writing happen after the respective data has been put into the write buffer (the write does not have to be completed yet). A transition to MHD_CONNECTION_CLOSED or MHD_CONNECTION_INIT requires the write to be complete.

Enumerator
MHD_CONNECTION_INIT 

Connection just started (no headers received). Waiting for the line with the request type, URL and version.

MHD_CONNECTION_REQ_LINE_RECEIVING 

Part of the request line was received. Wait for complete line.

MHD_CONNECTION_REQ_LINE_RECEIVED 

We got the URL (and request type and version). Wait for a header line.

A milestone state. No received data is processed in this state.

MHD_CONNECTION_REQ_HEADERS_RECEIVING 

Receiving request headers. Wait for the rest of the headers.

MHD_CONNECTION_HEADERS_RECEIVED 

We got the request headers. Process them.

MHD_CONNECTION_HEADERS_PROCESSED 

We have processed the request headers. Call application callback.

MHD_CONNECTION_CONTINUE_SENDING 

We have processed the headers and need to send 100 CONTINUE.

MHD_CONNECTION_BODY_RECEIVING 

We have sent 100 CONTINUE (or do not need to). Read the message body.

MHD_CONNECTION_BODY_RECEIVED 

We got the request body.

A milestone state. No received data is processed in this state.

MHD_CONNECTION_FOOTERS_RECEIVING 

We are reading the request footers.

MHD_CONNECTION_FOOTERS_RECEIVED 

We received the entire footer.

A milestone state. No received data is processed in this state.

MHD_CONNECTION_FULL_REQ_RECEIVED 

We received the entire request. Wait for a response to be queued.

MHD_CONNECTION_START_REPLY 

Finished reading of the request and the response is ready. Switch internal logic from receiving to sending, prepare connection sending the reply and build the reply header.

MHD_CONNECTION_HEADERS_SENDING 

We have prepared the response headers in the write buffer. Send the response headers.

MHD_CONNECTION_HEADERS_SENT 

We have sent the response headers. Get ready to send the body.

MHD_CONNECTION_NORMAL_BODY_UNREADY 

We are waiting for the client to provide more data of a non-chunked body.

MHD_CONNECTION_NORMAL_BODY_READY 

We are ready to send a part of a non-chunked body. Send it.

MHD_CONNECTION_CHUNKED_BODY_UNREADY 

We are waiting for the client to provide a chunk of the body.

MHD_CONNECTION_CHUNKED_BODY_READY 

We are ready to send a chunk.

MHD_CONNECTION_CHUNKED_BODY_SENT 

We have sent the chunked response body. Prepare the footers.

MHD_CONNECTION_FOOTERS_SENDING 

We have prepared the response footer. Send it.

MHD_CONNECTION_FULL_REPLY_SENT 

We have sent the entire reply. Shutdown connection or restart processing to get a new request.

MHD_CONNECTION_CLOSED 

This connection is to be closed.

Definition at line 612 of file internal.h.

◆ MHD_ConnectionEventLoopInfo

What is this connection waiting for?

Enumerator
MHD_EVENT_LOOP_INFO_READ 

We are waiting to be able to read.

MHD_EVENT_LOOP_INFO_WRITE 

We are waiting to be able to write.

MHD_EVENT_LOOP_INFO_PROCESS 

We are waiting for the application to provide data.

MHD_EVENT_LOOP_INFO_PROCESS_READ 

Some data is ready to be processed, but more data could be read.

MHD_EVENT_LOOP_INFO_CLEANUP 

We are finished and are awaiting cleanup.

Definition at line 214 of file internal.h.

◆ MHD_ConnKeepAlive

Ability to use same connection for next request

Enumerator
MHD_CONN_MUST_CLOSE 

Connection must be closed after sending response.

MHD_CONN_KEEPALIVE_UNKOWN 

KeelAlive state is not yet determined

MHD_CONN_USE_KEEPALIVE 

Connection can be used for serving next request

MHD_CONN_MUST_UPGRADE 

Connection will be upgraded

Definition at line 817 of file internal.h.

◆ MHD_EpollState

State of the socket with respect to epoll (bitmask).

Enumerator
MHD_EPOLL_STATE_UNREADY 

The socket is not involved with a defined state in epoll() right now.

MHD_EPOLL_STATE_READ_READY 

epoll() told us that data was ready for reading, and we did not consume all of it yet.

MHD_EPOLL_STATE_WRITE_READY 

epoll() told us that space was available for writing, and we did not consume all of it yet.

MHD_EPOLL_STATE_IN_EREADY_EDLL 

Is this connection currently in the 'eready' EDLL?

MHD_EPOLL_STATE_IN_EPOLL_SET 

Is this connection currently in the epoll() set?

MHD_EPOLL_STATE_SUSPENDED 

Is this connection currently suspended?

MHD_EPOLL_STATE_ERROR 

Is this connection in some error state?

Definition at line 168 of file internal.h.

◆ MHD_HTTP_Method

The HTTP method.

Only primary methods (specified in RFC9110) are defined here.

Enumerator
MHD_HTTP_MTHD_NO_METHOD 

No request string has been received yet

MHD_HTTP_MTHD_GET 

HTTP method GET

MHD_HTTP_MTHD_HEAD 

HTTP method HEAD

MHD_HTTP_MTHD_POST 

HTTP method POST

MHD_HTTP_MTHD_PUT 

HTTP method PUT

MHD_HTTP_MTHD_DELETE 

HTTP method DELETE

MHD_HTTP_MTHD_CONNECT 

HTTP method CONNECT

MHD_HTTP_MTHD_OPTIONS 

HTTP method OPTIONS

MHD_HTTP_MTHD_TRACE 

HTTP method TRACE

MHD_HTTP_MTHD_OTHER 

Other HTTP method. Check the string value.

Definition at line 898 of file internal.h.

◆ MHD_HTTP_Version

Enumerator
MHD_HTTP_VER_INVALID 

Not a HTTP protocol or HTTP version is invalid.

MHD_HTTP_VER_UNKNOWN 

HTTP version is not yet received from the client.

MHD_HTTP_VER_TOO_OLD 

HTTP version before 1.0, unsupported.

MHD_HTTP_VER_1_0 

HTTP version 1.0

MHD_HTTP_VER_1_1 

HTTP version 1.1

MHD_HTTP_VER_1_2__1_9 

HTTP version 1.2-1.9, must be used as 1.1

MHD_HTTP_VER_FUTURE 

HTTP future version. Unsupported.

Definition at line 840 of file internal.h.

◆ MHD_ResponseAutoFlags

Automatically assigned flags

Enumerator
MHD_RAF_NO_FLAGS 

No auto flags

MHD_RAF_HAS_CONNECTION_HDR 

Has "Connection" header

MHD_RAF_HAS_CONNECTION_CLOSE 

Has "Connection: close"

MHD_RAF_HAS_TRANS_ENC_CHUNKED 

Has "Transfer-Encoding: chunked"

MHD_RAF_HAS_CONTENT_LENGTH 

Has "Content-Length" header

MHD_RAF_HAS_DATE_HDR 

Has "Date" header

Definition at line 404 of file internal.h.

◆ MHD_TLS_CONN_STATE

States of TLS transport layer.

Enumerator
MHD_TLS_CONN_NO_TLS 

Not a TLS connection (plain socket).

MHD_TLS_CONN_INIT 

TLS connection is not established yet.

MHD_TLS_CONN_HANDSHAKING 

TLS is in handshake process.

MHD_TLS_CONN_CONNECTED 

TLS is established.

MHD_TLS_CONN_WR_CLOSING 

Closing WR side of TLS layer.

MHD_TLS_CONN_WR_CLOSED 

WR side of TLS layer is closed.

MHD_TLS_CONN_TLS_CLOSING 

TLS session is terminating.

MHD_TLS_CONN_TLS_CLOSED 

TLS session is terminated.

MHD_TLS_CONN_TLS_FAILED 

TLS session failed.

MHD_TLS_CONN_INVALID_STATE 

Sentinel. Not a valid value.

Definition at line 758 of file internal.h.

◆ MHD_tristate

Tri-state on/off/unknown

Enumerator
_MHD_UNKNOWN 

State is not yet checked nor set

_MHD_OFF 

State is "off" / "disabled"

_MHD_NO 

State is "off" / "disabled"

_MHD_ON 

State is "on" / "enabled"

_MHD_YES 

State is "on" / "enabled"

Definition at line 155 of file internal.h.

Function Documentation

◆ internal_suspend_connection_()

void internal_suspend_connection_ ( struct MHD_Connection connection)

Internal version of MHD_suspend_connection().

Remarks
In thread-per-connection mode: can be called from any thread, in any other mode: to be called only from thread that process daemon's select()/poll()/etc.
Parameters
connectionthe connection to suspend

Internal version of MHD_suspend_connection().

Remarks
In thread-per-connection mode: can be called from any thread, in any other mode: to be called only from thread that process daemon's select()/poll()/etc.
Parameters
connectionthe connection to suspend

Definition at line 3224 of file daemon.c.

References _, MHD_Daemon::cleanup_connection_mutex, MHD_Connection::connection_timeout_ms, MHD_Daemon::connection_timeout_ms, MHD_Daemon::connections_head, MHD_Daemon::connections_tail, MHD_Connection::daemon, DLL_insert, DLL_remove, EDLL_remove, MHD_Daemon::manual_timeout_head, MHD_Daemon::manual_timeout_tail, mhd_assert, MHD_D_IS_USING_EPOLL_, MHD_D_IS_USING_THREAD_PER_CONN_, MHD_D_IS_USING_THREADS_, MHD_EPOLL_STATE_IN_EPOLL_SET, MHD_EPOLL_STATE_IN_EREADY_EDLL, MHD_EPOLL_STATE_SUSPENDED, MHD_mutex_lock_chk_, MHD_mutex_unlock_chk_, MHD_PANIC, MHD_thread_handle_ID_is_current_thread_, MHD_Daemon::normal_timeout_head, MHD_Daemon::normal_timeout_tail, NULL, MHD_Connection::resuming, MHD_Connection::socket_fd, MHD_Connection::suspended, MHD_Daemon::suspended_connections_head, MHD_Daemon::suspended_connections_tail, MHD_Daemon::worker_pool, and XDLL_remove.

Referenced by MHD_suspend_connection().

Here is the caller graph for this function:

◆ MHD_check_response_header_token_ci()

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.

Parameters
responsethe response to query
keyheader name
key_lenthe length of key, not including optional terminating null-character.
tokenthe token to find
token_lenthe length of token, not including optional terminating null-character.
Returns
true if token is found in specified header, false otherwise

Definition at line 930 of file response.c.

References MHD_Response::first_header, MHD_HTTP_Res_Header::header, MHD_HTTP_Res_Header::header_size, MHD_HTTP_Res_Header::kind, mhd_assert, MHD_HEADER_KIND, MHD_str_equal_caseless_bin_n_(), MHD_str_has_token_caseless_(), MHD_HTTP_Res_Header::next, NULL, and MHD_HTTP_Res_Header::value.

Here is the call graph for this function:

◆ MHD_get_master()

_MHD_static_inline struct MHD_Daemon * MHD_get_master ( struct MHD_Daemon *const  daemon)

Trace up to and return master daemon. If the supplied daemon is a master, then return the daemon itself.

Parameters
daemonhandle to a daemon
Returns
master daemon handle

Definition at line 2900 of file internal.h.

References MHD_Daemon::master, mhd_assert, and NULL.

Referenced by calculate_add_nonce(), calculate_add_nonce_with_retry(), check_nonce_nc(), digest_auth_check_all_inner(), MHD_get_connection_info(), MHD_ip_limit_add(), MHD_ip_limit_del(), and queue_auth_required_response3_inner().

Here is the caller graph for this function:

◆ MHD_parse_arguments_()

enum MHD_Result MHD_parse_arguments_ ( struct MHD_Connection connection,
enum MHD_ValueKind  kind,
char *  args,
MHD_ArgumentIterator_  cb,
void *  cls 
)

Parse and unescape the arguments given by the client as part of the HTTP request URI.

Parameters
kindheader kind to pass to cb
connectionconnection to add headers to
[in,out]argsargument URI string (after "?" in URI), clobbered in the process!
cbfunction to call on each key-value pair found
clsthe iterator context
Returns
MHD_NO on failure (cb returned MHD_NO), MHD_YES for success (parsing succeeded, cb always returned MHD_YES)

Definition at line 169 of file internal.c.

References MHD_Connection::daemon, MHD_NO, MHD_unescape_plus(), MHD_YES, NULL, MHD_Daemon::unescape_callback, and MHD_Daemon::unescape_callback_cls.

Here is the call graph for this function:

◆ MHD_unescape_plus()

void MHD_unescape_plus ( char *  arg)

Convert all occurrences of '+' to ' '.

Parameters
argstring that is modified (in place), must be 0-terminated

Definition at line 123 of file internal.c.

References NULL.

Referenced by MHD_parse_arguments_(), MHD_parse_arguments_(), post_process_urlencoded(), and process_value().

Here is the caller graph for this function:

Variable Documentation

◆ _MHD_FIXED_ENUM

enum MHD_HTTP_Method _MHD_FIXED_ENUM

◆ _MHD_FIXED_FLAGS_ENUM

enum MHD_ResponseAutoFlags _MHD_FIXED_FLAGS_ENUM