RESOLVED FIXED Bug 224933
[LayoutTests] http/tests/misc/last-modified-parsing.html handles non-standard dates differently in PHP than Python
https://bugs.webkit.org/show_bug.cgi?id=224933
Summary [LayoutTests] http/tests/misc/last-modified-parsing.html handles non-standard...
Chris Gambrell
Reported 2021-04-22 08:34:14 PDT
In PHP, the Last-Modified header will send with any format of date, even if the date-string is blank it will send a blank Last-Modified header. When Python encounters a non-standard/blank date-string, it will not send the Last-Modified header. This test tests expectations with standard and non-standard dates. We need to change the test to match the expectations from Python with how it handles non-standard dates in the header.
Attachments
Patch (4.40 KB, patch)
2021-04-22 12:30 PDT, Chris Gambrell
no flags
Patch (11.55 KB, patch)
2021-05-11 11:13 PDT, Chris Gambrell
no flags
Patch (9.86 KB, patch)
2021-05-12 13:42 PDT, Chris Gambrell
no flags
Patch for landing (9.95 KB, patch)
2021-05-12 15:57 PDT, Chris Gambrell
no flags
Radar WebKit Bug Importer
Comment 1 2021-04-22 08:35:20 PDT
Chris Gambrell
Comment 2 2021-04-22 12:30:20 PDT
Chris Gambrell
Comment 3 2021-04-22 12:32:53 PDT
Comment on attachment 426837 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=426837&action=review > LayoutTests/http/tests/misc/last-modified-parsing-expected.txt:11 > Fri, 21 Nov 2008 01:03:33 GMT Removed untested dates > LayoutTests/http/tests/misc/last-modified-parsing.html:12 > test('Tuesday, 21 Nov 2008 01:03:33 GMT'); Removed non-standard dates
Darin Adler
Comment 4 2021-04-25 13:31:43 PDT
We want to test how WebKit software (the whole stack, including CFNetwork) handles these date formats. I understand that the Python library we are using makes it difficult to test this, but that doesn’t remove the need to do the testing. How will we do this testing, now?
Jonathan Bedard
Comment 5 2021-04-26 07:06:41 PDT
(In reply to Darin Adler from comment #4) > We want to test how WebKit software (the whole stack, including CFNetwork) > handles these date formats. I understand that the Python library we are > using makes it difficult to test this, but that doesn’t remove the need to > do the testing. How will we do this testing, now? This actually isn't a limitation of Python. It's a limitation of Apache, which refuses to serve what it considers invalid date formats coming from CGI scripts. Short of building our own webserver, I'm not sure what can be done. Apache could end up taking away this ability from PHP in a future update as well. As reflected in Chris's EWS run, Apache on Windows looks like it has a more strict set of rules than on other platforms.
Darin Adler
Comment 6 2021-04-26 13:09:26 PDT
(In reply to Jonathan Bedard from comment #5) > (In reply to Darin Adler from comment #4) > > We want to test how WebKit software (the whole stack, including CFNetwork) > > handles these date formats. I understand that the Python library we are > > using makes it difficult to test this, but that doesn’t remove the need to > > do the testing. How will we do this testing, now? > > This actually isn't a limitation of Python. It's a limitation of Apache, > which refuses to serve what it considers invalid date formats coming from > CGI scripts. Short of building our own webserver, I'm not sure what can be > done. Apache could end up taking away this ability from PHP in a future > update as well. As reflected in Chris's EWS run, Apache on Windows looks > like it has a more strict set of rules than on other platforms. OK. So we can’t use Apache for this. How can we test this aspect of WebKit networking behavior?
Jonathan Bedard
Comment 7 2021-04-26 13:25:05 PDT
(In reply to Darin Adler from comment #6) > (In reply to Jonathan Bedard from comment #5) > > (In reply to Darin Adler from comment #4) > > > We want to test how WebKit software (the whole stack, including CFNetwork) > > > handles these date formats. I understand that the Python library we are > > > using makes it difficult to test this, but that doesn’t remove the need to > > > do the testing. How will we do this testing, now? > > > > This actually isn't a limitation of Python. It's a limitation of Apache, > > which refuses to serve what it considers invalid date formats coming from > > CGI scripts. Short of building our own webserver, I'm not sure what can be > > done. Apache could end up taking away this ability from PHP in a future > > update as well. As reflected in Chris's EWS run, Apache on Windows looks > > like it has a more strict set of rules than on other platforms. > > OK. So we can’t use Apache for this. > > How can we test this aspect of WebKit networking behavior? Alexey pointed out there is an Apache setting, `send-as-is`, which may let us work-around this. If that fails, the next step would be looking at the wpt webserver and see if that lets us test what we're looking to.
Alexey Proskuryakov
Comment 8 2021-04-26 13:33:45 PDT
https://httpd.apache.org/docs/current/mod/mod_asis.html This cannot perform any processing of course, it's just a fixed response.
Jonathan Bedard
Comment 9 2021-04-26 14:08:08 PDT
AsIs still changes these dates.
Sam Sneddon [:gsnedders]
Comment 10 2021-04-27 00:17:09 PDT
(In reply to Jonathan Bedard from comment #7) > If that fails, the next step would be looking at the wpt webserver and see > if that lets us test what we're looking to. This definitely works with wptserve. Note that the server has a bunch of built-in support for things like varying headers: https://web-platform-tests.org/writing-tests/server-pipes.html#headers, so we can just replace last-modified.php with an HTML file. (Ideally we'd rewrite this to use testharness.js with moving it to http/wpt, but that's a larger change!)
Chris Gambrell
Comment 11 2021-05-11 11:13:00 PDT
Jonathan Bedard
Comment 12 2021-05-11 12:09:33 PDT
Comment on attachment 428297 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=428297&action=review > LayoutTests/http/wpt/misc/last-modified-parsing.js:6 > +} Any reason we didn't put this inside http/wpt/misc/no-last-modified.html? > LayoutTests/http/wpt/misc/no-last-modified.js:4 > +}, "Last-Modified sent with no date"); Any reason we didn't put this inside http/wpt/misc/no-last-modified.html? > LayoutTests/platform/win/TestExpectations:-4410 > -webkit.org/b/209455 http/tests/misc/last-modified-parsing.html [ Failure ] Pretty sure Windows will still struggle with this, although I suppose it's possible that is was actually Apache that was the problem, and not the engine, I guess EWS will let us know
Sam Sneddon [:gsnedders]
Comment 13 2021-05-12 05:41:24 PDT
Comment on attachment 428297 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=428297&action=review > LayoutTests/http/wpt/misc/last-modified-parsing.js:1 > +function test(date) { Let's not call this function test, as that redefines the test function defined in testharness.js; maybe test_last_modified or something? > LayoutTests/http/wpt/misc/no-last-modified.js:3 > + assert_greater_than((new Date(Date.parse(actual))).getTime(), (new Date()).getTime() - (24+1)*60*60*1000); We probably want `assert_approx_equals` with an epsilon of maybe 1 minute? >> LayoutTests/http/wpt/misc/no-last-modified.js:4 >> +}, "Last-Modified sent with no date"); > > Any reason we didn't put this inside http/wpt/misc/no-last-modified.html? Additionally, is there any reason why we don't just put this into last-modified-parsing.html? It leads to us having last-modified-utilities.sub.js as a separate file, and it's not clear what the benefit here is? It's still about parsing a header value, just an empty one. > LayoutTests/http/wpt/misc/resources/last-modified-utilities.sub.js:1 > +function observeResources(n) { This function is dead code. > LayoutTests/http/wpt/misc/resources/last-modified-utilities.sub.js:24 > + iframe.addEventListener('error', reject); We don't want the error event here (there's no error event ever fired on an iframe, far as I can tell) > LayoutTests/http/wpt/misc/resources/last-modified-utilities.sub.js:26 > + iframe.src = "/common/blank.html?pipe=header(Last-Modified," + header_value.replace(' ', '%20').replace(',', '\\,') + ")"; What's the reason for the header_value.replace(' ', '%20') (which the browser's URL parsing will do anyway), versus something broader like encodeURI/encodeURIComponent? > LayoutTests/http/wpt/misc/resources/last-modified-utilities.sub.js:32 > +} This file doesn't need .sub. in its name. (See also above about merging no-last-modified and last-modified-parsing, which would mean this file could then be merged into last-modified-parsing.)
Chris Gambrell
Comment 14 2021-05-12 13:42:01 PDT
Chris Gambrell
Comment 15 2021-05-12 13:43:03 PDT
(In reply to Sam Sneddon [:gsnedders] from comment #13) > Comment on attachment 428297 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=428297&action=review > > > LayoutTests/http/wpt/misc/last-modified-parsing.js:1 > > +function test(date) { > > Let's not call this function test, as that redefines the test function > defined in testharness.js; maybe test_last_modified or something? > > > LayoutTests/http/wpt/misc/no-last-modified.js:3 > > + assert_greater_than((new Date(Date.parse(actual))).getTime(), (new Date()).getTime() - (24+1)*60*60*1000); > > We probably want `assert_approx_equals` with an epsilon of maybe 1 minute? > > >> LayoutTests/http/wpt/misc/no-last-modified.js:4 > >> +}, "Last-Modified sent with no date"); > > > > Any reason we didn't put this inside http/wpt/misc/no-last-modified.html? > > Additionally, is there any reason why we don't just put this into > last-modified-parsing.html? It leads to us having > last-modified-utilities.sub.js as a separate file, and it's not clear what > the benefit here is? It's still about parsing a header value, just an empty > one. > > > LayoutTests/http/wpt/misc/resources/last-modified-utilities.sub.js:1 > > +function observeResources(n) { > > This function is dead code. > > > LayoutTests/http/wpt/misc/resources/last-modified-utilities.sub.js:24 > > + iframe.addEventListener('error', reject); > > We don't want the error event here (there's no error event ever fired on an > iframe, far as I can tell) > > > LayoutTests/http/wpt/misc/resources/last-modified-utilities.sub.js:26 > > + iframe.src = "/common/blank.html?pipe=header(Last-Modified," + header_value.replace(' ', '%20').replace(',', '\\,') + ")"; > > What's the reason for the header_value.replace(' ', '%20') (which the > browser's URL parsing will do anyway), versus something broader like > encodeURI/encodeURIComponent? > > > LayoutTests/http/wpt/misc/resources/last-modified-utilities.sub.js:32 > > +} > > This file doesn't need .sub. in its name. (See also above about merging > no-last-modified and last-modified-parsing, which would mean this file could > then be merged into last-modified-parsing.) These as well as comment 12's comments addressed and fixed in comment 14
Jonathan Bedard
Comment 16 2021-05-12 15:31:48 PDT
Comment on attachment 428413 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=428413&action=review > LayoutTests/platform/win/TestExpectations:4410 > +webkit.org/b/209455 http/wpt/misc/last-modified-parsing.html [ Failure ] Looks like the test failure on Windows EWS sees is this same bug
Chris Gambrell
Comment 17 2021-05-12 15:57:08 PDT
Created attachment 428424 [details] Patch for landing
EWS
Comment 18 2021-05-12 16:24:29 PDT
Committed r277408 (237658@main): <https://commits.webkit.org/237658@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 428424 [details].
Note You need to log in before you can comment on or make changes to this bug.