internal.h File Reference

internal shared structures More...

#include "platform.h"
#include "microhttpd.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_HTTP_Header
struct  MHD_Response
struct  MHD_Connection
struct  MHD_Daemon

Defines

#define EXTRA_CHECKS   MHD_YES
#define MHD_MAX(a, b)   ((a)<(b)) ? (b) : (a)
#define MHD_MIN(a, b)   ((a)<(b)) ? (a) : (b)
#define MHD_BUF_INC_SIZE   2048
#define DEBUG_STATES   MHD_NO
#define EXTRA_CHECK(a)   if (!(a)) abort();

Typedefs

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 *write_to, size_t max_bytes)
typedef void *(* LogCallback )(void *cls, const char *uri)

Enumerations

enum  MHD_CONNECTION_STATE {
  MHD_CONNECTION_INIT = 0, MHD_CONNECTION_URL_RECEIVED = MHD_CONNECTION_INIT + 1, MHD_CONNECTION_HEADER_PART_RECEIVED = MHD_CONNECTION_URL_RECEIVED + 1, MHD_CONNECTION_HEADERS_RECEIVED = MHD_CONNECTION_HEADER_PART_RECEIVED + 1,
  MHD_CONNECTION_HEADERS_PROCESSED = MHD_CONNECTION_HEADERS_RECEIVED + 1, MHD_CONNECTION_CONTINUE_SENDING = MHD_CONNECTION_HEADERS_PROCESSED + 1, MHD_CONNECTION_CONTINUE_SENT = MHD_CONNECTION_CONTINUE_SENDING + 1, MHD_CONNECTION_BODY_RECEIVED = MHD_CONNECTION_CONTINUE_SENT + 1,
  MHD_CONNECTION_FOOTER_PART_RECEIVED = MHD_CONNECTION_BODY_RECEIVED + 1, MHD_CONNECTION_FOOTERS_RECEIVED = MHD_CONNECTION_FOOTER_PART_RECEIVED + 1, MHD_CONNECTION_HEADERS_SENDING = MHD_CONNECTION_FOOTERS_RECEIVED + 1, MHD_CONNECTION_HEADERS_SENT = MHD_CONNECTION_HEADERS_SENDING + 1,
  MHD_CONNECTION_NORMAL_BODY_READY = MHD_CONNECTION_HEADERS_SENT + 1, MHD_CONNECTION_NORMAL_BODY_UNREADY = MHD_CONNECTION_NORMAL_BODY_READY + 1, MHD_CONNECTION_CHUNKED_BODY_READY = MHD_CONNECTION_NORMAL_BODY_UNREADY + 1, MHD_CONNECTION_CHUNKED_BODY_UNREADY = MHD_CONNECTION_CHUNKED_BODY_READY + 1,
  MHD_CONNECTION_BODY_SENT = MHD_CONNECTION_CHUNKED_BODY_UNREADY + 1, MHD_CONNECTION_FOOTERS_SENDING = MHD_CONNECTION_BODY_SENT + 1, MHD_CONNECTION_FOOTERS_SENT = MHD_CONNECTION_FOOTERS_SENDING + 1, MHD_CONNECTION_CLOSED = MHD_CONNECTION_FOOTERS_SENT + 1,
  MHD_TLS_CONNECTION_INIT = MHD_CONNECTION_CLOSED + 1, MHD_TLS_HELLO_REQUEST, MHD_TLS_HANDSHAKE_FAILED, MHD_TLS_HANDSHAKE_COMPLETE
}

Functions

void MHD_tls_log_func (int level, const char *str)
size_t MHD_http_unescape (char *val)
char * MHD_state_to_string (enum MHD_CONNECTION_STATE state)

Detailed Description

internal shared structures

Author:
Daniel Pittman
Christian Grothoff

Definition in file internal.h.


Define Documentation

#define DEBUG_STATES   MHD_NO

Should all state transitions be printed to stderr?

Definition at line 319 of file internal.h.

#define EXTRA_CHECK (  )     if (!(a)) abort();
#define EXTRA_CHECKS   MHD_YES

Definition at line 36 of file internal.h.

#define MHD_BUF_INC_SIZE   2048

Size by which MHD usually tries to increment read/write buffers. TODO: we should probably get rid of this magic constant and put in code to automatically determine a good value.

Definition at line 46 of file internal.h.

Referenced by get_next_header_line(), MHD_connection_handle_read(), MHD_create_response_from_callback(), and try_grow_read_buffer().

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

Definition at line 38 of file internal.h.

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

Definition at line 39 of file internal.h.

Referenced by try_ready_normal_body().


Typedef Documentation

typedef void*(* LogCallback)(void *cls, const char *uri)

Definition at line 618 of file internal.h.

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

Function to receive plaintext data.

Parameters:
conn the connection struct
write_to where to write received data
max_bytes maximum number of bytes to receive
Returns:
number of bytes written to write_to

Definition at line 333 of file internal.h.

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

Function to transmit plaintext data.

Parameters:
conn the connection struct
read_from where to read data to transmit
max_bytes maximum number of bytes to transmit
Returns:
number of bytes transmitted

Definition at line 345 of file internal.h.


Enumeration Type Documentation

States in a state machine for a connection.

Transitions are any-state to CLOSED, any state to state+1, FOOTERS_SENT to INIT. CLOSED is the terminal state and 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 CLOSED or 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_URL_RECEIVED 

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

MHD_CONNECTION_HEADER_PART_RECEIVED 

2: We got part of a multi-line request header. Wait for the rest.

MHD_CONNECTION_HEADERS_RECEIVED 

3: We got the request headers. Process them.

MHD_CONNECTION_HEADERS_PROCESSED 

4: We have processed the request headers. Send 100 continue.

MHD_CONNECTION_CONTINUE_SENDING 

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

MHD_CONNECTION_CONTINUE_SENT 

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

MHD_CONNECTION_BODY_RECEIVED 

7: We got the request body. Wait for a line of the footer.

MHD_CONNECTION_FOOTER_PART_RECEIVED 

8: We got part of a line of the footer. Wait for the rest.

MHD_CONNECTION_FOOTERS_RECEIVED 

9: We received the entire footer. Wait for a response to be queued and prepare the response headers.

MHD_CONNECTION_HEADERS_SENDING 

10: We have prepared the response headers in the writ buffer. Send the response headers.

MHD_CONNECTION_HEADERS_SENT 

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

MHD_CONNECTION_NORMAL_BODY_READY 

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

MHD_CONNECTION_NORMAL_BODY_UNREADY 

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

MHD_CONNECTION_CHUNKED_BODY_READY 

14: We are ready to send a chunk.

MHD_CONNECTION_CHUNKED_BODY_UNREADY 

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

MHD_CONNECTION_BODY_SENT 

16: We have sent the response body. Prepare the footers.

MHD_CONNECTION_FOOTERS_SENDING 

17: We have prepared the response footer. Send it.

MHD_CONNECTION_FOOTERS_SENT 

18: We have sent the response footer. Shutdown or restart.

MHD_CONNECTION_CLOSED 

19: This connection is closed (no more activity allowed).

MHD_TLS_CONNECTION_INIT 

The initial connection state for all secure connectoins Handshake messages will be processed in this state & while in the 'MHD_TLS_HELLO_REQUEST' state

MHD_TLS_HELLO_REQUEST 

This state indicates the server has send a 'Hello Request' to the client & a renegotiation of the handshake is in progress.

Handshake messages will processed in this state & while in the 'MHD_TLS_CONNECTION_INIT' state

MHD_TLS_HANDSHAKE_FAILED 
MHD_TLS_HANDSHAKE_COMPLETE 

Definition at line 182 of file internal.h.


Function Documentation

size_t MHD_http_unescape ( char *  val  ) 

Process escape sequences ('+'=space, HH). Updates val in place.

Returns:
length of the resulting val (strlen(val) maybe shorter afterwards due to elimination of escape sequences)

Process escape sequences ('+'=space, HH)

Definition at line 122 of file internal.c.

References SSCANF.

Referenced by parse_arguments(), parse_initial_message_line(), and post_process_urlencoded().

Here is the caller graph for this function:

char* MHD_state_to_string ( enum MHD_CONNECTION_STATE  state  ) 
void MHD_tls_log_func ( int  level,
const char *  str 
)

Definition at line 111 of file internal.c.

References FPRINTF.


Generated by  doxygen 1.6.2