aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/connection.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/connection.c')
-rw-r--r--src/microhttpd/connection.c56
1 files changed, 38 insertions, 18 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index eac75824..f940145e 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -4995,6 +4995,8 @@ MHD_set_http_callbacks_ (struct MHD_Connection *connection)
4995 4995
4996/** 4996/**
4997 * Obtain information about the given connection. 4997 * Obtain information about the given connection.
4998 * The returned pointer is invalidated with the next call of this function or
4999 * when the connection is closed.
4998 * 5000 *
4999 * @param connection what connection to get information about 5001 * @param connection what connection to get information about
5000 * @param info_type what information is desired? 5002 * @param info_type what information is desired?
@@ -5014,44 +5016,62 @@ MHD_get_connection_info (struct MHD_Connection *connection,
5014 case MHD_CONNECTION_INFO_CIPHER_ALGO: 5016 case MHD_CONNECTION_INFO_CIPHER_ALGO:
5015 if (NULL == connection->tls_session) 5017 if (NULL == connection->tls_session)
5016 return NULL; 5018 return NULL;
5017 connection->cipher = gnutls_cipher_get (connection->tls_session); 5019 connection->connection_info_dummy.cipher_algorithm =
5018 return (const union MHD_ConnectionInfo *) &connection->cipher; 5020 gnutls_cipher_get (connection->tls_session);
5021 return &connection->connection_info_dummy;
5019 case MHD_CONNECTION_INFO_PROTOCOL: 5022 case MHD_CONNECTION_INFO_PROTOCOL:
5020 if (NULL == connection->tls_session) 5023 if (NULL == connection->tls_session)
5021 return NULL; 5024 return NULL;
5022 connection->protocol = gnutls_protocol_get_version ( 5025 connection->connection_info_dummy.protocol =
5023 connection->tls_session); 5026 gnutls_protocol_get_version (connection->tls_session);
5024 return (const union MHD_ConnectionInfo *) &connection->protocol; 5027 return &connection->connection_info_dummy;
5025 case MHD_CONNECTION_INFO_GNUTLS_SESSION: 5028 case MHD_CONNECTION_INFO_GNUTLS_SESSION:
5026 if (NULL == connection->tls_session) 5029 if (NULL == connection->tls_session)
5027 return NULL; 5030 return NULL;
5028 return (const union MHD_ConnectionInfo *) &connection->tls_session; 5031 connection->connection_info_dummy.tls_session = connection->tls_session;
5032 return &connection->connection_info_dummy;
5029#endif /* HTTPS_SUPPORT */ 5033#endif /* HTTPS_SUPPORT */
5030 case MHD_CONNECTION_INFO_CLIENT_ADDRESS: 5034 case MHD_CONNECTION_INFO_CLIENT_ADDRESS:
5031 return (const union MHD_ConnectionInfo *) &connection->addr; 5035 memset (&connection->connection_info_dummy.client_addr, 0,
5036 sizeof (connection->connection_info_dummy.client_addr));
5037 memcpy (&connection->connection_info_dummy.client_addr,
5038 &connection->addr,
5039 connection->addr_len);
5040 return &connection->connection_info_dummy;
5032 case MHD_CONNECTION_INFO_DAEMON: 5041 case MHD_CONNECTION_INFO_DAEMON:
5033 return (const union MHD_ConnectionInfo *) &connection->daemon; 5042 connection->connection_info_dummy.daemon = connection->daemon;
5043 return &connection->connection_info_dummy;
5034 case MHD_CONNECTION_INFO_CONNECTION_FD: 5044 case MHD_CONNECTION_INFO_CONNECTION_FD:
5035 return (const union MHD_ConnectionInfo *) &connection->socket_fd; 5045 connection->connection_info_dummy.connect_fd = connection->socket_fd;
5046 return &connection->connection_info_dummy;
5036 case MHD_CONNECTION_INFO_SOCKET_CONTEXT: 5047 case MHD_CONNECTION_INFO_SOCKET_CONTEXT:
5037 return (const union MHD_ConnectionInfo *) &connection->socket_context; 5048 connection->connection_info_dummy.socket_context =
5049 connection->socket_context;
5050 return &connection->connection_info_dummy;
5038 case MHD_CONNECTION_INFO_CONNECTION_SUSPENDED: 5051 case MHD_CONNECTION_INFO_CONNECTION_SUSPENDED:
5039 connection->suspended_dummy = connection->suspended ? MHD_YES : MHD_NO; 5052 connection->connection_info_dummy.suspended =
5040 return (const union MHD_ConnectionInfo *) &connection->suspended_dummy; 5053 connection->suspended ? MHD_YES : MHD_NO;
5054 return &connection->connection_info_dummy;
5041 case MHD_CONNECTION_INFO_CONNECTION_TIMEOUT: 5055 case MHD_CONNECTION_INFO_CONNECTION_TIMEOUT:
5042 connection->connection_timeout_dummy = 5056#if SIZEOF_UNSIGNED_INT <= (SIZEOF_UINT64_T - 2)
5043 (unsigned int) connection->connection_timeout_ms / 1000; 5057 if (UINT_MAX < connection->connection_timeout_ms / 1000)
5044 return (const union MHD_ConnectionInfo *) &connection-> 5058 connection->connection_info_dummy.connection_timeout = UINT_MAX;
5045 connection_timeout_dummy; 5059 else
5060#endif /* SIZEOF_UNSIGNED_INT <=(SIZEOF_UINT64_T - 2) */
5061 connection->connection_info_dummy.connection_timeout =
5062 (unsigned int) (connection->connection_timeout_ms / 1000);
5063 return &connection->connection_info_dummy;
5046 case MHD_CONNECTION_INFO_REQUEST_HEADER_SIZE: 5064 case MHD_CONNECTION_INFO_REQUEST_HEADER_SIZE:
5047 if ( (MHD_CONNECTION_HEADERS_RECEIVED > connection->state) || 5065 if ( (MHD_CONNECTION_HEADERS_RECEIVED > connection->state) ||
5048 (MHD_CONNECTION_CLOSED == connection->state) ) 5066 (MHD_CONNECTION_CLOSED == connection->state) )
5049 return NULL; /* invalid, too early! */ 5067 return NULL; /* invalid, too early! */
5050 return (const union MHD_ConnectionInfo *) &connection->header_size; 5068 connection->connection_info_dummy.header_size = connection->header_size;
5069 return &connection->connection_info_dummy;
5051 case MHD_CONNECTION_INFO_HTTP_STATUS: 5070 case MHD_CONNECTION_INFO_HTTP_STATUS:
5052 if (NULL == connection->response) 5071 if (NULL == connection->response)
5053 return NULL; 5072 return NULL;
5054 return (const union MHD_ConnectionInfo *) &connection->responseCode; 5073 connection->connection_info_dummy.http_status = connection->responseCode;
5074 return &connection->connection_info_dummy;
5055 default: 5075 default:
5056 return NULL; 5076 return NULL;
5057 } 5077 }