Opened 4 years ago

Closed 4 years ago

#2062 closed defect (invalid)

Nginx doesn't support HTTP status code 417 (Expectation Failed)

Reported by: spacewander@… Owned by:
Priority: minor Milestone:
Component: nginx-core Version: 1.19.x
Keywords: Cc:
uname -a: Linux ubuntu-bionic 4.15.0-121-generic #123-Ubuntu SMP Mon Oct 5 16:16:40 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.19.3
built by gcc 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)
configure arguments:

Description

According to the HTTP spec,

The 417 (Expectation Failed) status code indicates that the
expectation given in the request's Expect header field
(Section 5.1.1) could not be met by at least one of the inbound
servers.

However, Nginx doesn't return 417 when the Expect header is given. It even doesn't have the status code defined.

For example:
conf:

worker_processes 1;
daemon off;
error_log stderr info;
events {
    worker_connections 65535;
}
http {
    server {
        client_max_body_size 32;
        listen       28002 reuseport;
        location / {
            return 200 "data";
        }
    }
}

test:

$ curl -i "http://127.0.0.1:28002/417" -d @$(which nginx) -v
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 28002 (#0)
> POST /417 HTTP/1.1
> Host: 127.0.0.1:28002
> User-Agent: curl/7.58.0
> Accept: */*
> Content-Length: 1561690
> Content-Type: application/x-www-form-urlencoded
> Expect: 100-continue
>
< HTTP/1.1 413 Request Entity Too Large
HTTP/1.1 413 Request Entity Too Large
< Server: nginx/1.19.3
Server: nginx/1.19.3
< Date: Mon, 19 Oct 2020 08:03:23 GMT
Date: Mon, 19 Oct 2020 08:03:23 GMT
< Content-Type: text/html
Content-Type: text/html
< Content-Length: 183
Content-Length: 183
< Connection: close
Connection: close

<
<html>
<head><title>413 Request Entity Too Large</title></head>
<body>
<center><h1>413 Request Entity Too Large</h1></center>
<hr><center>nginx/1.19.3</center>
</body>
</html>
* Closing connection 0

Change History (1)

comment:1 by Maxim Dounin, 4 years ago

Resolution: invalid
Status: newclosed

The only expectation defined by RFC 7231 is 100-continue. Since nginx supports this expectation, it does not need to return responses with the 417 (Expectation Failed) status code.

Note well that in the "test" provided in the ticket description there is no need to return neither 100 (Continue) nor 417 (Expectation Failed) status code, since the final status code is known and immediately returned.

Note: See TracTickets for help on using tickets.