# HG changeset patch # User Yaroslav Zhuravlev # Date 1537806252 -10800 # Node ID 0f16ef9a8dbe4471566a9df450e98dce983fb63e # Parent 32ba43abf9cd755e14cb347ba53b72f3976a36aa Created "nginx objects" section in reference.xml. diff -r 32ba43abf9cd -r 0f16ef9a8dbe xml/en/docs/njs/reference.xml --- a/xml/en/docs/njs/reference.xml Mon Sep 24 19:24:04 2018 +0300 +++ b/xml/en/docs/njs/reference.xml Mon Sep 24 19:24:12 2018 +0300 @@ -9,7 +9,7 @@
+ rev="10">
@@ -21,6 +21,435 @@
+
+ + +
+ + +The HTTP request object is available only in the +ngx_http_js_module module. +All string properties of the object are byte strings. + + + +r.args{} + +request arguments object, read-only + + +r.error(string) + +writes a string to the error log +on the error level of logging + + +r.finish() + +finishes sending a response to the client + + +r.headersIn{} + +incoming headers object, read-only. + +For example, the Foo header +can be accessed with the syntax headersIn.foo +or headersIn['Foo'] + + + +r.headersOut{} + +outgoing headers object, writable. + +For example, the Foo header +can be accessed with the syntax headersOut.foo +or headersOut['Foo'] + + + +r.httpVersion + +HTTP version, read-only + + +r.log(string) + +writes a string to the error log +on the info level of logging + + +r.internalRedirect(uri) + +performs an internal redirect to the specified uri. +If the uri starts with the “@” prefix, +it is considered a named location. + + +r.method + +HTTP method, read-only + + +r.parent + +references the parent request object + + +r.remoteAddress + +client address, read-only + + +r.requestBody + +holds the request body, read-only + + +r.responseBody + +holds the subrequest response body, read-only. +The size of r.responseBody is limited by the + +directive. + + +r.return(status[, string]) + +sends the entire response +with the specified status to the client + +It is possible to specify either a redirect URL +(for codes 301, 302, 303, 307, and 308) +or the response body text (for other codes) as the second argument + + + +r.send(string) + +sends a part of the response body to the client + + +r.sendHeader() + +sends the HTTP headers to the client + + +r.status + +status, writable + + +r.variables{} + +nginx variables object, read-only + + +r.warn(string) + +writes a string to the error log +on the warning level of logging + + +r.uri + +current URI, read-only + + +r.subrequest(uri[, +options[, callback]]) + +creates a subrequest with the given uri and +options, and installs +an optional completion callback. + + +If options is a string, then it +holds the subrequest arguments string. +Otherwise, options is expected to be +an object with the following keys: + +args + +arguments string + +body + +request body + + +method + +HTTP method + + + + + + +The completion callback receives +a subrequest response object with methods and properties +identical to the parent request object. + + + + + + +
+ + +
+ + +The stream session object is available only in the +ngx_stream_js_module +module. +All string properties of the object are byte strings. + + + + +Prior to njs 0.2.4, +the stream session object had some properties which are currently +removed. + + + + + + +s.allow() + +successfully finalizes the phase handler +(0.2.4) + + +s.decline() + +finalizes the phase handler and passes control to the next handler +(0.2.4) + + +s.deny() + +finalizes the phase handler with the access error code +(0.2.4) + + +s.done([code]) + +successfully finalizes the current phase handler +or finalizes it with the specified numeric code +(0.2.4). + + +s.error(string) + +writes a sent string to the error log +on the error level of logging + + +s.log(string) + +writes a sent string to the error log +on the info level of logging + + +s.off(eventName) + +unregisters the callback set by the s.on() method +(0.2.4) + + +s.on(event, +callback) + +registers a callback for the specified event +(0.2.4). + + +An event may be one of the following strings: + +upload + +new data from a client + + +download + +new data to a client + + + + + + +The completion callback has the following prototype: +callback(data, flags), where +data is string, +flags is an object +with the following properties: + +last + +a boolean value, true if data is a last buffer. + + + + + + +s.remoteAddress + +client address, read-only + + +s.send(data[, +options]) + +sends the data to the client +(0.2.4). +The options is an object used +to override nginx buffer flags derived from an incoming data chunk buffer. +The flags can be overriden with the following flags: + + + +last + +boolean, true if the buffer is the last buffer + + +flush + +boolean, true if the buffer should have the flush flag + + + +The method can be called multiple times per callback invocation. + + +s.variables{} + +nginx variables object, read-only + + +s.warn(string) + +writes a sent string to the error log +on the warning level of logging + + + + + + +
+ + +These properties have been removed +in njs 0.2.4 +and are not backward compatible with the existing njs code. + + + + + +s.ABORT + +the ABORT return code + +Starting from njs 0.2.4, +the s.deny() method should be used instead. + + + +s.AGAIN + +the AGAIN return code + +Starting from njs 0.2.4, +the corresponding behavior is achieved if no +s.allow(), +s.deny(), +s.decline(), +s.done() +is invoked and a callback is registered. + + + +s.buffer + +the current buffer, writable + +Starting from 0.2.4, +the s.send() method should be used for writing. +For reading, the current buffer is available as the first argument of the +event callback. + + + +s.DECLINED + +the DECLINED return code + +Starting from njs 0.2.4, +the s.decline() method should be used instead. + + + +s.eof + +a boolean read-only property, true if the current buffer is the last buffer + +Starting from 0.2.4, +the flags.last property +should be used instead. + + + +s.ERROR + +the ERROR return code + +Starting from njs 0.2.4, +an appropriate exception can be thrown to report an error. + + + +s.fromUpstream + +a boolean read-only property, +true if the current buffer is from the upstream server to the client + +Starting from 0.2.4, +a corresponding event +(upload or download) +should be used to handle data to or from client. + + + +s.OK + +the OK return code + +Starting from njs 0.2.4, +the s.allow() method should be used instead. + + + + + + +
+ +
+ +
+ +
@@ -853,429 +1282,4 @@
- -
- - -The HTTP request object is available only in the -ngx_http_js_module module. -All string properties of the object are byte strings. - - - -r.args{} - -request arguments object, read-only - - -r.error(string) - -writes a string to the error log -on the error level of logging - - -r.finish() - -finishes sending a response to the client - - -r.headersIn{} - -incoming headers object, read-only. - -For example, the Foo header -can be accessed with the syntax headersIn.foo -or headersIn['Foo'] - - - -r.headersOut{} - -outgoing headers object, writable. - -For example, the Foo header -can be accessed with the syntax headersOut.foo -or headersOut['Foo'] - - - -r.httpVersion - -HTTP version, read-only - - -r.log(string) - -writes a string to the error log -on the info level of logging - - -r.internalRedirect(uri) - -performs an internal redirect to the specified uri. -If the uri starts with the “@” prefix, -it is considered a named location. - - -r.method - -HTTP method, read-only - - -r.parent - -references the parent request object - - -r.remoteAddress - -client address, read-only - - -r.requestBody - -holds the request body, read-only - - -r.responseBody - -holds the subrequest response body, read-only. -The size of r.responseBody is limited by the - -directive. - - -r.return(status[, string]) - -sends the entire response -with the specified status to the client - -It is possible to specify either a redirect URL -(for codes 301, 302, 303, 307, and 308) -or the response body text (for other codes) as the second argument - - - -r.send(string) - -sends a part of the response body to the client - - -r.sendHeader() - -sends the HTTP headers to the client - - -r.status - -status, writable - - -r.variables{} - -nginx variables object, read-only - - -r.warn(string) - -writes a string to the error log -on the warning level of logging - - -r.uri - -current URI, read-only - - -r.subrequest(uri[, -options[, callback]]) - -creates a subrequest with the given uri and -options, and installs -an optional completion callback. - - -If options is a string, then it -holds the subrequest arguments string. -Otherwise, options is expected to be -an object with the following keys: - -args - -arguments string - -body - -request body - - -method - -HTTP method - - - - - - -The completion callback receives -a subrequest response object with methods and properties -identical to the parent request object. - - - - - - -
- - -
- - -The stream session object is available only in the -ngx_stream_js_module -module. -All string properties of the object are byte strings. - - - - -Prior to njs 0.2.4, -the stream session object had some properties which are currently -removed. - - - - - - -s.allow() - -successfully finalizes the phase handler -(0.2.4) - - -s.decline() - -finalizes the phase handler and passes control to the next handler -(0.2.4) - - -s.deny() - -finalizes the phase handler with the access error code -(0.2.4) - - -s.done([code]) - -successfully finalizes the current phase handler -or finalizes it with the specified numeric code -(0.2.4). - - -s.error(string) - -writes a sent string to the error log -on the error level of logging - - -s.log(string) - -writes a sent string to the error log -on the info level of logging - - -s.off(eventName) - -unregisters the callback set by the s.on() method -(0.2.4) - - -s.on(event, -callback) - -registers a callback for the specified event -(0.2.4). - - -An event may be one of the following strings: - -upload - -new data from a client - - -download - -new data to a client - - - - - - -The completion callback has the following prototype: -callback(data, flags), where -data is string, -flags is an object -with the following properties: - -last - -a boolean value, true if data is a last buffer. - - - - - - -s.remoteAddress - -client address, read-only - - -s.send(data[, -options]) - -sends the data to the client -(0.2.4). -The options is an object used -to override nginx buffer flags derived from an incoming data chunk buffer. -The flags can be overriden with the following flags: - - - -last - -boolean, true if the buffer is the last buffer - - -flush - -boolean, true if the buffer should have the flush flag - - - -The method can be called multiple times per callback invocation. - - -s.variables{} - -nginx variables object, read-only - - -s.warn(string) - -writes a sent string to the error log -on the warning level of logging - - - - - - -
- - -These properties have been removed -in njs 0.2.4 -and are not backward compatible with the existing njs code. - - - - - -s.ABORT - -the ABORT return code - -Starting from njs 0.2.4, -the s.deny() method should be used instead. - - - -s.AGAIN - -the AGAIN return code - -Starting from njs 0.2.4, -the corresponding behavior is achieved if no -s.allow(), -s.deny(), -s.decline(), -s.done() -is invoked and a callback is registered. - - - -s.buffer - -the current buffer, writable - -Starting from 0.2.4, -the s.send() method should be used for writing. -For reading, the current buffer is available as the first argument of the -event callback. - - - -s.DECLINED - -the DECLINED return code - -Starting from njs 0.2.4, -the s.decline() method should be used instead. - - - -s.eof - -a boolean read-only property, true if the current buffer is the last buffer - -Starting from 0.2.4, -the flags.last property -should be used instead. - - - -s.ERROR - -the ERROR return code - -Starting from njs 0.2.4, -an appropriate exception can be thrown to report an error. - - - -s.fromUpstream - -a boolean read-only property, -true if the current buffer is from the upstream server to the client - -Starting from 0.2.4, -a corresponding event -(upload or download) -should be used to handle data to or from client. - - - -s.OK - -the OK return code - -Starting from njs 0.2.4, -the s.allow() method should be used instead. - - - - - - -
- -
- -