diff options
Diffstat (limited to 'doc/libmicrohttpd.texi')
-rw-r--r-- | doc/libmicrohttpd.texi | 61 |
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 |
736 | Register a function that should be called when the TCP connection to a | 736 | Register a function that should be called when the TCP connection to a |
737 | client is opened or closed. Note that | 737 | client is opened or closed. The registered callback is called twice per |
738 | @code{MHD_OPTION_NOTIFY_COMPLETED} and the @code{con_cls} argument to | 738 | TCP connection, with @code{MHD_CONNECTION_NOTIFY_STARTED} and |
739 | the @code{MHD_AccessHandlerCallback} are per HTTP request (and there | 739 | @code{MHD_CONNECTION_NOTIFY_CLOSED} respectively. An additional |
740 | can be multiple HTTP requests per TCP connection). The registered | ||
741 | callback is called twice per TCP connection, with | ||
742 | @code{MHD_CONNECTION_NOTIFY_STARTED} and | ||
743 | @code{MHD_CONNECTION_NOTIFY_CLOSED} respectively. An additional | ||
744 | argument can be used to store TCP connection specific information, | 740 | argument can be used to store TCP connection specific information, |
745 | which can be retrieved using @code{MHD_CONNECTION_INFO_SOCKET_CONTEXT} | 741 | which can be retrieved using @code{MHD_CONNECTION_INFO_SOCKET_CONTEXT} |
746 | during the lifetime of the TCP connection. The respective location is | 742 | during the lifetime of the TCP connection. |
747 | not the same as the HTTP-request-specific @code{con_cls} from the | 743 | Note @code{MHD_OPTION_NOTIFY_COMPLETED} and the @code{req_cls} argument |
748 | @code{MHD_AccessHandlerCallback}. | 744 | to the @code{MHD_AccessHandlerCallback} are per HTTP request (and there |
745 | can be multiple HTTP requests per TCP connection). | ||
749 | 746 | ||
750 | This option should be followed by @strong{TWO} pointers. First a | 747 | This option should be followed by @strong{TWO} pointers. First a |
751 | pointer to a function of type @code{MHD_NotifyConnectionCallback()} | 748 | pointer 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 |
822 | where the return value will be passed as | 819 | where 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} |
824 | when this request is processed later; returning a | 821 | when this request is processed later; returning a |
825 | value of @code{NULL} has no special significance; (however, | 822 | value of @code{NULL} has no special significance; (however, |
826 | note that if you return non-@code{NULL}, you can no longer | 823 | note that if you return non-@code{NULL}, you can no longer |
827 | rely on the first call to the access handler having | 824 | rely 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 |
830 | MHD_OPTION_URI_LOG_CALLBACK. Finally, @code{uri} will | 827 | MHD_OPTION_URI_LOG_CALLBACK. Finally, @code{uri} will |
831 | be the 0-terminated URI of the request. | 828 | be 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) |
1812 | Invoked in the context of a connection to answer a request from the | 1809 | Invoked in the context of a connection to answer a request from the |
1813 | client. This callback must call MHD functions (example: the | 1810 | client. 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 | |||
1874 | avoid this, clients must be able to process upload data incrementally | 1871 | avoid this, clients must be able to process upload data incrementally |
1875 | and reduce the value of @code{upload_data_size}. | 1872 | and reduce the value of @code{upload_data_size}. |
1876 | 1873 | ||
1877 | @item con_cls | 1874 | @item req_cls |
1878 | reference to a pointer, initially set to @code{NULL}, that this callback can | 1875 | reference to a pointer, initially set to @code{NULL}, that this callback can |
1879 | set to some address and that will be preserved by MHD for future | 1876 | set to some address and that will be preserved by MHD for future |
1880 | calls for this request; | 1877 | calls 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) |
1894 | Signature of the callback used by MHD to notify the application about | 1891 | Signature of the callback used by MHD to notify the application about |
1895 | completed requests. | 1892 | completed requests. |
1896 | 1893 | ||
@@ -1901,7 +1898,7 @@ custom value selected at callback registration time; | |||
1901 | @item connection | 1898 | @item connection |
1902 | connection handle; | 1899 | connection handle; |
1903 | 1900 | ||
1904 | @item con_cls | 1901 | @item req_cls |
1905 | value as set by the last call to the | 1902 | value 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 |
2945 | identifies the connection that is being upgraded; | 2942 | identifies the connection that is being upgraded; |
2946 | 2943 | ||
2947 | @item con_cls | 2944 | @item req_cls |
2948 | last value left in `*con_cls` in the `MHD_AccessHandlerCallback` | 2945 | last value left in `*req_cls` in the `MHD_AccessHandlerCallback` |
2949 | 2946 | ||
2950 | @item extra_in | 2947 | @item extra_in |
2951 | buffer 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. | 2948 | buffer 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 | |||
3377 | be processed. The arguments @var{upload_data} and @var{upload_data_size} | 3374 | be processed. The arguments @var{upload_data} and @var{upload_data_size} |
3378 | are used to reference the chunk of data. | 3375 | are used to reference the chunk of data. |
3379 | 3376 | ||
3380 | When @code{MHD_AccessHandlerCallback} is invoked for a new connection: | 3377 | When @code{MHD_AccessHandlerCallback} is invoked for a new request: |
3381 | its @code{*@var{con_cls}} argument is set to @code{NULL}. When @code{POST} | 3378 | its @code{*@var{req_cls}} argument is set to @code{NULL}. When @code{POST} |
3382 | data comes in the upload buffer it is @strong{mandatory} to use the | 3379 | data 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 |
3384 | that the pointer was initially @code{NULL} can be used to detect that | 3381 | that the pointer was initially @code{NULL} can be used to detect that |
3385 | this is a new request. | 3382 | this is a new request. |
3386 | 3383 | ||
3387 | One method to detect that a new connection was established is | 3384 | One method to detect that a new request was started is |
3388 | to set @code{*con_cls} to an unused integer: | 3385 | to set @code{*req_cls} to an unused integer: |
3389 | 3386 | ||
3390 | @example | 3387 | @example |
3391 | int | 3388 | int |
@@ -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 |
3413 | In contrast to the previous example, for @code{POST} requests in particular, | 3410 | In contrast to the previous example, for @code{POST} requests in particular, |
3414 | it is more common to use the value of @code{*con_cls} to keep track of | 3411 | it is more common to use the value of @code{*req_cls} to keep track of |
3415 | actual state used during processing, such as the post processor (or a | 3412 | actual state used during processing, such as the post processor (or a |
3416 | struct containing a post processor): | 3413 | struct 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. | |||
3719 | Returns the client-specific pointer to a @code{void *} that was | 3716 | Returns 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 |
3721 | socket was first accepted. Note that this is NOT the same as the | 3718 | socket 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 | ||
3726 | Takes no extra arguments. | 3723 | Takes no extra arguments. |