aboutsummaryrefslogtreecommitdiff
path: root/nginx/ngx_http_js_module.c
Commit message (Collapse)AuthorAge
...
* HTTP: avoid calling body filter when input chain is NULL.Dmitry Volyntsev2023-09-11
| | | | | This solves the problem of erroneous exception thrown in r.internalRedirect() after 05c7f0b31856 (0.8.0).
* Modules: improved debug log.Dmitry Volyntsev2023-09-08
| | | | | | | 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.
* Modules: added a session object for js_periodic handler.Dmitry Volyntsev2023-09-05
| | | | | | | | | | | | | | | | | | 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); }
* Modules: added worker_affinity parameter for js_periodic directive.Dmitry Volyntsev2023-09-05
| | | | | | | | | | | | | | | | | | | | | 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; }
* Fixed js_periodic handler stopping after graceful shutdown.Dmitry Volyntsev2023-08-30
| | | | The issue was introduced in f1bd0b1db065.
* Modules: introduced js_periodic directive.Dmitry Volyntsev2023-08-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* HTTP: simplified events handling.Dmitry Volyntsev2023-08-22
|
* HTTP: fixed setting of Last-Modified header.Dmitry Volyntsev2023-07-11
| | | | | | 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.
* HTTP: fixed setting of Date header.Dmitry Volyntsev2023-07-11
| | | | | | Previously, r.headersOut['Date'] setter did not update r->headers_out.date. As a result a client might get two Date headers.
* Modules: introduced js_shared_dict_zone directive.Dmitry Volyntsev2023-07-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Added njs_vm_external_constructor().Dmitry Volyntsev2023-07-03
| | | | The new API allows to add new constructor/prototype pairs.
* Using addon module API to unify injecting of external objects.Dmitry Volyntsev2023-06-28
|
* Modules: renaming ngx_js_conf_t to ngx_js_loc_conf_t.Dmitry Volyntsev2023-06-06
|
* HTTP: fixed setting of Location header.Dmitry Volyntsev2023-06-05
| | | | | | | | 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.
* HTTP: deduplicated special header handlers for nginx <= 1.22.Dmitry Volyntsev2023-06-05
|
* HTTP: throwing an exception in r.internalRedirect() while filtering.Dmitry Volyntsev2023-05-26
| | | | | A user is notified explicitly that r.internalRedirect() is not supported in filters.
* Change: removed deprecated r.requestBody and r.responseBody.Dmitry Volyntsev2023-05-17
| | | | Both properties were deprecated since 0.5.0.
* HTTP: fixed r.status setter when filtering.Dmitry Volyntsev2023-05-08
|
* Change: native methods are provided with retval argument.Dmitry Volyntsev2023-04-19
| | | | | | | | | | | | | | | 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().
* Extended njs_vm_function_alloc().Dmitry Volyntsev2022-12-07
|
* Modules: js_merge_conf is moved to shared library.Vadim Zhestikov2022-09-27
|
* Modules: common code is moved to shared library.Vadim Zhestikov2022-09-27
|
* HTTP: adding a warning for ignored outgoing header assignments.Dmitry Volyntsev2022-09-22
|
* Modules: added js_preload_object directive.Vadim Zhestikov2022-09-16
|
* Modules: common code for js_import is moved to shared library.Vadim Zhestikov2022-09-13
|
* HTTP: added r.internal property.Dmitry Volyntsev2022-08-25
|
* Modules: sorting external object property descriptors alphabetically.Dmitry Volyntsev2022-08-24
|
* Modules: extending allowed context for js directives.Dmitry Volyntsev2022-08-02
| | | | | | | | | 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.
* Fixed deprecation warnings introduced in beaff2c39864.Dmitry Volyntsev2022-08-02
| | | | | Previously, deprecated and non-deprecated properties shared a common handler.
* Added soft deprecation warning for deprecated methods and properties.Dmitry Volyntsev2022-07-25
|
* Added generic logger callback.Dmitry Volyntsev2022-07-25
| | | | | This allows for a host environment to control when and how internal NJS messages are logged.
* HTTP: refactored r.args object.Dmitry Volyntsev2022-07-14
| | | | | | 1) added support for multiple arguments with the same key. 2) added cases sensitivity for keys. 3) keys and values are percent-decoded.
* HTTP: fixed r.headersOut setter for special headers.Dmitry Volyntsev2022-07-06
| | | | | | | | | | | 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.
* HTTP: returing undefined for Content-Type when the header is absent.Dmitry Volyntsev2022-06-07
| | | | This unifies empty response value type for r.headersOut.
* HTTP: fixed r.headersOut special getters when value is absent.Dmitry Volyntsev2022-06-06
| | | | | | | Previously, when Content-Encoding or Content-Length header was absent, an exception was thrown erroneously. This closes #537 issue on Github.
* HTTP: adapting to changes in nginx header structures.Dmitry Volyntsev2022-05-31
|
* HTTP: improved memory allocation error handling.Sergey Kandaurov2022-05-26
|
* HTTP: expect escaped URIs in r.internalRedirect().Dmitry Volyntsev2022-04-28
| | | | | | | | 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.
* Modules: added additional directives for Fetch API.Dmitry Volyntsev2022-04-28
| | | | | | | | | | 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.
* Refactoring of user modules importing.Dmitry Volyntsev2022-02-21
| | | | | | | | | | | | 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.
* Refactor modules using external prototypes.Dmitry Volyntsev2021-12-21
|
* Modules: removed dead code left after dfcbfb5e27b2.Dmitry Volyntsev2021-12-14
| | | | Found by Coverity (CID 1495259).
* Modules: removed "js_include" directive deprecated in 0.4.0.Dmitry Volyntsev2021-12-09
|
* Style.Dmitry Volyntsev2021-10-14
|
* Modules: introduced setReturnValue() method.Dmitry Volyntsev2021-10-08
|
* Modules: introduced common ngx_js_retval().Dmitry Volyntsev2021-10-08
|
* Added support for HTTPS URLs to the Fetch API.Antoine Bonavita2021-09-01
| | | | | | | | | | | | | | | 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.
* Marking different external pointer with unique tag.Dmitry Volyntsev2021-07-09
| | | | | | | | 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.
* Modules: improved working with external prototypes.Dmitry Volyntsev2021-07-09
| | | | | | This patch avoids relying on the order in which external prototypes are registered. Instead, the returned proto_id is expected to be stored somewhere.
* Modules: added js_var directive.Dmitry Volyntsev2021-03-27
|