Mola-maker opened a new issue, #9049:
URL: https://github.com/apache/opendal/issues/9049
### OpenDAL version or commit
main (57f8b75)
### Affected service or component
core: `parse_last_modified` (`core/core/src/raw/http_util/header.rs`), used
by `parse_into_metadata` and by the http, webdav, azblob, azdls, azfile, swift
and other HTTP-based services.
### Describe the bug
`parse_last_modified` parses `Last-Modified` with
`Timestamp::parse_rfc2822`, which accepts only the IMF-fixdate format. RFC 9110
ยง5.6.7 says recipients **MUST** accept all three HTTP-date formats:
```
Sun, 06 Nov 1994 08:49:37 GMT ; IMF-fixdate
Sunday, 06-Nov-94 08:49:37 GMT ; obsolete RFC 850 format
Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format
```
If a server sends either obsolete format, metadata parsing fails. Then every
`stat` **and** `read` of the object fails with `Unexpected`, even though the
body itself is fine.
### Steps to Reproduce
I ran a local HTTP server that returns `Content-Length: 5` and the given
`Last-Modified`, then used `services::Http` against it (Windows 11, main
57f8b75):
```rust
let op = Operator::new(Http::default().endpoint("http://127.0.0.1:18931"))?;
op.stat("file.txt").await;
op.read("file.txt").await;
```
```
== Last-Modified format: imf
stat: Ok(len=5, last_modified=Some("1994-11-06T08:49:37Z"))
read: Ok("hello")
== Last-Modified format: rfc850
stat: Err(Unexpected) ... => parse 'Sunday, 06-Nov-94 08:49:37 GMT' into
rfc2822 failed
read: Err(Unexpected) ... => parse 'Sunday, 06-Nov-94 08:49:37 GMT' into
rfc2822 failed
== Last-Modified format: asctime
stat: Err(Unexpected) ... => parse 'Sun Nov 6 08:49:37 1994' into rfc2822
failed
read: Err(Unexpected) ... => parse 'Sun Nov 6 08:49:37 1994' into rfc2822
failed
```
### Actual Behavior
`stat` and `read` fail for objects whose `Last-Modified` header uses the RFC
850 or asctime format.
### Expected Behavior
All three HTTP-date formats are accepted. Each one in the example above
gives `1994-11-06T08:49:37Z`.
### Additional Context
WebDAV `getlastmodified` is defined as an rfc1123-date (RFC 4918), and the
Azure and pCloud listers parse body fields rather than HTTP headers, so only
the header path needs this change.
### Reproduction confirmation
- [x] I reproduced this issue against the affected component. For a
service-specific report, I used the actual service rather than only a mock,
emulator, or source-code analysis.
### Are you willing to submit a PR to fix this bug?
- [x] Yes, I would like to submit a PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]