Opened 10 years ago

Closed 9 years ago

#736 closed defect (wontfix)

Nginx responses 412 to invalid If-Unmodified-Since request-header

Reported by: wai wai li Owned by:
Priority: major Milestone:
Component: nginx-module Version: 1.7.x
Keywords: invalid If-Unmodified-Since Cc:
uname -a: N/A
nginx -V: nginx/1.7.7

Description

Sending request with If-Unmodified-Since header to Ngnix:

  1. If the specified date is valid, Nginx responses 200
       > If-Unmodified-Since: Wed, 25 Mar 2015 02:07:01 GMT
       >
       < HTTP/1.1 200 OK
       * Server nginx/1.7.7 is not blacklisted
       < Server: nginx/1.7.7
       < Date: Wed, 25 Mar 2015 02:07:55 GMT
    
  1. If the specified date is invalid, Nginx responses 412
       > If-Unmodified-Since: Wed, 25 MMar 2015 02:07:01 GMT
       >
       < HTTP/1.1 412 Precondition Failed
       * Server nginx/1.7.7 is not blacklisted
       < Server: nginx/1.7.7
       < Date: Wed, 25 Mar 2015 02:11:24 GMT
       < Content-Type: text/html
       < Content-Length: 188
       < Connection: keep-alive
    
   > If-Unmodified-Since: Wed, 25 Mar 2015 02,07,01 GMT
   >
   < HTTP/1.1 412 Precondition Failed
   * Server nginx/1.7.7 is not blacklisted
   < Server: nginx/1.7.7
   < Date: Wed, 25 Mar 2015 02:12:23 GMT
   < Content-Type: text/html
   < Content-Length: 188
   < Connection: keep-alive

According to http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.28
"
If the specified date is invalid, the header is ignored.
"

In this case, should Nginx responses 200?

Change History (3)

comment:1 by wai wai li, 10 years ago

Sending request with If-Unmodified-Since header to Ngnix:

  1. If the specified date is valid, Nginx responses 200
   > If-Unmodified-Since: Wed, 25 Mar 2015 02:07:01 GMT
   >
   < HTTP/1.1 200 OK
   * Server nginx/1.7.7 is not blacklisted
   < Server: nginx/1.7.7
   < Date: Wed, 25 Mar 2015 02:07:55 GMT
  1. If the specified date is invalid, Nginx responses 412
   > If-Unmodified-Since: Wed, 25 MMar 2015 02:07:01 GMT
   >
   < HTTP/1.1 412 Precondition Failed
   * Server nginx/1.7.7 is not blacklisted
   < Server: nginx/1.7.7
   < Date: Wed, 25 Mar 2015 02:11:24 GMT
   < Content-Type: text/html
   < Content-Length: 188
   < Connection: keep-alive
   > If-Unmodified-Since: Wed, 25 Mar 2015 02,07,01 GMT
   >
   < HTTP/1.1 412 Precondition Failed
   * Server nginx/1.7.7 is not blacklisted
   < Server: nginx/1.7.7
   < Date: Wed, 25 Mar 2015 02:12:23 GMT
   < Content-Type: text/html
   < Content-Length: 188
   < Connection: keep-alive

According to ​http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.28
"
If the specified date is invalid, the header is ignored.
"

In this case, SHOULDN'T Nginx response 200 instead of 412?

comment:2 by Maxim Dounin, 9 years ago

All of the above times are recognized by nginx to be -1, the last UTC second of 1969. Hence for all possible responses the If-Unmodified-Since condition fails.

While it is certainly possible to change the behaviour to strictly follow RFC and ignore the header in such cases, it's not clear why this change is needed.

On the other hand, it's clear that such a change will make subrange requests with incorrect If-Unmodified-Since less safe, as any date formatting error will silently render If-Unmodified-Since conditions useless.

comment:3 by Maxim Dounin, 9 years ago

Resolution: wontfix
Status: newclosed

Feedback timeout. No reasoning provided for the suggested change. Current behaviour is believed to be safe and good enough.

Note: See TracTickets for help on using tickets.