Skip to content

Commit 576a10d

Browse files
thibaultchaagentzh
authored andcommitted
doc: mention that ngx.req.set_body_data() and ngx.req.set_body_file() must read the request body.
This behavior was introduced in e37b58e but the documentation was left unchanged. Signed-off-by: Yichun Zhang (agentzh) <[email protected]>
1 parent 8ba33da commit 576a10d

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

README.markdown

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4888,7 +4888,7 @@ This function returns `nil` if
48884888
1. the request body has been read into disk temporary files,
48894889
1. or the request body has zero size.
48904890

4891-
If the request body has not been read yet, call [ngx.req.read_body](#ngxreqread_body) first (or turned on [lua_need_request_body](#lua_need_request_body) to force this module to read the request body. This is not recommended however).
4891+
If the request body has not been read yet, call [ngx.req.read_body](#ngxreqread_body) first (or turn on [lua_need_request_body](#lua_need_request_body) to force this module to read the request body. This is not recommended however).
48924892

48934893
If the request body has been read into disk files, try calling the [ngx.req.get_body_file](#ngxreqget_body_file) function instead.
48944894

@@ -4912,7 +4912,7 @@ Retrieves the file name for the in-file request body data. Returns `nil` if the
49124912

49134913
The returned file is read only and is usually cleaned up by Nginx's memory pool. It should not be manually modified, renamed, or removed in Lua code.
49144914

4915-
If the request body has not been read yet, call [ngx.req.read_body](#ngxreqread_body) first (or turned on [lua_need_request_body](#lua_need_request_body) to force this module to read the request body. This is not recommended however).
4915+
If the request body has not been read yet, call [ngx.req.read_body](#ngxreqread_body) first (or turn on [lua_need_request_body](#lua_need_request_body) to force this module to read the request body. This is not recommended however).
49164916

49174917
If the request body has been read into memory, try calling the [ngx.req.get_body_data](#ngxreqget_body_data) function instead.
49184918

@@ -4932,7 +4932,9 @@ ngx.req.set_body_data
49324932

49334933
Set the current request's request body using the in-memory data specified by the `data` argument.
49344934

4935-
If the current request's request body has not been read, then it will be properly discarded. When the current request's request body has been read into memory or buffered into a disk file, then the old request body's memory will be freed or the disk file will be cleaned up immediately, respectively.
4935+
If the request body has not been read yet, call [ngx.req.read_body](#ngxreqread_body) first (or turn on [lua_need_request_body](#lua_need_request_body) to force this module to read the request body. This is not recommended however). Additionally, the request body must not have been previously discarded by [ngx.req.discard_body](#ngxreqdiscard_body).
4936+
4937+
Whether the previous request body has been read into memory or buffered into a disk file, it will be freed or the disk file will be cleaned up immediately, respectively.
49364938

49374939
This function was first introduced in the `v0.3.1rc18` release.
49384940

@@ -4948,11 +4950,13 @@ ngx.req.set_body_file
49484950

49494951
Set the current request's request body using the in-file data specified by the `file_name` argument.
49504952

4953+
If the request body has not been read yet, call [ngx.req.read_body](#ngxreqread_body) first (or turn on [lua_need_request_body](#lua_need_request_body) to force this module to read the request body. This is not recommended however). Additionally, the request body must not have been previously discarded by [ngx.req.discard_body](#ngxreqdiscard_body).
4954+
49514955
If the optional `auto_clean` argument is given a `true` value, then this file will be removed at request completion or the next time this function or [ngx.req.set_body_data](#ngxreqset_body_data) are called in the same request. The `auto_clean` is default to `false`.
49524956

49534957
Please ensure that the file specified by the `file_name` argument exists and is readable by an Nginx worker process by setting its permission properly to avoid Lua exception errors.
49544958

4955-
If the current request's request body has not been read, then it will be properly discarded. When the current request's request body has been read into memory or buffered into a disk file, then the old request body's memory will be freed or the disk file will be cleaned up immediately, respectively.
4959+
Whether the previous request body has been read into memory or buffered into a disk file, it will be freed or the disk file will be cleaned up immediately, respectively.
49564960

49574961
This function was first introduced in the `v0.3.1rc18` release.
49584962

doc/HttpLuaModule.wiki

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4071,7 +4071,7 @@ This function returns <code>nil</code> if
40714071
# the request body has been read into disk temporary files,
40724072
# or the request body has zero size.
40734073
4074-
If the request body has not been read yet, call [[#ngx.req.read_body|ngx.req.read_body]] first (or turned on [[#lua_need_request_body|lua_need_request_body]] to force this module to read the request body. This is not recommended however).
4074+
If the request body has not been read yet, call [[#ngx.req.read_body|ngx.req.read_body]] first (or turn on [[#lua_need_request_body|lua_need_request_body]] to force this module to read the request body. This is not recommended however).
40754075
40764076
If the request body has been read into disk files, try calling the [[#ngx.req.get_body_file|ngx.req.get_body_file]] function instead.
40774077
@@ -4092,7 +4092,7 @@ Retrieves the file name for the in-file request body data. Returns <code>nil</co
40924092
40934093
The returned file is read only and is usually cleaned up by Nginx's memory pool. It should not be manually modified, renamed, or removed in Lua code.
40944094
4095-
If the request body has not been read yet, call [[#ngx.req.read_body|ngx.req.read_body]] first (or turned on [[#lua_need_request_body|lua_need_request_body]] to force this module to read the request body. This is not recommended however).
4095+
If the request body has not been read yet, call [[#ngx.req.read_body|ngx.req.read_body]] first (or turn on [[#lua_need_request_body|lua_need_request_body]] to force this module to read the request body. This is not recommended however).
40964096
40974097
If the request body has been read into memory, try calling the [[#ngx.req.get_body_data|ngx.req.get_body_data]] function instead.
40984098
@@ -4109,7 +4109,9 @@ See also [[#ngx.req.get_body_data|ngx.req.get_body_data]].
41094109
41104110
Set the current request's request body using the in-memory data specified by the <code>data</code> argument.
41114111
4112-
If the current request's request body has not been read, then it will be properly discarded. When the current request's request body has been read into memory or buffered into a disk file, then the old request body's memory will be freed or the disk file will be cleaned up immediately, respectively.
4112+
If the request body has not been read yet, call [[#ngx.req.read_body|ngx.req.read_body]] first (or turn on [[#lua_need_request_body|lua_need_request_body]] to force this module to read the request body. This is not recommended however). Additionally, the request body must not have been previously discarded by [[#ngx.req.discard_body|ngx.req.discard_body]].
4113+
4114+
Whether the previous request body has been read into memory or buffered into a disk file, it will be freed or the disk file will be cleaned up immediately, respectively.
41134115
41144116
This function was first introduced in the <code>v0.3.1rc18</code> release.
41154117
@@ -4122,11 +4124,13 @@ See also [[#ngx.req.set_body_file|ngx.req.set_body_file]].
41224124
41234125
Set the current request's request body using the in-file data specified by the <code>file_name</code> argument.
41244126
4127+
If the request body has not been read yet, call [[#ngx.req.read_body|ngx.req.read_body]] first (or turn on [[#lua_need_request_body|lua_need_request_body]] to force this module to read the request body. This is not recommended however). Additionally, the request body must not have been previously discarded by [[#ngx.req.discard_body|ngx.req.discard_body]].
4128+
41254129
If the optional <code>auto_clean</code> argument is given a <code>true</code> value, then this file will be removed at request completion or the next time this function or [[#ngx.req.set_body_data|ngx.req.set_body_data]] are called in the same request. The <code>auto_clean</code> is default to <code>false</code>.
41264130
41274131
Please ensure that the file specified by the <code>file_name</code> argument exists and is readable by an Nginx worker process by setting its permission properly to avoid Lua exception errors.
41284132
4129-
If the current request's request body has not been read, then it will be properly discarded. When the current request's request body has been read into memory or buffered into a disk file, then the old request body's memory will be freed or the disk file will be cleaned up immediately, respectively.
4133+
Whether the previous request body has been read into memory or buffered into a disk file, it will be freed or the disk file will be cleaned up immediately, respectively.
41304134
41314135
This function was first introduced in the <code>v0.3.1rc18</code> release.
41324136

0 commit comments

Comments
 (0)