aboutsummaryrefslogtreecommitdiff
path: root/doc/libmicrohttpd.texi
diff options
context:
space:
mode:
Diffstat (limited to 'doc/libmicrohttpd.texi')
-rw-r--r--doc/libmicrohttpd.texi61
1 files changed, 29 insertions, 32 deletions
diff --git a/doc/libmicrohttpd.texi b/doc/libmicrohttpd.texi
index a6bd12eb..a14c28d3 100644
--- a/doc/libmicrohttpd.texi
+++ b/doc/libmicrohttpd.texi
@@ -734,18 +734,15 @@ callback. The second pointer maybe @code{NULL}.
734 734
735@item MHD_OPTION_NOTIFY_CONNECTION 735@item MHD_OPTION_NOTIFY_CONNECTION
736Register a function that should be called when the TCP connection to a 736Register a function that should be called when the TCP connection to a
737client is opened or closed. Note that 737client is opened or closed. The registered callback is called twice per
738@code{MHD_OPTION_NOTIFY_COMPLETED} and the @code{con_cls} argument to 738TCP connection, with @code{MHD_CONNECTION_NOTIFY_STARTED} and
739the @code{MHD_AccessHandlerCallback} are per HTTP request (and there 739@code{MHD_CONNECTION_NOTIFY_CLOSED} respectively. An additional
740can be multiple HTTP requests per TCP connection). The registered
741callback is called twice per TCP connection, with
742@code{MHD_CONNECTION_NOTIFY_STARTED} and
743@code{MHD_CONNECTION_NOTIFY_CLOSED} respectively. An additional
744argument can be used to store TCP connection specific information, 740argument can be used to store TCP connection specific information,
745which can be retrieved using @code{MHD_CONNECTION_INFO_SOCKET_CONTEXT} 741which can be retrieved using @code{MHD_CONNECTION_INFO_SOCKET_CONTEXT}
746during the lifetime of the TCP connection. The respective location is 742during the lifetime of the TCP connection.
747not the same as the HTTP-request-specific @code{con_cls} from the 743Note @code{MHD_OPTION_NOTIFY_COMPLETED} and the @code{req_cls} argument
748@code{MHD_AccessHandlerCallback}. 744to the @code{MHD_AccessHandlerCallback} are per HTTP request (and there
745can be multiple HTTP requests per TCP connection).
749 746
750This option should be followed by @strong{TWO} pointers. First a 747This option should be followed by @strong{TWO} pointers. First a
751pointer to a function of type @code{MHD_NotifyConnectionCallback()} 748pointer to a function of type @code{MHD_NotifyConnectionCallback()}
@@ -820,12 +817,12 @@ one must be of the form
820 void * my_logger(void * cls, const char * uri, struct MHD_Connection *con) 817 void * my_logger(void * cls, const char * uri, struct MHD_Connection *con)
821@end example 818@end example
822where the return value will be passed as 819where the return value will be passed as
823@code{*con_cls} in calls to the @code{MHD_AccessHandlerCallback} 820@code{*req_cls} in calls to the @code{MHD_AccessHandlerCallback}
824when this request is processed later; returning a 821when this request is processed later; returning a
825value of @code{NULL} has no special significance; (however, 822value of @code{NULL} has no special significance; (however,
826note that if you return non-@code{NULL}, you can no longer 823note that if you return non-@code{NULL}, you can no longer
827rely on the first call to the access handler having 824rely on the first call to the access handler having
828@code{NULL == *con_cls} on entry) 825@code{NULL == *req_cls} on entry)
829@code{cls} will be set to the second argument following 826@code{cls} will be set to the second argument following
830MHD_OPTION_URI_LOG_CALLBACK. Finally, @code{uri} will 827MHD_OPTION_URI_LOG_CALLBACK. Finally, @code{uri} will
831be the 0-terminated URI of the request. 828be the 0-terminated URI of the request.
@@ -1808,7 +1805,7 @@ length of the address information.
1808@end deftypefn 1805@end deftypefn
1809 1806
1810 1807
1811@deftypefn {Function Pointer} enum MHD_Result {*MHD_AccessHandlerCallback} (void *cls, struct MHD_Connection * connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **con_cls) 1808@deftypefn {Function Pointer} enum MHD_Result {*MHD_AccessHandlerCallback} (void *cls, struct MHD_Connection * connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **req_cls)
1812Invoked in the context of a connection to answer a request from the 1809Invoked in the context of a connection to answer a request from the
1813client. This callback must call MHD functions (example: the 1810client. This callback must call MHD functions (example: the
1814@code{MHD_Response} ones) to provide content to give back to the client 1811@code{MHD_Response} ones) to provide content to give back to the client
@@ -1874,7 +1871,7 @@ and return an internal server error to the client. In order to
1874avoid this, clients must be able to process upload data incrementally 1871avoid this, clients must be able to process upload data incrementally
1875and reduce the value of @code{upload_data_size}. 1872and reduce the value of @code{upload_data_size}.
1876 1873
1877@item con_cls 1874@item req_cls
1878reference to a pointer, initially set to @code{NULL}, that this callback can 1875reference to a pointer, initially set to @code{NULL}, that this callback can
1879set to some address and that will be preserved by MHD for future 1876set to some address and that will be preserved by MHD for future
1880calls for this request; 1877calls for this request;
@@ -1890,7 +1887,7 @@ if necessary, this state can be cleaned up in the global
1890@end deftypefn 1887@end deftypefn
1891 1888
1892 1889
1893@deftypefn {Function Pointer} void {*MHD_RequestCompletedCallback} (void *cls, struct MHD_Connectionconnection, void **con_cls, enum MHD_RequestTerminationCode toe) 1890@deftypefn {Function Pointer} void {*MHD_RequestCompletedCallback} (void *cls, struct MHD_Connectionconnection, void **req_cls, enum MHD_RequestTerminationCode toe)
1894Signature of the callback used by MHD to notify the application about 1891Signature of the callback used by MHD to notify the application about
1895completed requests. 1892completed requests.
1896 1893
@@ -1901,7 +1898,7 @@ custom value selected at callback registration time;
1901@item connection 1898@item connection
1902connection handle; 1899connection handle;
1903 1900
1904@item con_cls 1901@item req_cls
1905value as set by the last call to the 1902value as set by the last call to the
1906@code{MHD_AccessHandlerCallback}; 1903@code{MHD_AccessHandlerCallback};
1907 1904
@@ -2944,8 +2941,8 @@ matches the @code{upgrade_handler_cls} that was given to @code{MHD_create_respon
2944@item connection 2941@item connection
2945identifies the connection that is being upgraded; 2942identifies the connection that is being upgraded;
2946 2943
2947@item con_cls 2944@item req_cls
2948last value left in `*con_cls` in the `MHD_AccessHandlerCallback` 2945last value left in `*req_cls` in the `MHD_AccessHandlerCallback`
2949 2946
2950@item extra_in 2947@item extra_in
2951buffer of bytes MHD read ``by accident'' from the socket already. This can happen if the client eagerly transmits more than just the HTTP request. The application should treat these as if it had read them from the socket. 2948buffer of bytes MHD read ``by accident'' from the socket already. This can happen if the client eagerly transmits more than just the HTTP request. The application should treat these as if it had read them from the socket.
@@ -3377,15 +3374,15 @@ process data as it arrives; at each invocation a new chunk of data must
3377be processed. The arguments @var{upload_data} and @var{upload_data_size} 3374be processed. The arguments @var{upload_data} and @var{upload_data_size}
3378are used to reference the chunk of data. 3375are used to reference the chunk of data.
3379 3376
3380When @code{MHD_AccessHandlerCallback} is invoked for a new connection: 3377When @code{MHD_AccessHandlerCallback} is invoked for a new request:
3381its @code{*@var{con_cls}} argument is set to @code{NULL}. When @code{POST} 3378its @code{*@var{req_cls}} argument is set to @code{NULL}. When @code{POST}
3382data comes in the upload buffer it is @strong{mandatory} to use the 3379data comes in the upload buffer it is @strong{mandatory} to use the
3383@var{con_cls} to store a reference to per-connection data. The fact 3380@var{req_cls} to store a reference to per-request data. The fact
3384that the pointer was initially @code{NULL} can be used to detect that 3381that the pointer was initially @code{NULL} can be used to detect that
3385this is a new request. 3382this is a new request.
3386 3383
3387One method to detect that a new connection was established is 3384One method to detect that a new request was started is
3388to set @code{*con_cls} to an unused integer: 3385to set @code{*req_cls} to an unused integer:
3389 3386
3390@example 3387@example
3391int 3388int
@@ -3394,15 +3391,15 @@ access_handler (void *cls,
3394 const char *url, 3391 const char *url,
3395 const char *method, const char *version, 3392 const char *method, const char *version,
3396 const char *upload_data, size_t *upload_data_size, 3393 const char *upload_data, size_t *upload_data_size,
3397 void **con_cls) 3394 void **req_cls)
3398@{ 3395@{
3399 static int old_connection_marker; 3396 static int old_connection_marker;
3400 int new_connection = (NULL == *con_cls); 3397 int new_connection = (NULL == *req_cls);
3401 3398
3402 if (new_connection) 3399 if (new_connection)
3403 @{ 3400 @{
3404 /* new connection with POST */ 3401 /* new connection with POST */
3405 *con_cls = &old_connection_marker; 3402 *req_cls = &old_connection_marker;
3406 @} 3403 @}
3407 3404
3408 ... 3405 ...
@@ -3411,7 +3408,7 @@ access_handler (void *cls,
3411 3408
3412@noindent 3409@noindent
3413In contrast to the previous example, for @code{POST} requests in particular, 3410In contrast to the previous example, for @code{POST} requests in particular,
3414it is more common to use the value of @code{*con_cls} to keep track of 3411it is more common to use the value of @code{*req_cls} to keep track of
3415actual state used during processing, such as the post processor (or a 3412actual state used during processing, such as the post processor (or a
3416struct containing a post processor): 3413struct containing a post processor):
3417 3414
@@ -3422,14 +3419,14 @@ access_handler (void *cls,
3422 const char *url, 3419 const char *url,
3423 const char *method, const char *version, 3420 const char *method, const char *version,
3424 const char *upload_data, size_t *upload_data_size, 3421 const char *upload_data, size_t *upload_data_size,
3425 void **con_cls) 3422 void **req_cls)
3426@{ 3423@{
3427 struct MHD_PostProcessor * pp = *con_cls; 3424 struct MHD_PostProcessor * pp = *req_cls;
3428 3425
3429 if (pp == NULL) 3426 if (pp == NULL)
3430 @{ 3427 @{
3431 pp = MHD_create_post_processor(connection, ...); 3428 pp = MHD_create_post_processor(connection, ...);
3432 *con_cls = pp; 3429 *req_cls = pp;
3433 return MHD_YES; 3430 return MHD_YES;
3434 @} 3431 @}
3435 if (*upload_data_size) 3432 if (*upload_data_size)
@@ -3719,8 +3716,8 @@ Takes no extra arguments.
3719Returns the client-specific pointer to a @code{void *} that was 3716Returns the client-specific pointer to a @code{void *} that was
3720(possibly) set during a @code{MHD_NotifyConnectionCallback} when the 3717(possibly) set during a @code{MHD_NotifyConnectionCallback} when the
3721socket was first accepted. Note that this is NOT the same as the 3718socket was first accepted. Note that this is NOT the same as the
3722@code{con_cls} argument of the @code{MHD_AccessHandlerCallback}. The 3719@code{req_cls} argument of the @code{MHD_AccessHandlerCallback}. The
3723@code{con_cls} is fresh for each HTTP request, while the 3720@code{req_cls} is fresh for each HTTP request, while the
3724@code{socket_context} is fresh for each socket. 3721@code{socket_context} is fresh for each socket.
3725 3722
3726Takes no extra arguments. 3723Takes no extra arguments.