-
Notifications
You must be signed in to change notification settings - Fork 38.5k
ServletWebRequest.checkNotModified(…) writes Last-Modified header in invalid format [SPR-13090] #17681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Brian Clozel commented Hey Oliver Drotbohm,
I've renamed those methods I'm not quite sure about one part though; since #15948, HTTP response headers I'd be happy to discuss those changes with you and Rossen Stoyanchev. |
Oliver Drotbohm commented Couldn't the automatic addition of the header values be guarded by a check whether they're contained in what's returned from the controller? And if so, skip the addition step? I think that if a controller manually sets these values, the values from the controller should be the ones that end up in the request. The way the suggested commit looks to me, I'd still end up with two values in the response for the |
Brian Clozel commented This is now fixed and has been validated with a spring-data-rest test. |
Oliver Drotbohm commented I still see the header added twice:
|
Brian Clozel commented Reopening as duplicate headers are still being written to the response |
Oliver Drotbohm commented Confirmed fixed! \o/ Thanks for your patience. :) |
Oliver Drotbohm commented I am still running into a regression with this: Spring Data RESTs |
Oliver Drotbohm commented I've altered the headers example we have for Spring Data REST to check for the presence of the headers to show the failure in this branch. |
Brian Clozel commented Here is a new fix for this issue. Oliver Drotbohm, all your tests pass with that one, and I've basically cleared the relationship between Thanks Arjen Poutsma - discussing this issue with you probably avoided further back and forth between framework and data-rest... |
Arjen Poutsma commented Looks good to me. |
Brian Clozel commented This is merged and available in the latest SNAPSHOTs. |
Oliver Drotbohm commented Looks good to me now: https://travis-ci.org/spring-projects/spring-data-examples/builds/68832926 |
Florent Bonamis commented We have a problem with this bug fixed in our web application. |
Brian Clozel commented Hi Florent Bonamis, Could you elaborate? Thanks, |
Oliver Drotbohm opened SPR-13090 and commented
As of version 4.2 RC1
ServletWebRequest
has acheckNotModified(String, long)
method, that – unexpectedly – sets headers (the method name does not imply that). Even worse, it callssetDateHeader(…)
on the response, which writes the given timestamp as is. This is wrong as per HTTP spec the value has to be a formatted date.So if you set a
Last-Modified
header in a controller and return aResponseEntity
, the just mentioned check adds an invalid header to the response and later on adds the actually correct value as second value for that parameter.Trying to access the header value then finally fails with an execption as
HttpHeaders.getLastModified()
tries to parse the first value found into aDate
which it can't because of the invalid format.I'd argue:
check…
method that changes the state of the object is weirdLast-Modified
in this case) is present it will be added later on by definition. Why create a second code path that writes headers and bypasses the code paths making sure headers are in the right formatI'd expect a single header value to be present in the response in the correct format.
The issue can be verified running https://github.com/spring-projects/spring-data-examples/tree/master/rest/headers and changing the Spring version to be used to anything 4.2.
Affects: 4.2 RC1
Issue Links:
Referenced from: commits dba46c1, 39d689d, a421bd2, e2c8d37, 0175068
0 votes, 5 watchers
The text was updated successfully, but these errors were encountered: