Commit Graph

78 Commits

Author SHA1 Message Date
Alejandro Colomar
a3d19f71a2 Fixed indentation.
Some lines (incorrectly) had an indentation of 3 or 5, or 7 or 9,
or 11 or 13, or 15 or 17 spaces instead of 4, 8, 12, or 16.  Fix them.

Found with:

$ find src -type f | xargs grep -n '^   [^ ]';
$ find src -type f | xargs grep -n '^     [^ *]';
$ find src -type f | xargs grep -n '^       [^ ]';
$ find src -type f | xargs grep -n '^         [^ *]';
$ find src -type f | xargs grep -n '^           [^ +]';
$ find src -type f | xargs grep -n '^             [^ *+]';
$ find src -type f | xargs grep -n '^               [^ +]';
$ find src -type f | xargs grep -n '^                 [^ *+]';
2022-04-26 12:38:48 +02:00
Valentin Bartenev
aed1c55a06 Removed the execute permission bit from "nxt_h1proto.c".
It was accidentally added in 4645a43bc248.
2021-11-11 18:54:10 +03:00
Max Romanov
db03dfad67 Fixed dead assignments.
Found by Clang Static Analyzer.
2021-08-03 13:59:27 +03:00
Andrey Suvorov
3efffddd95 Fixing crash during TLS connection shutdown.
A crash was caused by an incorrect timer handler nxt_h1p_idle_timeout() if
SSL_shutdown() returned SSL_ERROR_WANT_READ/SSL_ERROR_WANT_WRITE.

The flag SSL_RECEIVED_SHUTDOWN is used to avoid getting SSL_ERROR_WANT_READ, so
the server won't wait for a close notification from a client.

For SSL_ERROR_WANT_WRITE, a correct timer handler is set up.
2021-05-26 11:11:58 -07:00
Valentin Bartenev
2348229dc7 PHP: populating PHP_AUTH_* server variables.
This closes #498 issue on GitHub.
2020-12-08 01:59:46 +03:00
Valentin Bartenev
bda76b04e9 HTTP: fixed status line format for unknown status codes.
According to Section #3.1.2 of RFC 7230, after the status code
there must be a space even if the reason phrase is empty.

Also, only 3 digits allowed.

This closes #507 issue on GitHub.
2020-12-07 18:50:56 +03:00
Valentin Bartenev
fb80502513 HTTP parser: allowed more characters in header field names.
Previously, all requests that contained in header field names characters other
than alphanumeric, or "-", or "_" were rejected with a 400 "Bad Request" error
response.

Now, the parser allows the same set of characters as specified in RFC 7230,
including: "!", "#", "$", "%", "&", "'", "*", "+", ".", "^", "`", "|", and "~".
Header field names that contain only these characters are considered valid.

Also, there's a new option introduced: "discard_unsafe_fields".  It accepts
boolean value and it is set to "true" by default.

When this option is "true", all header field names that contain characters
in valid range, but other than alphanumeric or "-" are skipped during parsing.
When the option is "false", these header fields aren't skipped.

Requests with non-valid characters in header field names according to
RFC 7230 are rejected regardless of "discard_unsafe_fields" setting.

This closes #422 issue on GitHub.
2020-11-17 16:50:06 +03:00
Max Romanov
c5cb2432c4 Fixing router connection pool leakage.
The connection's local socket address is allocated from the connection
pool before the request is passed to the application; however, with keep-alive
connections, this field was unconditionally reset by a socket configuration
value that could be NULL.  For the next request, the address was allocated
again from the same connection pool.  Nonetheless, all leaked addresses
were released when the connection was closed.

The issue introduced in changeset 5c7dd85fabd5.
2020-09-30 16:36:57 +03:00
Max Romanov
c4b000f9cc Supporting HTTP/1.0 keep-alive.
The Apache HTTP server benchmarking tool, ab, issues HTTP/1.0 requests with
the 'Connection: Keep-Alive' header and expects a 'Connection: Keep-Alive'
header in the response.
2020-09-29 22:57:46 +03:00
Igor Sysoev
6b9882fc14 Fixed segmentation fault during reconfiguration.
If idle connection was closed before h1proto had been allocated
then c->socket.data is NULL.  This happens if nxt_h1p_idle_response()
is called by nxt_h1p_idle_close().  However, h1p->conn_write_tail
is used only in nxt_h1p_request_send() that would not be called
after nxt_h1p_idle_response().

The bug was introduced in f237e8c553fd.
2020-09-18 13:20:06 +03:00
Igor Sysoev
6cfbf4ba79 Fixed segmentation fault during reconfiguration. 2020-09-18 13:20:05 +03:00
Igor Sysoev
09f4db1fc0 Fixed use-after-free error during reconfiguration.
An idle connection was not removed from idle connection list
if the connections detected that listening socket had been closed.
2020-09-18 13:20:02 +03:00
Valentin Bartenev
b0ff245ca8 Improved mkstemp() error reporting.
The invocation parameters should be logged as well, notably the path of the file
that is failed to be created.

Also, log level changed to ALERT as it's quite critical error.
2020-08-05 16:11:20 +03:00
Igor Sysoev
65799c7252 Upstream chunked transfer encoding support. 2020-06-23 14:16:45 +03:00
Max Romanov
6bda9b5eeb Using malloc/free for the http fields hash.
This is required due to lack of a graceful shutdown: there is a small gap
between the runtime's memory pool release and router process's exit. Thus, a
worker thread may start processing a request between these two operations,
which may result in an http fields hash access and subsequent crash.

To simplify issue reproduction, it makes sense to add a 2 sec sleep before
exit() in nxt_runtime_exit().
2020-04-16 17:09:23 +03:00
Igor Sysoev
04143c8c7e Fixed crash that occurs when idle connections are closed forcibly. 2020-04-15 14:54:09 +03:00
Valentin Bartenev
c63b498f94 Implemented "location" option for "return" action.
This allows to specify redirects:

  {
      "action": {
          "return": 301,
          "location": "https://www.example.com/"
      }
  }
2020-03-21 01:39:00 +03:00
Max Romanov
59e06e4910 Completing buffers immediately
This fixes crash introduced in 039b00e32e3d.
2020-03-19 22:04:43 +03:00
Max Romanov
c26fbbe53a Completing request header buffers to avoid memory leak.
Before this fix, only persistent connection request buffers were completed.

This issue was introduced in dc403927ab0b.
2020-03-19 20:43:35 +03:00
Max Romanov
5296be0b82 Using disk file to store large request body.
This closes #386 on GitHub.
2020-03-12 17:54:29 +03:00
Max Romanov
0b5aabfc3f Checking Content-Length value right after header parse.
The check was moved from the request body read stage.
2020-03-12 17:54:19 +03:00
Igor Sysoev
7935ea4543 Round robin upstream added. 2020-03-06 18:28:54 +03:00
Max Romanov
806b3945fe Introducing write tail reference to avoid buffer chain iteration. 2019-12-24 18:04:00 +03:00
Igor Sysoev
02e197e978 Processing inconsistent proxied response length.
Keepalive connection is disabled if upstream response length
differs from specified in the "Content-Length" field value.
2019-11-14 16:40:02 +03:00
Igor Sysoev
ddde9c23cf Initial proxy support. 2019-11-14 16:39:54 +03:00
Igor Sysoev
57e326b411 Introduced chained buffer completion handlers. 2019-11-14 16:39:48 +03:00
Igor Sysoev
643c433f8e Using event engine memory buffers in HTTP/1 layer. 2019-11-14 16:39:48 +03:00
Igor Sysoev
d4e3951c4d Using request task. 2019-11-14 16:39:48 +03:00
Igor Sysoev
09e7357b08 Style fixes. 2019-10-10 19:42:41 +03:00
Igor Sysoev
ec0d5c928e Changed nxt_memcasecmp() interface to avoid casts. 2019-10-10 19:37:40 +03:00
Valentin Bartenev
f8ff71b917 HTTP: corrected allocation size for tail chunk. 2019-09-30 19:11:17 +03:00
Max Romanov
daadc2e00b Making request state handler calls more consistent. 2019-09-02 18:27:08 +03:00
Igor Sysoev
e2abfaf381 Adding body handler to nxt_http_request_header_send(). 2019-08-26 18:29:00 +03:00
Max Romanov
e501c74ddc Introducing websocket support in router and libunit. 2019-08-20 16:31:53 +03:00
Max Romanov
686f5b1436 Changing the sequence of body send execution.
Request state ready_handler required for further websocket events processing.
It is not required for regular response transferring.
2019-08-16 14:55:18 +03:00
Igor Sysoev
c7210eaa5a nxt_h1proto_t definition was moved to h1proto implementation. 2019-08-06 15:29:40 +03:00
Igor Sysoev
17bb22a4e4 Refactored HTTP protocol callback table. 2019-08-06 15:29:39 +03:00
Axel Duch
7785c96c1a Added routing based on request scheme.
Scheme matches exact string “http” or “https”.
2019-07-24 13:47:35 +03:00
Max Romanov
452ce0789e Adjusting request schema value according to connection tls state.
This closes #223 issue on GitHub.
2019-03-21 13:55:57 +03:00
Igor Sysoev
834e8ca576 Fixed timer and event race condition.
When idle timeout occurs at the same time as a request comes in,
the timer handler closes connection while the read event triggers
request processing, and this eventually leads to segmentation fault.
2019-02-28 18:04:11 +03:00
Igor Sysoev
444b9ffea9 Keepalive mode is disabled on HTTP header parsing errors. 2019-02-26 19:12:16 +03:00
Valentin Bartenev
2d4697dbbe Validation and normalization of request host. 2019-02-19 20:25:25 +03:00
Valentin Bartenev
d54d806c52 Disabled chunked transfer encoding for 304 responses as well.
According to RFC 7232:

 | A 304 response cannot contain a message-body; it is always terminated
 | by the first empty line after the header fields.
2018-10-01 15:06:31 +03:00
Valentin Bartenev
3c2eddb183 Allowing keep-alive connections after 204 responses.
This was unintentionally disabled by 7b5026a0bdeb.
2018-10-01 15:06:31 +03:00
Igor Sysoev
b5d4fc939e Disabled chunked transfer encoding for 204 responses. 2018-09-28 17:32:02 +03:00
Igor Sysoev
b5d76454ed Added nginx error 497 response. 2018-09-20 15:05:38 +03:00
Igor Sysoev
96cd68b340 Added SSL/TLS support on connection level. 2018-09-20 15:05:37 +03:00
Igor Sysoev
8654372842 Fixed segfault on listening socket close.
Now keep-alive connection sends 408 response if listening
socket was closed while reconfiguration.
2018-07-30 17:05:49 +03:00
Igor Sysoev
69a1169cae Sending 408 response on idle connection timeout. 2018-07-30 17:05:48 +03:00
Igor Sysoev
5de582f6db Disabling keep-alive connection on errors. 2018-07-12 18:29:22 +03:00