| Commit message (Collapse) | Author | Age |
... | |
|
|
|
|
| |
This solves the problem of erroneous exception thrown in
r.internalRedirect() after 05c7f0b31856 (0.8.0).
|
|
|
|
|
|
|
| |
1) Ensuring that consistent prefixes are used:
"http js" in HTTP module and "stream js" in Stream module.
2) Added debug for every event/callback handler entrance.
3) Added debug with a method name for every JS call.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Now js_periodic handler is provided with a session object as its first
argument. Session object can be used to access variables created with
js_set, js_var or map directives.
example.conf:
js_var $js_var JS-VAR;
location @periodics {
js_periodic main.handler interval=60s;
}
example.js:
function handler(s) {
ngx.log(ngx.INFO, s.variables.js_var);
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
worker_affinity specifies on what set of workers the js_periodic handler
should be executed. By default the js_handler is executed only on worker 0.
The parameter accepts a binary mask or "all" to specify all workers.
example.conf:
worker_processes 4;
...
location @periodics {
# to be run at 1 minute intervals in worker 0
js_periodic main.handler interval=60s;
# to be run at 1 minute intervals in all the workers
js_periodic main.handler interval=60s worker_affinity=all;
# to be run at 1 minute intervals in workers 1 and 3
js_periodic main.handler interval=60s worker_affinity=0101;
}
|
|
|
|
| |
The issue was introduced in f1bd0b1db065.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The directive specifies a JS handler to run at regular intervals. The JS
handler will be executed in each worker process. The handler receives no
arguments. It has access to ngx and other global objects.
example.conf:
location @periodics {
# Specifies a JS handler to be run at 1 minute intervals
js_periodic main.handler interval=60s jitter=5s;
resolver 10.0.0.1;
js_fetch_trusted_certificate /path/to/ISRG_Root_X1.pem;
}
example.js:
async function handler() {
if (ngx.worker_id != 0) {
/* using ngx.worker_id to run handler only in one worker. */
return;
}
let reply = async ngx.fetch('https://nginx.org/en/docs/njs/');
let body = async reply.text();
ngx.log(ngx.INFO, body);
}
This closes #660 issue on Github.
|
| |
|
|
|
|
|
|
| |
Previously, r.headersOut['Last-Modified'] setter did not update
r->headers_out.last_modified. As a result a client might get two
Last-Modified headers.
|
|
|
|
|
|
| |
Previously, r.headersOut['Date'] setter did not update
r->headers_out.date. As a result a client might get two
Date headers.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The directive allows to declare a dictionary that is shared among the
working processes. A dictionary expects strings as keys. It stores
string or number as values. The value type is declared using
type= argument of the directive. The default type is string.
example.conf:
# Declares a shared dictionary of strings of size 1 Mb that
# removes key-value after 60 seconds of inactivity.
js_shared_dict_zone zone=foo:1M timeout=60s;
# Declares a shared dictionary of strings of size 512Kb that
# forcibly remove oldest key-value pairs when memory is not enough.
js_shared_dict_zone zone=bar:512K timeout=30s evict;
# Declares a permanent number shared dictionary of size 32Kb.
js_shared_dict_zone zone=num:32k type=number;
example.js:
function get(r) {
r.return(200, ngx.shared.foo.get(r.args.key));
}
function set(r) {
r.return(200, ngx.shared.foo.set(r.args.key, r.args.value));
}
function delete(r) {
r.return(200, ngx.shared.bar.delete(r.args.key));
}
function increment(r) {
r.return(200, ngx.shared.num.incr(r.args.key, 2));
}
In collaboration with Artem S. Povalyukhin, Jakub Jirutka and
洪志道 (Hong Zhi Dao).
This closes #437 issue on Github.
|
|
|
|
| |
The new API allows to add new constructor/prototype pairs.
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
Previously, r.headersOut['Location'] setter did not update
r->headers_out.location. As a result a client might get two
Location headers.
This fixes #648 issue on Github.
|
| |
|
|
|
|
|
| |
A user is notified explicitly that r.internalRedirect()
is not supported in filters.
|
|
|
|
| |
Both properties were deprecated since 0.5.0.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously, native methods were expected to return
their retval using vm->retval. This caused problem in the part
(1aa137411b09, 293fe42c5e1c) because vm->retval can be overwritten
unexpectedly as a side-effect of operations like ToString(), ToNumber().
The fix is to never used a global retval. Instead methods
are provided with a retval argument to store their retval value.
As a part of the change, retval and exception values are split.
The normal value is returned in the retval argument.
The exception value is thrown by njs_vm_throw() or njs_vm_error().
The exception value can be acquired using njs_vm_exception_get().
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
| |
HTTP: js_import, js_path, js_set and js_var are allowed in server and
location contexts. js_content, js_body_filter and js_header_filter
are allowed in 'if' context.
Stream: js_import, js_path, js_set and js_var are allowed in server context.
This closes #566 issue on Github.
|
|
|
|
|
| |
Previously, deprecated and non-deprecated properties shared
a common handler.
|
| |
|
|
|
|
|
| |
This allows for a host environment to control when and
how internal NJS messages are logged.
|
|
|
|
|
|
| |
1) added support for multiple arguments with the same key.
2) added cases sensitivity for keys.
3) keys and values are percent-decoded.
|
|
|
|
|
|
|
|
|
|
|
| |
The issue was introduced in 5b7676ec600d (0.7.5) when njs module was
adapted to changes in nginx/1.23 related to header structures.
When special headers (Content-Length, Content-Type, Content-Encoding)
were set, the value of the last outgoing header might be overwritten
with a new set value.
This closes #555 issue on Github.
|
|
|
|
| |
This unifies empty response value type for r.headersOut.
|
|
|
|
|
|
|
| |
Previously, when Content-Encoding or Content-Length header was absent,
an exception was thrown erroneously.
This closes #537 issue on Github.
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
Similarly to the nginx change in 975d7ab37b39 (1.17.2), we should accept
properly escaped URIs and unescape them as needed, else it is not possible
to handle URIs with question marks.
Previously, the URI was used as is.
|
|
|
|
|
|
|
|
|
|
| |
The following directives are added:
* js_fetch_timeout
* js_fetch_verify
* js_fetch_buffer_size
* js_fetch_max_response_buffer_size
This closes #489 issue on Github.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously, user modules were compiled as as anonymous functions in a
global scope. This is incorrect, because modules should be compiled
in their own scope.
In addition, this patch introduces HostResolveImportedModule support.
When vm->options.ops->module_loader is provided, a module lookup
and compilation is delegated to this callback.
This closes #443 issue on Github.
|
| |
|
|
|
|
| |
Found by Coverity (CID 1495259).
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The fetch API now accepts an extra parameters:
- verify: boolean (default true) to control server certificate
verification.
Verification process can be controlled with the following directives
from the http js and stream js modules:
- js_fetch_ciphers
- js_fetch_protocols
- js_fetch_verify_depth
- js_fetch_trusted_certificate
In collaboration with Dmitry Volyntsev.
|
|
|
|
|
|
|
|
| |
An external value has an arbitrary raw pointer associated with it.
External values with different prototypes have different C-level
structures. To ensure that only appropriate structures are fetched
by njs_vm_external() the unique tag has to be provided during
creation of external values.
|
|
|
|
|
|
| |
This patch avoids relying on the order in which external prototypes are
registered. Instead, the returned proto_id is expected to be stored
somewhere.
|
| |
|