aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/microhttpd/connection.c41
-rw-r--r--src/microhttpd/connection.h8
-rw-r--r--src/microhttpd/daemon.c3
3 files changed, 52 insertions, 0 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index be9c5525..4716eb0f 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -6069,6 +6069,47 @@ cleanup_connection (struct MHD_Connection *connection)
6069 6069
6070 6070
6071/** 6071/**
6072 * Set initial internal states for the connection to start reading and
6073 * processing incoming data.
6074 * @param c the connection to process
6075 */
6076void
6077MHD_connection_set_initial_state_ (struct MHD_Connection *c)
6078{
6079 size_t read_buf_size;
6080
6081#ifdef HTTPS_SUPPORT
6082 mhd_assert ( (0 == (c->daemon->options & MHD_USE_TLS)) || \
6083 (MHD_TLS_CONN_INIT == c->tls_state) );
6084 mhd_assert ( (0 != (c->daemon->options & MHD_USE_TLS)) || \
6085 (MHD_TLS_CONN_NO_TLS == c->tls_state) );
6086#endif /* HTTPS_SUPPORT */
6087 mhd_assert (MHD_CONNECTION_INIT == c->state);
6088
6089 c->keepalive = MHD_CONN_KEEPALIVE_UNKOWN;
6090 c->event_loop_info = MHD_EVENT_LOOP_INFO_READ;
6091
6092 memset (&c->rq, 0, sizeof(c->rq));
6093 memset (&c->rp, 0, sizeof(c->rp));
6094
6095 c->write_buffer = NULL;
6096 c->write_buffer_size = 0;
6097 c->write_buffer_send_offset = 0;
6098 c->write_buffer_append_offset = 0;
6099
6100 c->continue_message_write_offset = 0;
6101
6102 c->read_buffer_offset = 0;
6103 read_buf_size = c->daemon->pool_size / 2;
6104 c->read_buffer
6105 = MHD_pool_allocate (c->pool,
6106 read_buf_size,
6107 false);
6108 c->read_buffer_size = read_buf_size;
6109}
6110
6111
6112/**
6072 * Reset connection after request-reply cycle. 6113 * Reset connection after request-reply cycle.
6073 * @param connection the connection to process 6114 * @param connection the connection to process
6074 * @param reuse the flag to choose whether to close connection or 6115 * @param reuse the flag to choose whether to close connection or
diff --git a/src/microhttpd/connection.h b/src/microhttpd/connection.h
index 693e26fc..67a251a8 100644
--- a/src/microhttpd/connection.h
+++ b/src/microhttpd/connection.h
@@ -87,6 +87,14 @@ MHD_set_http_callbacks_ (struct MHD_Connection *connection);
87 87
88 88
89/** 89/**
90 * Set initial internal states for the connection to start reading and
91 * processing incoming data.
92 * @param c the connection to process
93 */
94void
95MHD_connection_set_initial_state_ (struct MHD_Connection *c);
96
97/**
90 * This function handles a particular connection when it has been 98 * This function handles a particular connection when it has been
91 * determined that there is data to be read off a socket. All 99 * determined that there is data to be read off a socket. All
92 * implementations (multithreaded, external polling, internal polling) 100 * implementations (multithreaded, external polling, internal polling)
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index f9ffb388..f310e1c7 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -2801,6 +2801,9 @@ new_connection_process_ (struct MHD_Daemon *daemon,
2801 connection); 2801 connection);
2802 } 2802 }
2803 MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex); 2803 MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
2804
2805 MHD_connection_set_initial_state_ (connection);
2806
2804 if (NULL != daemon->notify_connection) 2807 if (NULL != daemon->notify_connection)
2805 daemon->notify_connection (daemon->notify_connection_cls, 2808 daemon->notify_connection (daemon->notify_connection_cls,
2806 connection, 2809 connection,