History log of /unit/src/nxt_http_parse.c (Results 1 – 25 of 48)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 2139:99d792169ffb 16-Jun-2022 Andrew Clayton

Constified numerous function parameters.

As was pointed out by the cppcheck[0] static code analysis utility we
can mark numerous function parameters as 'const'. This acts as a hint to
the compiler a

Constified numerous function parameters.

As was pointed out by the cppcheck[0] static code analysis utility we
can mark numerous function parameters as 'const'. This acts as a hint to
the compiler about our intentions and the compiler will tell us when we
deviate from them.

[0]: https://cppcheck.sourceforge.io/

show more ...


Revision tags: 1.27.0-1, 1.27.0
# 2084:7d479274f334 30-Apr-2022 Alejandro Colomar

Fixed #define style.

We had a mix of styles for declaring function-like macros:

Style A:
#define \
foo() \
do { \
...

Fixed #define style.

We had a mix of styles for declaring function-like macros:

Style A:
#define \
foo() \
do { \
... \
} while (0)

Style B:
#define foo() \
do { \
... \
} while (0)

We had a similar number of occurences of each style:

$ grep -rnI '^\w*(.*\\' | wc -l
244
$ grep -rn 'define.*(.*)' | wc -l
239

(Those regexes aren't perfect, but a very decent approximation.)

Real examples:

$ find src -type f | xargs sed -n '/^nxt_double_is_zero/,/^$/p'
nxt_double_is_zero(f) \
(fabs(f) <= FLT_EPSILON)

$ find src -type f | xargs sed -n '/define nxt_http_field_set/,/^$/p'
#define nxt_http_field_set(_field, _name, _value) \
do { \
(_field)->name_length = nxt_length(_name); \
(_field)->value_length = nxt_length(_value); \
(_field)->name = (u_char *) _name; \
(_field)->value = (u_char *) _value; \
} while (0)

I'd like to standardize on a single style for them, and IMO,
having the identifier in the same line as #define is a better
option for the following reasons:

- Programmers are used to `#define foo() ...` (readability).
- One less line of code.
- The program for finding them is really simple (see below).

function grep_ngx_func()
{
if (($# != 1)); then
>&2 echo "Usage: ${FUNCNAME[0]} <func>";
return 1;
fi;

find src -type f \
| grep '\.[ch]$' \
| xargs grep -l "$1" \
| sort \
| xargs pcregrep -Mn "(?s)^\$[\w\s*]+?^$1\(.*?^}";

find src -type f \
| grep '\.[ch]$' \
| xargs grep -l "$1" \
| sort \
| xargs pcregrep -Mn "(?s)define $1\(.*?^$" \
| sed -E '1s/^[^:]+:[0-9]+:/&\n\n/';
}

$ grep_ngx_func
Usage: grep_ngx_func <func>

$ grep_ngx_func nxt_http_field_set
src/nxt_http.h:98:

#define nxt_http_field_set(_field, _name, _value) \
do { \
(_field)->name_length = nxt_length(_name); \
(_field)->value_length = nxt_length(_value); \
(_field)->name = (u_char *) _name; \
(_field)->value = (u_char *) _value; \
} while (0)

$ grep_ngx_func nxt_sprintf
src/nxt_sprintf.c:56:

u_char * nxt_cdecl
nxt_sprintf(u_char *buf, u_char *end, const char *fmt, ...)
{
u_char *p;
va_list args;

va_start(args, fmt);
p = nxt_vsprintf(buf, end, fmt, args);
va_end(args);

return p;
}

................
Scripted change:
................

$ find src -type f \
| grep '\.[ch]$' \
| xargs sed -i '/define *\\$/{N;s/ *\\\n/ /;s/ //}'

show more ...


Revision tags: 1.26.1-1, 1.26.1, 1.26.0-1, 1.26.0, 1.25.0-1, 1.25.0, 1.24.0-1, 1.24.0, 1.23.0-1, 1.23.0, 1.22.0-1, 1.22.0, 1.21.0-1, 1.21.0
# 1709:1fe93c17d23f 17-Nov-2020 Valentin Bartenev

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

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.

show more ...


Revision tags: 1.20.0-1, 1.20.0, 1.19.0-1, 1.19.0, 1.18.0-1, 1.18.0, 1.17.0-1, 1.17.0
# 1459:358b957ca294 16-Apr-2020 Max Romanov

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
wor

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().

show more ...


Revision tags: 1.16.0-1, 1.16.0, 1.15.0-1, 1.15.0, 1.14.0-1, 1.14.0, 1.13.0-1, 1.13.0
# 1270:9efa309be18b 14-Nov-2019 Igor Sysoev

Initial proxy support.


Revision tags: 1.12.0-1, 1.12.0
# 1214:c3666b232602 30-Sep-2019 Valentin Bartenev

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
targ

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.

show more ...


# 1213:f334dd97291d 30-Sep-2019 Valentin Bartenev

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 hypothet

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.

show more ...


Revision tags: 1.11.0-2, 1.11.0-1, 1.11.0
# 1171:968424f2804c 17-Sep-2019 Valentin Bartenev

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 s

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.

show more ...


# 1170:830d6af7d24c 16-Sep-2019 Valentin Bartenev

HTTP parser: removed unused "plus_in_target" flag.


# 1168:d4b329089cca 16-Sep-2019 Valentin Bartenev

HTTP parser: removed unused "exten_start" and "args_start" fields.


# 1167:a49ee872e83d 16-Sep-2019 Valentin Bartenev

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/


Revision tags: 1.10.0-2, 1.10.0-1, 1.10.0
# 1126:50a8b6ded8e2 15-Aug-2019 Max Romanov

Improving response header fields processing.

Fields are filtered one by one before being added to fields list.
This avoids adding and then skipping connection-specific fields.


Revision tags: 1.9.0-1, 1.9.0
# 1059:11b44092759d 30-May-2019 Igor Sysoev

Added routing based on header fields.


# 1008:84f2370bd642 11-Mar-2019 Andrey Zelenkov

Style.


Revision tags: 1.8.0-1, 1.8.0, 1.7.1-1, 1.7.1, 1.7-1, 1.7, 1.6-1, 1.6, 1.5-1, 1.5, 1.4-2, 1.4, 1.3
# 712:95538a9d4050 03-Jul-2018 Valentin Bartenev

HTTP parser: relaxed checking of fields values.

Allowing characters up to 0xFF doesn't conflict with RFC 7230.
Particularly, this make it possible to pass unencoded UTF-8 data
through HTTP headers,

HTTP parser: relaxed checking of fields values.

Allowing characters up to 0xFF doesn't conflict with RFC 7230.
Particularly, this make it possible to pass unencoded UTF-8 data
through HTTP headers, which can be useful.

show more ...


# 704:1fcac04f0a15 25-Jun-2018 Igor Sysoev

Removed '\r' and '\n' artifact macros.


Revision tags: 1.2, 1.1, 1.0
# 623:d9631fc41049 10-Apr-2018 Valentin Bartenev

HTTP parser: saving partial method.

This is useful for log purposes.


# 622:8ba4abc08034 10-Apr-2018 Valentin Bartenev

HTTP parser: saving unsupported version.

This is useful for log purposes.


# 621:944d059f7a4b 10-Apr-2018 Valentin Bartenev

HTTP parser: correct "target" for partial or invalid request line.


# 613:e5dd7bc63d59 05-Apr-2018 Valentin Bartenev

Style.


# 611:323e11065f83 04-Apr-2018 Valentin Bartenev

Style: capitalized letters in hexadecimal literals.


Revision tags: 0.7
# 577:000a777d3716 15-Mar-2018 Valentin Bartenev

HTTP parser: excluding leading and trailing tabs from field values.

As required by RFC 7230.


# 576:7567b2a5ebfb 15-Mar-2018 Valentin Bartenev

HTTP parser: allowing tabs in field values as per RFC 7230.


# 575:52c8c2a000d0 15-Mar-2018 Valentin Bartenev

HTTP parser: restricting allowed characters in fields values.

According to RFC 7230 only printable 7-bit ASCII characters are allowed
in field values.


# 574:1ec560778942 15-Mar-2018 Valentin Bartenev

HTTP parser: fixed parsing of field values ending with space.

This closes #82 issue on GitHub.


12