aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-02-14 05:35:48 +0100
committerChristian Grothoff <christian@grothoff.org>2018-02-14 05:53:28 +0100
commitb7dd331e440f36db9c362731afed803148a08fe9 (patch)
tree1d3610547b90240432842268f698d23944823745
parentb14541751ff614f00867ceaf4c0fa21f7c484c58 (diff)
downloadlibmicrohttpd-b7dd331e440f36db9c362731afed803148a08fe9.tar.gz
libmicrohttpd-b7dd331e440f36db9c362731afed803148a08fe9.zip
more lib/ work
-rw-r--r--src/include/microhttpd2.h46
-rw-r--r--src/include/microhttpd_tls.h20
-rw-r--r--src/lib/connection_info.c60
-rw-r--r--src/lib/daemon_info.c63
-rw-r--r--src/lib/daemon_options.c18
-rw-r--r--src/lib/internal.c2
-rw-r--r--src/lib/internal.h52
-rw-r--r--src/lib/request_info.c36
8 files changed, 233 insertions, 64 deletions
diff --git a/src/include/microhttpd2.h b/src/include/microhttpd2.h
index aa0fa0ae..f4b39fbe 100644
--- a/src/include/microhttpd2.h
+++ b/src/include/microhttpd2.h
@@ -2608,7 +2608,14 @@ enum MHD_ConnectionInformationType
2608 * Get connection timeout 2608 * Get connection timeout
2609 * @ingroup request 2609 * @ingroup request
2610 */ 2610 */
2611 MHD_CONNECTION_INFORMATION_CONNECTION_TIMEOUT 2611 MHD_CONNECTION_INFORMATION_CONNECTION_TIMEOUT,
2612
2613 /**
2614 * Check whether the connection is suspended.
2615 * @ingroup request
2616 */
2617 MHD_CONNECTION_INFORMATION_CONNECTION_SUSPENDED
2618
2612 2619
2613}; 2620};
2614 2621
@@ -2654,7 +2661,7 @@ union MHD_ConnectionInformation
2654 /** 2661 /**
2655 * Address information for the client. 2662 * Address information for the client.
2656 */ 2663 */
2657 struct sockaddr *client_addr; 2664 const struct sockaddr *client_addr;
2658 2665
2659 /** 2666 /**
2660 * Which daemon manages this connection (useful in case there are many 2667 * Which daemon manages this connection (useful in case there are many
@@ -2663,10 +2670,16 @@ union MHD_ConnectionInformation
2663 struct MHD_Daemon *daemon; 2670 struct MHD_Daemon *daemon;
2664 2671
2665 /** 2672 /**
2666 * Socket-specific client context. Points to the same address as 2673 * Pointer to connection-specific client context. Points to the
2667 * the "socket_context" of the #MHD_NotifyConnectionCallback. 2674 * same address as the "socket_context" of the
2675 * #MHD_NotifyConnectionCallback.
2676 */
2677 void **socket_context;
2678
2679 /**
2680 * Is this connection right now suspended?
2668 */ 2681 */
2669 void *socket_context; 2682 enum MHD_Bool suspended;
2670}; 2683};
2671 2684
2672 2685
@@ -2721,15 +2734,10 @@ union MHD_RequestInformation
2721 struct MHD_Connection *connection; 2734 struct MHD_Connection *connection;
2722 2735
2723 /** 2736 /**
2724 * Socket-specific client context. Will also be given to 2737 * Pointer to client context. Will also be given to
2725 * the application in a #MHD_RequestTerminationCallback. 2738 * the application in a #MHD_RequestTerminationCallback.
2726 */ 2739 */
2727 void *request_context; 2740 void **request_context;
2728
2729 /**
2730 * The suspended status of a request.
2731 */
2732 enum MHD_Bool suspended;
2733 2741
2734 /** 2742 /**
2735 * HTTP version requested by the client. 2743 * HTTP version requested by the client.
@@ -2762,11 +2770,11 @@ enum MHD_RequestInformationType
2762 MHD_REQUEST_INFORMATION_CONNECTION, 2770 MHD_REQUEST_INFORMATION_CONNECTION,
2763 2771
2764 /** 2772 /**
2765 * Check whether the connection is suspended. 2773 * Returns the client-specific pointer to a `void *` that
2766 * @ingroup request 2774 * is specific to this request.
2767 */ 2775 */
2768 MHD_REQUEST_INFORMATION_SUSPENDED, 2776 MHD_REQUEST_INFORMATION_CLIENT_CONTEXT,
2769 2777
2770 /** 2778 /**
2771 * Return the HTTP version string given by the client. 2779 * Return the HTTP version string given by the client.
2772 * @ingroup request 2780 * @ingroup request
@@ -2837,7 +2845,7 @@ enum MHD_DaemonInformationType
2837 * Request the file descriptor for the listening socket. 2845 * Request the file descriptor for the listening socket.
2838 * No extra arguments should be passed. 2846 * No extra arguments should be passed.
2839 */ 2847 */
2840 MHD_DAEMON_INFORMATION_LISTEN_FD, 2848 MHD_DAEMON_INFORMATION_LISTEN_SOCKET,
2841 2849
2842 /** 2850 /**
2843 * Request the file descriptor for the external epoll. 2851 * Request the file descriptor for the external epoll.
@@ -2871,9 +2879,9 @@ union MHD_DaemonInformation
2871{ 2879{
2872 2880
2873 /** 2881 /**
2874 * Socket, returned for #MHD_DAEMON_INFORMATION_LISTEN_FD. 2882 * Socket, returned for #MHD_DAEMON_INFORMATION_LISTEN_SOCKET.
2875 */ 2883 */
2876 MHD_socket listen_fd; 2884 MHD_socket listen_socket;
2877 2885
2878 /** 2886 /**
2879 * Bind port number, returned for #MHD_DAEMON_INFORMATION_BIND_PORT. 2887 * Bind port number, returned for #MHD_DAEMON_INFORMATION_BIND_PORT.
diff --git a/src/include/microhttpd_tls.h b/src/include/microhttpd_tls.h
index 4f5b0e72..f8e5bd51 100644
--- a/src/include/microhttpd_tls.h
+++ b/src/include/microhttpd_tls.h
@@ -14,6 +14,12 @@
14 14
15 15
16/** 16/**
17 * Data structure kept per TLS client by the plugin.
18 */
19struct MHD_TLS_ConnectionState;
20
21
22/**
17 * Callback functions to use for TLS operations. 23 * Callback functions to use for TLS operations.
18 */ 24 */
19struct MHD_TLS_Plugin 25struct MHD_TLS_Plugin
@@ -70,7 +76,19 @@ struct MHD_TLS_Plugin
70 enum MHD_StatusCode 76 enum MHD_StatusCode
71 (*init_mem_trust)(void *cls, 77 (*init_mem_trust)(void *cls,
72 const char *mem_trust); 78 const char *mem_trust);
73 79
80
81 /**
82 * Function called when we receive a connection and need
83 * to initialize our TLS state for it.
84 *
85 * @param cls the @e cls of this struct
86 * @param ... TBD
87 * @return NULL on error
88 */
89 struct MHD_TLS_ConnectionState *
90 (*setup_connection)(void *cls,
91 ...);
74 92
75 /** 93 /**
76 * TODO: More functions here.... 94 * TODO: More functions here....
diff --git a/src/lib/connection_info.c b/src/lib/connection_info.c
index a4337679..88055fa4 100644
--- a/src/lib/connection_info.c
+++ b/src/lib/connection_info.c
@@ -46,7 +46,65 @@ MHD_connection_get_information_sz (struct MHD_Connection *connection,
46 union MHD_ConnectionInformation *return_value, 46 union MHD_ConnectionInformation *return_value,
47 size_t return_value_size) 47 size_t return_value_size)
48{ 48{
49 return MHD_NO; /* FIXME: not yet implemented */ 49#define CHECK_SIZE(type) if (sizeof(type) < return_value_size) \
50 return MHD_NO
51
52 switch (info_type)
53 {
54#ifdef HTTPS_SUPPORT
55 case MHD_CONNECTION_INFORMATION_CIPHER_ALGO:
56 CHECK_SIZE (int);
57 if (NULL == connection->tls_cs)
58 return MHD_NO;
59 // return_value->cipher_algorithm
60 // = gnutls_cipher_get (connection->tls_session);
61 return MHD_NO; // FIXME: to be implemented
62 case MHD_CONNECTION_INFORMATION_PROTOCOL:
63 CHECK_SIZE (int);
64 if (NULL == connection->tls_cs)
65 return MHD_NO;
66 //return_value->protocol
67 // = gnutls_protocol_get_version (connection->tls_session);
68 return MHD_NO; // FIXME: to be implemented
69 case MHD_CONNECTION_INFORMATION_GNUTLS_SESSION:
70 CHECK_SIZE (void *);
71 if (NULL == connection->tls_cs)
72 return MHD_NO;
73 // return_value->tls_session = connection->tls_session;
74 return MHD_NO; // FIXME: to be implemented
75#endif /* HTTPS_SUPPORT */
76 case MHD_CONNECTION_INFORMATION_CLIENT_ADDRESS:
77 CHECK_SIZE (struct sockaddr *);
78 return_value->client_addr
79 = (const struct sockaddr *) &connection->addr;
80 return MHD_YES;
81 case MHD_CONNECTION_INFORMATION_DAEMON:
82 CHECK_SIZE (struct MHD_Daemon *);
83 return_value->daemon = connection->daemon;
84 return MHD_YES;
85 case MHD_CONNECTION_INFORMATION_CONNECTION_FD:
86 CHECK_SIZE (MHD_socket);
87 return_value->connect_fd = connection->socket_fd;
88 return MHD_YES;
89 case MHD_CONNECTION_INFORMATION_SOCKET_CONTEXT:
90 CHECK_SIZE (void **);
91 return_value->socket_context = &connection->socket_context;
92 return MHD_YES;
93 case MHD_CONNECTION_INFORMATION_CONNECTION_SUSPENDED:
94 CHECK_SIZE (enum MHD_Bool);
95 return_value->suspended
96 = connection->suspended ? MHD_YES : MHD_NO;
97 return MHD_YES;
98 case MHD_CONNECTION_INFORMATION_CONNECTION_TIMEOUT:
99 CHECK_SIZE (unsigned int);
100 return_value->connection_timeout
101 = (unsigned int) connection->connection_timeout;
102 return MHD_YES;
103 default:
104 return MHD_NO;
105 }
106
107#undef CHECK_SIZE
50} 108}
51 109
52/* end of connection_info.c */ 110/* end of connection_info.c */
diff --git a/src/lib/daemon_info.c b/src/lib/daemon_info.c
index 47009687..770f74b9 100644
--- a/src/lib/daemon_info.c
+++ b/src/lib/daemon_info.c
@@ -46,50 +46,59 @@ MHD_daemon_get_information_sz (struct MHD_Daemon *daemon,
46 union MHD_DaemonInformation *return_value, 46 union MHD_DaemonInformation *return_value,
47 size_t return_value_size) 47 size_t return_value_size)
48{ 48{
49#if OLD 49#define CHECK_SIZE(type) if (sizeof(type) < return_value_size) \
50 if (NULL == daemon) 50 return MHD_NO
51 return NULL; 51
52 switch (info_type) 52 switch (info_type)
53 { 53 {
54 case MHD_DAEMON_INFO_KEY_SIZE: 54 case MHD_DAEMON_INFORMATION_LISTEN_SOCKET:
55 return NULL; /* no longer supported */ 55 CHECK_SIZE (MHD_socket);
56 case MHD_DAEMON_INFO_MAC_KEY_SIZE: 56 return_value->listen_socket
57 return NULL; /* no longer supported */ 57 = daemon->listen_socket;
58 case MHD_DAEMON_INFO_LISTEN_FD: 58 return MHD_YES;
59 return (const union MHD_DaemonInfo *) &daemon->listen_fd;
60#ifdef EPOLL_SUPPORT 59#ifdef EPOLL_SUPPORT
61 case MHD_DAEMON_INFO_EPOLL_FD: 60 case MHD_DAEMON_INFORMATION_EPOLL_FD:
62 return (const union MHD_DaemonInfo *) &daemon->epoll_fd; 61 CHECK_SIZE (int);
62 // FIXME: maybe return MHD_NO if we are not using EPOLL?
63 return_value->epoll_fd = daemon->epoll_fd;
64 return MHD_YES;
63#endif 65#endif
64 case MHD_DAEMON_INFO_CURRENT_CONNECTIONS: 66 case MHD_DAEMON_INFORMATION_CURRENT_CONNECTIONS:
65 if (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) 67 CHECK_SIZE (unsigned int);
68 if (MHD_TM_EXTERNAL_EVENT_LOOP == daemon->threading_model)
66 { 69 {
67 /* Assume that MHD_run() in not called in other thread 70 /* Assumes that MHD_run() in not called in other thread
68 * at the same time. */ 71 (of the application) at the same time. */
69 MHD_cleanup_connections (daemon); 72 MHD_cleanup_connections (daemon);
73 return_value->num_connections
74 = daemon->connections;
70 } 75 }
71 else if (daemon->worker_pool) 76 else if (daemon->worker_pool)
72 { 77 {
73 unsigned int i; 78 unsigned int i;
74 /* Collect the connection information stored in the workers. */ 79 /* Collect the connection information stored in the workers. */
75 daemon->connections = 0; 80 return_value->num_connections = 0;
76 for (i = 0; i < daemon->worker_pool_size; i++) 81 for (i = 0; i < daemon->worker_pool_size; i++)
77 { 82 {
78 /* FIXME: next line is thread-safe only if read is atomic. */ 83 /* FIXME: next line is thread-safe only if read is atomic. */
79 daemon->connections += daemon->worker_pool[i].connections; 84 return_value->num_connections
85 += daemon->worker_pool[i].connections;
80 } 86 }
81 } 87 }
82 return (const union MHD_DaemonInfo *) &daemon->connections; 88 else
83 case MHD_DAEMON_INFO_FLAGS: 89 return_value->num_connections
84 return (const union MHD_DaemonInfo *) &daemon->options; 90 = daemon->connections;
85 case MHD_DAEMON_INFO_BIND_PORT: 91 return MHD_YES;
86 return (const union MHD_DaemonInfo *) &daemon->port; 92 case MHD_DAEMON_INFORMATION_BIND_PORT:
93 CHECK_SIZE (uint16_t);
94 // FIXME: return MHD_NO if port is not known/UNIX?
95 return_value->port = daemon->listen_port;
96 return MHD_YES;
87 default: 97 default:
88 return NULL; 98 return MHD_NO;
89 } 99 }
90#else 100
91 return MHD_NO; 101#undef CHECK_SIZE
92#endif
93} 102}
94 103
95/* end of daemon_info.c */ 104/* end of daemon_info.c */
diff --git a/src/lib/daemon_options.c b/src/lib/daemon_options.c
index 640f70c8..4693b692 100644
--- a/src/lib/daemon_options.c
+++ b/src/lib/daemon_options.c
@@ -126,7 +126,7 @@ MHD_daemon_disallow_suspend_resume (struct MHD_Daemon *daemon)
126void 126void
127MHD_daemon_disallow_upgrade (struct MHD_Daemon *daemon) 127MHD_daemon_disallow_upgrade (struct MHD_Daemon *daemon)
128{ 128{
129 daemon->disallow_upgrade; 129 daemon->disallow_upgrade = true;
130} 130}
131 131
132 132
@@ -165,6 +165,7 @@ MHD_daemon_tcp_fastopen (struct MHD_Daemon *daemon,
165 return MHD_NO; 165 return MHD_NO;
166#endif 166#endif
167 } 167 }
168 return MHD_NO;
168} 169}
169 170
170 171
@@ -355,20 +356,20 @@ MHD_daemon_set_tls_backend (struct MHD_Daemon *daemon,
355 if (NULL == 356 if (NULL ==
356 (daemon->tls_backend_lib = dlopen (filename, 357 (daemon->tls_backend_lib = dlopen (filename,
357 RTLD_NOW | RTLD_LOCAL))) 358 RTLD_NOW | RTLD_LOCAL)))
358 return MHD_SC_BACKEND_UNSUPPORTED; /* plugin not found */ 359 return MHD_SC_TLS_BACKEND_UNSUPPORTED; /* plugin not found */
359 if (NULL == (init = dlsym (daemon->tls_backend_lib, 360 if (NULL == (init = dlsym (daemon->tls_backend_lib,
360 "MHD_TLS_init_" MHD_TLS_ABI_VERSION_STR))) 361 "MHD_TLS_init_" MHD_TLS_ABI_VERSION_STR)))
361 362
362 { 363 {
363 dlclose (daemon->tls_backend_lib); 364 dlclose (daemon->tls_backend_lib);
364 daemon->tls_backend_lib = NULL; 365 daemon->tls_backend_lib = NULL;
365 return MHD_SC_BACKEND_UNSUPPORTED; /* possibly wrong version installed */ 366 return MHD_SC_TLS_BACKEND_UNSUPPORTED; /* possibly wrong version installed */
366 } 367 }
367 if (NULL == (daemon->tls_api = init (ciphers))) 368 if (NULL == (daemon->tls_api = init (ciphers)))
368 { 369 {
369 dlclose (daemon->tls_backend_lib); 370 dlclose (daemon->tls_backend_lib);
370 daemon->tls_backend_lib = NULL; 371 daemon->tls_backend_lib = NULL;
371 return MHD_SC_CIPHERS_INVALID; /* possibly wrong version installed */ 372 return MHD_SC_TLS_CIPHERS_INVALID; /* possibly wrong version installed */
372 } 373 }
373 return MHD_SC_OK; 374 return MHD_SC_OK;
374#endif 375#endif
@@ -545,8 +546,8 @@ MHD_daemon_set_early_uri_logger (struct MHD_Daemon *daemon,
545 MHD_EarlyUriLogCallback cb, 546 MHD_EarlyUriLogCallback cb,
546 void *cb_cls) 547 void *cb_cls)
547{ 548{
548 daemon->early_uri_logger = cb; 549 daemon->early_uri_logger_cb = cb;
549 daemon->early_uri_logger_cls = cb_cls; 550 daemon->early_uri_logger_cb_cls = cb_cls;
550} 551}
551 552
552 553
@@ -687,6 +688,9 @@ MHD_daemon_digest_auth_random (struct MHD_Daemon *daemon,
687 daemon->digest_auth_random_buf = buf; 688 daemon->digest_auth_random_buf = buf;
688 daemon->digest_auth_random_buf_size = buf_size; 689 daemon->digest_auth_random_buf_size = buf_size;
689#else 690#else
691 (void) daemon;
692 (void) buf_size;
693 (void) buf;
690 MHD_PANIC ("digest authentication not supported by this build"); 694 MHD_PANIC ("digest authentication not supported by this build");
691#endif 695#endif
692} 696}
@@ -732,6 +736,8 @@ MHD_daemon_digest_auth_nc_length (struct MHD_Daemon *daemon,
732 daemon->digest_nc_length = nc_length; 736 daemon->digest_nc_length = nc_length;
733 return MHD_SC_OK; 737 return MHD_SC_OK;
734#else 738#else
739 (void) daemon;
740 (void) nc_length;
735 return MHD_SC_DIGEST_AUTH_NOT_SUPPORTED_BY_BUILD; 741 return MHD_SC_DIGEST_AUTH_NOT_SUPPORTED_BY_BUILD;
736#endif 742#endif
737} 743}
diff --git a/src/lib/internal.c b/src/lib/internal.c
index 7e8d2286..4422d9ed 100644
--- a/src/lib/internal.c
+++ b/src/lib/internal.c
@@ -238,7 +238,7 @@ MHD_parse_arguments_ (struct MHD_Connection *connection,
238 break; 238 break;
239 } 239 }
240 /* amper is non-NULL here */ 240 /* amper is non-NULL here */
241 amper[0] = '\0';d 241 amper[0] = '\0';
242 amper++; 242 amper++;
243 if ( (NULL == equals) || 243 if ( (NULL == equals) ||
244 (equals >= amper) ) 244 (equals >= amper) )
diff --git a/src/lib/internal.h b/src/lib/internal.h
index 4c3ceddc..4ea6528a 100644
--- a/src/lib/internal.h
+++ b/src/lib/internal.h
@@ -454,7 +454,7 @@ struct MHD_Request
454 * HTTP version string (i.e. http/1.1). Allocated 454 * HTTP version string (i.e. http/1.1). Allocated
455 * in pool. 455 * in pool.
456 */ 456 */
457 char *version; 457 char *version_s;
458 458
459 /** 459 /**
460 * Close connection after sending response? 460 * Close connection after sending response?
@@ -493,7 +493,6 @@ struct MHD_Request
493 */ 493 */
494 char *colon; 494 char *colon;
495 495
496
497 /** 496 /**
498 * Function used for reading HTTP request stream. 497 * Function used for reading HTTP request stream.
499 */ 498 */
@@ -515,11 +514,6 @@ struct MHD_Request
515#endif /* UPGRADE_SUPPORT */ 514#endif /* UPGRADE_SUPPORT */
516 515
517 /** 516 /**
518 * Foreign address (of length @e addr_len).
519 */
520 struct sockaddr_storage addr;
521
522 /**
523 * Thread handle for this connection (if we are using 517 * Thread handle for this connection (if we are using
524 * one thread per connection). 518 * one thread per connection).
525 */ 519 */
@@ -741,7 +735,23 @@ struct MHD_Connection
741 * Reference to the MHD_Daemon struct. 735 * Reference to the MHD_Daemon struct.
742 */ 736 */
743 struct MHD_Daemon *daemon; 737 struct MHD_Daemon *daemon;
738
739 /**
740 * We allow the main application to associate some pointer with the
741 * TCP connection (which may span multiple HTTP requests). Here is
742 * where we store it. (MHD does not know or care what it is).
743 * The location is given to the #MHD_NotifyConnectionCallback and
744 * also accessible via #MHD_CONNECTION_INFO_SOCKET_CONTEXT.
745 */
746 void *socket_context;
744 747
748#ifdef HTTPS_SUPPORT
749 /**
750 * State kept per TLS connection. Plugin-specific.
751 */
752 struct MHD_TLS_ConnectionState *tls_cs;
753#endif
754
745 /** 755 /**
746 * Information about the current request we are processing 756 * Information about the current request we are processing
747 * on this connection. 757 * on this connection.
@@ -749,6 +759,11 @@ struct MHD_Connection
749 struct MHD_Request request; 759 struct MHD_Request request;
750 760
751 /** 761 /**
762 * Foreign address (of length @e addr_len).
763 */
764 struct sockaddr_storage addr;
765
766 /**
752 * Length of the foreign address. 767 * Length of the foreign address.
753 */ 768 */
754 socklen_t addr_len; 769 socklen_t addr_len;
@@ -858,7 +873,7 @@ struct MHD_Daemon
858 /** 873 /**
859 * Closure for @e early_uri_logger_cb. 874 * Closure for @e early_uri_logger_cb.
860 */ 875 */
861 void *early_uri_logger_cls; 876 void *early_uri_logger_cb_cls;
862 877
863 /** 878 /**
864 * Function to call whenever a connection is started or 879 * Function to call whenever a connection is started or
@@ -881,6 +896,17 @@ struct MHD_Daemon
881 * Closure for @e unescape_cb. 896 * Closure for @e unescape_cb.
882 */ 897 */
883 void *unescape_cb_cls; 898 void *unescape_cb_cls;
899
900 /**
901 * Pointer to master daemon (NULL if this is the master)
902 */
903 struct MHD_Daemon *master;
904
905 /**
906 * Worker daemons (one per thread)
907 */
908 struct MHD_Daemon *worker_pool;
909
884 910
885#if HTTPS_SUPPORT 911#if HTTPS_SUPPORT
886 /** 912 /**
@@ -1135,6 +1161,16 @@ struct MHD_Daemon
1135 unsigned int ip_connection_limit; 1161 unsigned int ip_connection_limit;
1136 1162
1137 /** 1163 /**
1164 * Number of active parallel connections.
1165 */
1166 unsigned int connections;
1167
1168 /**
1169 * Number of worker daemons
1170 */
1171 unsigned int worker_pool_size;
1172
1173 /**
1138 * Default timeout in seconds for idle connections. 1174 * Default timeout in seconds for idle connections.
1139 */ 1175 */
1140 time_t connection_default_timeout; 1176 time_t connection_default_timeout;
diff --git a/src/lib/request_info.c b/src/lib/request_info.c
index 4a903ef0..a7342e0a 100644
--- a/src/lib/request_info.c
+++ b/src/lib/request_info.c
@@ -46,7 +46,41 @@ MHD_request_get_information_sz (struct MHD_Request *request,
46 union MHD_RequestInformation *return_value, 46 union MHD_RequestInformation *return_value,
47 size_t return_value_size) 47 size_t return_value_size)
48{ 48{
49 return MHD_NO; /* not implemented */ 49#define CHECK_SIZE(type) if (sizeof(type) < return_value_size) \
50 return MHD_NO
51
52 switch (info_type)
53 {
54 case MHD_REQUEST_INFORMATION_CONNECTION:
55 CHECK_SIZE (struct MHD_Connection *);
56 return_value->connection = request->connection;
57 return MHD_YES;
58 case MHD_REQUEST_INFORMATION_CLIENT_CONTEXT:
59 CHECK_SIZE (void **);
60 return_value->request_context = &request->client_context;
61 return MHD_YES;
62 case MHD_REQUEST_INFORMATION_HTTP_VERSION:
63 CHECK_SIZE (const char *);
64 return_value->http_version = request->version_s;
65 return MHD_YES;
66 case MHD_REQUEST_INFORMATION_HTTP_METHOD:
67 CHECK_SIZE (const char *);
68 return_value->http_method = request->method_s;
69 return MHD_YES;
70 case MHD_REQUEST_INFORMATION_HEADER_SIZE:
71 CHECK_SIZE (size_t);
72 if ( (MHD_REQUEST_HEADERS_RECEIVED > request->state) ||
73 (MHD_REQUEST_CLOSED == request->state) ||
74 (MHD_REQUEST_IN_CLEANUP == request->state) )
75 return MHD_NO; /* invalid, too early! */
76 return_value->header_size = request->header_size;
77 return MHD_YES;
78
79 default:
80 return MHD_NO;
81 }
82
83#undef CHECK_SIZE
50} 84}
51 85
52 86