Commit Graph
100 Commits
Author SHA1 Message Date
Valentin Bartenev fd8e524b82 Configuration: fixed comments parsing.
Unclosed multi-line comments and "/" at the end of JSON shouldn't be allowed.
2020-03-25 19:14:15 +03:00
Valentin Bartenev b7f0e09de0 Version bump. 2020-03-16 13:27:10 +03:00
Valentin Bartenev b3c8a7b33a Added tag 1.16.0 for changeset 8bab088952dd 2020-03-12 18:35:33 +03:00
Valentin Bartenev 8f397c8ae5 Generated Dockerfiles for Unit 1.16.0. 2020-03-12 18:13:08 +03:00
Valentin Bartenev f6d53f69b8 Added version 1.16.0 CHANGES. 2020-03-12 18:13:07 +03:00
Valentin Bartenev 810b8dbb67 Tests: unitd stderr output redirected to unit.log.
A part of the debug log was printed to stderr before the log file was opened.
Now, this output is redirected to the same log file.
2020-03-06 20:08:38 +03:00
Valentin Bartenev 3617d4ed03 Tests: simplified unitd process running.
There are no reasons to wrap the Unit daemon in a separate Python process.
2020-03-06 20:08:29 +03:00
Valentin Bartenev afa2f86ecf PHP: added ZTS indication to ./configure output. 2020-03-04 15:24:27 +03:00
Valentin Bartenev 75cb2a947d PHP: rearranged feature checks in ./configure.
Now it prints version even if PHP was built without embed SAPI.
2020-03-04 15:24:27 +03:00
Valentin Bartenev a98de7f705 Added a "fallback" option to be used with the "share" action.
It allows proceeding to another action if a file isn't available.

An example:

    {
        "share": "/data/www/",

        "fallback": {
            "pass": "applications/php"
        }
    }

In the example above, an attempt is made first to serve a request with
a file from the "/data/www/" directory.  If there's no such file, the
request is passed to the "php" application.

Fallback actions may be nested:

    {
        "share": "/data/www/",

        "fallback": {
            "share": "/data/cache/",

            "fallback": {
                "proxy": "http://127.0.0.1:9000"
            }
        }
    }
2020-03-03 20:37:47 +03:00
Valentin Bartenev a60f856ce2 Improved validation of the "action" object.
Now it enforces the mutual exclusivity of "pass", "proxy", and "share" options.
2020-03-03 20:37:47 +03:00
Valentin Bartenev d198a105eb Configuration: removing UTF-8 BOM from the input JSON.
Some editors can add it to JSON files.
2020-02-20 17:58:24 +03:00
Valentin Bartenev 044b3afcda Configuration: stripping comments from the input JSON.
This allows to have JavaScript-like comments in the uploading JSON.
2020-02-20 17:58:24 +03:00
Valentin Bartenev 7a0383189c Version bump. 2020-02-19 19:13:51 +03:00
Valentin Bartenev 6e19090736 Added tag 1.15.0 for changeset 801ac82f80fb 2020-02-06 18:20:37 +03:00
Valentin Bartenev e6bb4c5493 Generated Dockerfiles for Unit 1.15.0. 2020-02-06 17:33:44 +03:00
Valentin Bartenev 672602d1ee Added version 1.15.0 CHANGES. 2020-02-06 17:33:44 +03:00
Valentin Bartenev f860c20a96 PHP: added check for the ".php" extension.
A check for the ".php" extension is added to prevent execution of files
with arbitrary extensions in cases where "index" and "script" options
aren't used.
2020-01-28 19:18:26 +03:00
Valentin Bartenev 4bad2cf1e9 Version bump. 2020-01-27 16:52:53 +03:00
Valentin Bartenev d2eac78c57 Updated copyright notice. 2020-01-27 16:52:45 +03:00
Valentin Bartenev 55f8e31ed7 Added tag 1.14.0 for changeset 6e28966ed1f2 2019-12-26 17:04:37 +03:00
Valentin Bartenev be8589d925 Generated Dockerfiles for Unit 1.14.0. 2019-12-26 17:03:21 +03:00
Valentin Bartenev 9403233328 Added version 1.14.0 CHANGES. 2019-12-26 17:03:21 +03:00
Valentin Bartenev 9224e94a8d Removed unused variables from "docs/Makefile".
They actually have been broken since 00d8049418cf,
where NXT_VERSION was removed from nxt_main.h.

Also, shebang is added.
2019-12-24 17:03:47 +03:00
Valentin Bartenev 51af6ac0a1 Python: pre-creation of objects for string constants.
This is an optimization to avoid creating them at runtime on each request.
2019-12-23 21:14:14 +03:00
Valentin Bartenev 0a27f137de Added tag 1.13.0 for changeset 3313bf222e6e 2019-11-14 19:25:20 +03:00
Valentin Bartenev 2241847efb Generated Dockerfiles for Unit 1.13.0. 2019-11-14 19:24:14 +03:00
Valentin Bartenev 182107c10e Added version 1.13.0 CHANGES. 2019-11-14 19:23:38 +03:00
Valentin Bartenev c2976fb337 Python: avoiding buffering of exception backtraces.
A quote from the Python 3 documentation:

 | When interactive, stdout and stderr streams are line-buffered.
 | Otherwise, they are block-buffered like regular text files.

As a result, if an exception occurred and PyErr_Print() was called, its output
could be buffered but not printed to the log for a while (ultimately, until
the interpreter finalization).  If the application process crashed shortly,
the backtrace was completely lost.

Buffering can be disabled by redefining the sys.stderr stream object.
However, interference with standard environment objects was deemed undesirable.
Instead, sys.stderr.flush() is called every time after printing exceptions.
A potential advantage here is that lines from backtraces won't be mixed
with other lines in the log.
2019-11-14 17:48:48 +03:00
Valentin Bartenev 4e41d90006 Python: removed wrong PyErr_Print() call.
PyCallable_Check() doesn't produce errors.

The needless call was introduced in fdd6ed28e3b9.
2019-11-14 17:48:48 +03:00
Valentin Bartenev b3db7a30c0 Python: optimized response object close() calling.
PyObject_HasAttrString() is just a wrapper over PyObject_GetAttrString(),
while PyObject_CallMethod() calls it as the first step.  As a result,
PyObject_GetAttrString() was called twice if close() was present.

To get rid of PyObject_HasAttrString() while keeping the same behaviour,
the PyObject_CallMethod() call has been decomposed into separate calls of
PyObject_GetAttrString() and PyObject_CallFunction().
2019-11-14 17:48:48 +03:00
Valentin Bartenev 75c2c23bb6 Python: fixed an object leak when response close() is called.
On success, PyObject_CallMethod() returns a new reference to
the result of the call, which previously got lost.

Also, error logging on failure was added.

The issue was introduced by b0148ec28c4d.
2019-11-14 17:48:48 +03:00
Valentin Bartenev c667bb446d Python: refactored nxt_python_request_handler(). 2019-11-14 17:48:48 +03:00
Valentin Bartenev cd6cb02be0 Python: fixed potential object leak in case of allocation error. 2019-11-14 17:48:48 +03:00
Valentin Bartenev e9429324c2 Python: improved error handling if response object isn't iterable.
According to the documentation, PyObject_GetIter():

 | Raises TypeError and returns NULL if the object cannot be iterated.

Previously, this exception wasn't printed or cleared and remained unhandled.
2019-11-14 17:48:48 +03:00
Valentin Bartenev e189d0a96c Python: fixed handling of errors on response object iteration.
According to the documentation, PyIter_Next():

 | If there are no remaining values, returns NULL with no exception set.
 | If an error occurs while retrieving the item, returns NULL and passes
 | along the exception.

Previously, this exception wasn't properly handled and the response was
finalized as successful.

This issue was introduced in b0148ec28c4d.

A check for PyErr_Occurred() located in the code below might print this
traceback or occasionally catch an exception from one of the two response
close() calls.

Albeit that exceptions from the close() calls also need to be catched,
it's clear that this particular check wasn't supposed to do so.  This is
another issue and it will be fixed later.
2019-11-14 17:48:48 +03:00
Valentin Bartenev 69ff7ce731 Python: releasing GIL while waiting for a request.
It unblocks other threads that can be forked by the application
to work in background.

This closes #336 issue on GitHub.
2019-11-13 16:45:37 +03:00
Valentin Bartenev cc82547782 Respecting AR environment variable to configure ar binary. 2019-11-07 19:53:25 +03:00
Valentin Bartenev 75453479f3 Configuration: added check for mandatory options of "action". 2019-10-09 15:26:59 +03:00
Valentin Bartenev 1b4c96f265 Version bump. 2019-10-07 18:38:41 +03:00
Valentin Bartenev 59db9a3887 Added tag 1.12.0 for changeset b391df5f0102 2019-10-03 17:34:58 +03:00
Valentin Bartenev 946cbd1f10 Generated Dockerfiles for Unit 1.12.0. 2019-10-03 17:08:32 +03:00
Valentin Bartenev b1cb78ef8e Added version 1.12.0 CHANGES. 2019-10-03 16:30:31 +03:00
Valentin Bartenev 73f096f796 Added response status code to error page body.
Also the error page markup is now valid according to HTML5 specification.
All optional tags were omitted.
2019-10-02 20:04:52 +03:00
Valentin Bartenev f8ff71b917 HTTP: corrected allocation size for tail chunk. 2019-09-30 19:11:17 +03:00
Valentin Bartenev f7d3db314d HTTP parser: removed unused "exten" field.
This field was intended for MIME type lookup by file extension when serving
static files, but this use case is too narrow; only a fraction of requests
targets static content, and the URI presumably isn't rewritten.  Moreover,
current implementation uses the entire filename for MIME type lookup if the
file has no extension.

Instead of extracting filenames and extensions when parsing requests, it's
easier to obtain them right before serving static content; this behavior is
already implemented.  Thus, we can drop excessive logic from parser.
2019-09-30 19:11:17 +03:00
Valentin Bartenev 2dbda125db HTTP parser: normalization of paths ending with "." or "..".
Earlier, the paths were normalized only if there was a "/" at the end, which
is wrong according to section 5.2.4 of RFC 3986 and hypothetically may allow
to the directory above the document root.
2019-09-30 19:11:17 +03:00
Valentin Bartenev f2c0f2899a Refactored nxt_process_create() for more explicit pipe closing. 2019-09-26 16:03:02 +03:00
Valentin Bartenev 9c06bfdf2c Fixed descriptors leak on process creation.
The leak has been introduced in 325b315e48c4.
This closes #322 issue in GitHub.
2019-09-26 16:03:01 +03:00
Valentin Bartenev 514f34144a Static: returning 404 for Unix domain sockets.
It's now similar to how attempts to access other non-regular files are handled.
2019-09-24 15:33:42 +03:00
Valentin Bartenev 5c50329f8e Fixed segfault if an inappropriate file system object is requested.
Found by Coverity (CID 349483).
2019-09-20 14:31:19 +03:00
Valentin Bartenev 8853dece44 Version bump. 2019-09-20 14:29:11 +03:00
Valentin Bartenev db777d1e7f Added tag 1.11.0 for changeset 3b1601ac0f2f 2019-09-19 17:38:16 +03:00
Valentin Bartenev 7d53cc7029 Generated Dockerfiles for Unit 1.11.0. 2019-09-19 17:36:09 +03:00
Valentin Bartenev 2281d9f02c Added version 1.11.0 CHANGES. 2019-09-19 17:28:55 +03:00
Valentin Bartenev 08a8d1510d Basic support for serving static files. 2019-09-19 02:47:09 +03:00
Valentin Bartenev ca01845d89 Configuration: added ability to modify object members with slashes.
Example:

  PUT/POST/DELETE /config/listeners/unix:%2Fpath%2Fto%2Fsocket

This follows a49ee872e83d.
2019-09-18 16:03:28 +03:00
Valentin Bartenev 6352c21a58 HTTP parser: fixed parsing of target after literal space character.
In theory, all space characters in request target must be encoded; however,
some clients may violate the specification.  For the sake of interoperability,
Unit supports unencoded space characters.

Previously, if there was a space character before the extension or arguments
parts, those parts weren't recognized.  Also, quoted symbols and complex
target weren't detected after a space character.
2019-09-17 18:40:21 +03:00
Valentin Bartenev 3b77e402a9 HTTP parser: removed unused "plus_in_target" flag. 2019-09-16 20:17:42 +03:00
Valentin Bartenev 56f4085b9d HTTP parser: removed unused "offset" field.
Thanks to 洪志道 (Hong Zhi Dao).
2019-09-16 20:17:42 +03:00
Valentin Bartenev 2fb7a1bfb9 HTTP parser: removed unused "exten_start" and "args_start" fields. 2019-09-16 20:17:42 +03:00
Valentin Bartenev 64be8717bd Configuration: added ability to access object members with slashes.
Now URI encoding can be used to escape "/" in the request path:

  GET /config/listeners/unix:%2Fpath%2Fto%2Fsocket/
2019-09-16 20:17:42 +03:00
Valentin Bartenev 1298824130 Version bump. 2019-08-26 18:06:03 +03:00
Valentin Bartenev bc57d1d076 Added tag 1.10.0 for changeset cdbba3c3e376 2019-08-22 18:56:22 +03:00
Valentin Bartenev 19f59b221d Generated Dockerfiles for Unit 1.10.0. 2019-08-22 18:43:25 +03:00
Valentin Bartenev 700987c355 Fixed rebuilding of Dockerfiles. 2019-08-22 18:43:21 +03:00
Valentin Bartenev 0a106e3cbc Added version 1.10.0 CHANGES. 2019-08-22 18:43:02 +03:00
Valentin Bartenev 274260bd28 Router: allowed empty configurations.
Now it's possible to delete "listeners" and "applications" objects.

This closes #187 issue on GitHub.
2019-08-06 17:13:13 +03:00
Valentin Bartenev 7fd9444728 Node.js: returning "this" from writeHead() to allow chaining.
In Node.js version 11.10.0 and later, the writeHead() function returns "this".
2019-08-06 16:24:11 +03:00
Valentin Bartenev 242dc363ce Perl: propagated compile options from perl build.
Some Perl compile options affects ABI and not using them while compiling
our module resulted in non-working build.

Notably on 32-bit Debian 10, Perl is built with -D_FILE_OFFSET_BITS=64
and our module after being compiled without this option caused segmentation
faults in unexpected places.
2019-07-17 21:17:30 +03:00
Valentin Bartenev dbce694d5a Perl: removed "--include=" configure option.
It's surplus option because the perl executable returns the proper path.

Also the Perl module configure script was cleaned up a bit.
Note that NXT_PERL_LDOPTS already contains the library path.
2019-07-17 21:17:30 +03:00
Valentin Bartenev ef89815f03 PHP: fixed script filename setting, broken after 2a71417d297f. 2019-07-16 17:58:48 +03:00
Valentin Bartenev 924165c90b PHP: improved response status code handling.
There's no reason to parse "http_status_line"; the PHP interpreter already
does this.  If the line contains a valid status code, it's assigned to
"http_response_code".

This also fixes invalid status line handling, where the nxt_int_parse()
function returned -1; it was cast to unsigned, yielding response code 65535.
2019-07-05 18:42:30 +03:00
Valentin Bartenev b2a0620483 Version bump. 2019-06-10 15:53:26 +03:00
Valentin Bartenev 7da320a93a Added tag 1.9.0 for changeset dda6319de785 2019-05-30 17:39:43 +03:00
Valentin Bartenev 081a6baeb7 Generated Dockerfiles for Unit 1.9.0. 2019-05-30 17:16:24 +03:00
Valentin Bartenev b2d7d6fb02 Added version 1.9 CHANGES. 2019-05-30 17:16:23 +03:00
Valentin Bartenev 6a6bc63c48 Configuration: support for POST operations on arrays.
It allows to add an array element without specifying the index.
2019-04-24 20:31:00 +03:00
Valentin Bartenev 4d35a7bbac Configuration: support for manipulations of array elements.
Now PUT and DELETE operations also work on elements.
This closes #242 issue on GitHub.
2019-04-24 20:31:00 +03:00
Valentin Bartenev 30768b7b3c Refactored nxt_conf_op_compile().
Now index is always initialized for create operations.

The changes in nxt_conf_op_compile() simplify adding upcoming support of
operations with arrays.

No functional changes.
2019-04-24 20:31:00 +03:00
Valentin Bartenev 1467d34d73 Removed unused field from nxt_conf_op_s. 2019-04-24 20:31:00 +03:00
Valentin Bartenev 094cc2fc99 Packages: using "pass" option in config examples.
The "application" option has been deprecated since 1.8.0.
2019-04-24 20:31:00 +03:00
Valentin Bartenev c1a3b06d03 Tests: using "pass" option instead of deprecated "application". 2019-04-22 18:20:53 +03:00
Valentin Bartenev 5e1cf14565 Controller: rejecting double wildcards. 2019-04-12 17:44:55 +03:00
Valentin Bartenev f0cc14d394 Simplified cycles in nxt_http_route_rule(). 2019-04-12 17:44:54 +03:00
Valentin Bartenev 7b839bf5da Backed out changeset f74d4dd9c3db.
This closes #240 issue on GitHub.
2019-04-03 18:40:47 +03:00
Valentin Bartenev f3a0d95d09 Version bump. 2019-03-05 14:57:46 +03:00
Valentin Bartenev df02b03824 Added tag 1.8.0 for changeset 0a18a14d169f 2019-03-01 18:26:10 +03:00
Valentin Bartenev 204dfec879 Generated Dockerfiles for Unit 1.8.0. 2019-03-01 18:23:39 +03:00
Valentin Bartenev 050cfb6d5b Added version 1.8.0 CHANGES. 2019-03-01 18:23:38 +03:00
Valentin Bartenev d92feef571 README.JSR-340 legal notice to save our ughm.. bottoms of bodies. 2019-03-01 17:12:40 +03:00
Valentin Bartenev a5dd0f8aa9 Made QUERY_STRING mandatory.
According to CGI/1.1 RFC 3875:

   The server MUST set this variable; if the Script-URI does not include a
   query component, the QUERY_STRING MUST be defined as an empty string ("").

Python's PEP 333(3) allows omitting it in WSGI interface; PHP docs force no
requirements; PSGI and Rack specifications require it even if empty.

When nginx proxies requests over FastCGI, it always provides QUERY_STRING.
and some PHP apps have been observed to fail if it is missing (see issue
#201 on GitHub).

A drawback of this change (besides a small overhead) is that there will be
no easy way to tell a missing query string from an empty one (i.e. requests
with or without the "?" character); yet, it's negligible compared to the
possible benefits of wider application compatibility.

This closes #226 issue on GitHub.
2019-02-28 20:20:41 +03:00
Valentin Bartenev 5c9fe8c306 Added trailing zero to version string.
While it looks nicer without zero 3-rd version number, this should
improve interoperability.  Version string can be parsed or used for
sorting.  And it is easier to handle and less confusing when there
is constant number of version parts.

Moreover, NPM also expects version format with 3 parts.
So ".0" has already been used in Node.js module version.
2019-02-27 17:25:28 +03:00
Valentin Bartenev e929d08201 Fixed processing of SERVER_NAME after 77aad2c142a0.
Previously, the nxt_router_prepare_msg() function expected server host among
other headers unmodified.  It's not true anymore since normalization of the
Host header has been introduced in 77aad2c142a0.

The nxt_unit_split_host() function was removed.  It didn't work correctly with
IPv6 literals.  Anyway, after 77aad2c142a0 the port splitting is done in router
while Host header processing.
2019-02-27 17:25:07 +03:00
Valentin Bartenev a881c31abd Controller: added "routes" configuration. 2019-02-27 16:50:37 +03:00
Valentin Bartenev c24c0deb19 Controller: added "pass" configuration option. 2019-02-27 16:44:52 +03:00
Valentin Bartenev ce6ce15c20 Fixed violation of the strict aliasing rules in 5d0edd35c4ce.
In order to reduce number of operations over rb-tree and process them in
batches simultaneously, all the timers changes are temporary stored in array.
While processing of these changes, the same memory is also used for storing
pointers to postpone timers adding.

As the same block of memory has been referenced by two different types of
pointers (nxt_timer_change_t * and nxt_timer_t **), some compilers may reorder
operations with these pointers and produce broken code.  See ticket #221 on
GitHub for a particular case.

Now the same "nxt_timer_change_t" structure is used in both cases.

Also, reverted the -fno-strict-aliasing flag, which has been introduced in
ef76227ec159 as a workaround for this issue.
2019-02-26 17:42:20 +03:00
Valentin Bartenev d8c0a0dbe2 Disabled useless code in nxt_router_listen_socket_error().
It doesn't do anything useful, among creating a JSON message and logging it
to debug log.  Besides that it causes segmentation fault if the RPC handler
is triggered with an empty buffer due to exiting of the main process.
2019-02-25 15:10:44 +03:00
Valentin Bartenev c5563d142d Removed surplus check for NUL in nxt_http_validate_host().
Such header fields are already rejected by HTTP parser.
2019-02-23 14:48:33 +03:00
Valentin Bartenev 2d4697dbbe Validation and normalization of request host. 2019-02-19 20:25:25 +03:00