moonbridge

diff reference.txt @ 184:97d3ca77c86a

Code cleanup, renamed functions, added documentation for HTTP module
author jbe
date Fri Jun 19 18:24:58 2015 +0200 (2015-06-19)
parents 2a5bd37034c6
children 5601a486e68a
line diff
     1.1 --- a/reference.txt	Fri Jun 19 16:54:33 2015 +0200
     1.2 +++ b/reference.txt	Fri Jun 19 18:24:58 2015 +0200
     1.3 @@ -432,34 +432,32 @@
     1.4  
     1.5  A corresponding "Connection: close" header is automatically sent.
     1.6  
     1.7 +See also request:monologue().
     1.8 +
     1.9 +
    1.10 +### request:consume_input()
    1.11 +
    1.12 +Starts processing the request body (if existent) to set the values
    1.13 +request.post_params, request.post_params_list, request.post_metadata, and
    1.14 +and request.post_metadata_list and/or to call POST field stream handlers that
    1.15 +have been previously registered with request:stream_post_param(...) or
    1.16 +request:stream_post_params(...), or to call a previously registered request
    1.17 +body stream handler that was set with request:set_request_body_streamer().
    1.18 +
    1.19 +This method gets invoked automatically when the POST param tables
    1.20 +(request.post_params, etc.) are accessed or if request.body is accessed.
    1.21 +
    1.22  
    1.23  ### request.cookies
    1.24  
    1.25  A table with all cookies sent by the client.
    1.26  
    1.27  
    1.28 -### request.defer_reading()
    1.29 -
    1.30 -Disables automatic request body processing on write. Can be called before
    1.31 -sending a HTTP status code to send a response before the request has been fully
    1.32 -received.
    1.33 -
    1.34 -CAUTION: Responding to a request before the request body has been processed may
    1.35 -lead to a deadlock if the browser does not process the response while trying to
    1.36 -send the request. Therefore, this function should only be used if:
    1.37 -
    1.38 -- the TCP stack has enough buffer space for the response (i.e. if the response
    1.39 -  is small enough), and if
    1.40 -- a timer is used to cancel the response in case of a deadlock.
    1.41 -
    1.42 -It is recommended to not use this function unless certain performance tweaks
    1.43 -are desired.
    1.44 -
    1.45 -
    1.46  ### request.faulty
    1.47  
    1.48 -Normally set to false. In case of a read or write error on the client
    1.49 -connection, this value is set to true before a Lua error is raised.
    1.50 +Normally set to false. In case of a write error on the client connection or
    1.51 +certain other unexpected errors, this value is set to true before a Lua error
    1.52 +is raised.
    1.53  
    1.54  A faulty request handle must not be used, or another Lua error will be raised.
    1.55  
    1.56 @@ -485,6 +483,12 @@
    1.57  body, it is required to call request:finish().
    1.58  
    1.59  
    1.60 +### request.fresh
    1.61 +
    1.62 +Set to false whenever the request object has been used (e.g. data has been read
    1.63 +or sent out, or a stream handler was installed); true otherwise.
    1.64 +
    1.65 +
    1.66  ### request.get_params
    1.67  
    1.68  A table that maps field names to their corresponding GET value. If there are
    1.69 @@ -543,6 +547,12 @@
    1.70  The HTTP request method, e.g. "HEAD", "GET", or "POST".
    1.71  
    1.72  
    1.73 +### request:monologue()
    1.74 +
    1.75 +Same as request:close_after_finish() but additionally discards all input data
    1.76 +immediately.
    1.77 +
    1.78 +
    1.79  ### request.path
    1.80  
    1.81  The requested path without a leading slash and without the query part (e.g.
    1.82 @@ -599,25 +609,6 @@
    1.83  request-target in section 5.3.4 in RFC 7230).
    1.84  
    1.85  
    1.86 -### request:process_request_body()
    1.87 -
    1.88 -Starts processing the request body (if existent) to set the values
    1.89 -request.post_params, request.post_params_list, request.post_metadata, and
    1.90 -and request.post_metadata_list and/or to call POST field stream handlers that
    1.91 -have been previously registered with request:stream_post_param(...) or
    1.92 -request:stream_post_params(...).
    1.93 -
    1.94 -This method gets invoked automatically when the POST param tables
    1.95 -(request.post_params, etc.) are accessed, or if a response is sent (to avoid
    1.96 -deadlocks with the webbrowser). (Note: Automatic request body processing on
    1.97 -write may be disabled by calling request:defer_reading().)
    1.98 -
    1.99 -After this method returned, all registered POST field stream handlers have
   1.100 -received all data. Registration of other POST field stream handlers is not
   1.101 -possible after this method has been called (or after request.post_params_list
   1.102 -or request.post_params have been accessed).
   1.103 -
   1.104 -
   1.105  ### request:send_data(...)
   1.106  
   1.107  Sends data as response body. All arguments are converted via tostring(...) and
   1.108 @@ -672,6 +663,9 @@
   1.109    as second argument.
   1.110  - The second time without any arguments.
   1.111  
   1.112 +Note that request:consume_input() needs to be called to enforce streaming to
   1.113 +finish.
   1.114 +
   1.115  
   1.116  ### request:stream_post_params(pattern, callback)
   1.117  
   1.118 @@ -681,15 +675,20 @@
   1.119  
   1.120  ### request:stream_request_body(callback)
   1.121  
   1.122 -Start streaming of request body. For each chunk of the request body, the
   1.123 -callback function is called with the corresponding chunk. End of data is
   1.124 -indicated through return of request:stream_request_body(...) (not by calling
   1.125 -the callback without arguments).
   1.126 +Registeres a stream handler for the whole request body. For each chunk of the
   1.127 +request body, the callback function is called with the corresponding chunk. End
   1.128 +of data is indicated by passing a nil value to the callback functuion.
   1.129  
   1.130 -The function may be called with nil instead of a callback function. In this
   1.131 -case, the request body is read and discarded. Only if nil is passed instead of
   1.132 -a callback, then the function may also be invoked when the request body has
   1.133 -already been read and/or processed. In the latter case, the function performs
   1.134 -no operation.
   1.135 +Note that request:consume_input() needs to be called to enforce streaming to
   1.136 +finish.
   1.137  
   1.138  
   1.139 +### request:stream_request_body_now(callback)
   1.140 +
   1.141 +Start streaming of request body immediately. On EOF the function returns and
   1.142 +the callback function is *not* called with nil as argument.
   1.143 +
   1.144 +Note that request:consume_input() needs to be called to enforce streaming to
   1.145 +finish.
   1.146 +
   1.147 +

Impressum / About Us