pyfisch / httpdate Goto Github PK
View Code? Open in Web Editor NEWHTTP date parsing and formatting
License: Apache License 2.0
HTTP date parsing and formatting
License: Apache License 2.0
Hi I think it's beneficial to expose DateTime
type, for two reasons:
While developing with httpdate
with sites such as Google search site at https://www.google.com, the Set-Cookie response header has an expires
time with four digits year:
Set-Cookie: CONSENT=PENDING+705; expires=Wed, 15-Nov-2023 09:20:03 GMT; path=/; domain=.google.com; Secure
When trying to parse this date with httpdate
it raises a parse error.
Next date with only two digits is parsed rightly:
Wed, 15-Nov-23 09:20:03 GMT
Would it be possible to parse as right the date below with four year digits?
Hi! What's your feeling on accepting lowercase variations of the date format?
I'm currently using httpdate
to parse and compare modified dates for resources in my webserver. Strictly speaking, the HTTP standard says that clients should send back the exact date I previously served them, but in practice I see many clients who don't. In cases where I can figure out what they mean, I'd like to be flexible to increase the chances of a 304 Not Modified. Thus my use of httpdate
rather than an exact string compare.
However, I'm seeing clients in practice that send all headers lowercased, including the contents of if-modified-since. This means I receive a date that would be otherwise valid, except for letter case. httpdate
's parser is strict and it rejects these dates. Per Postel's Law I'm going to modify the server to accept lowercase, and I'm trying to figure out if that means I need to fork this crate.
Thanks!
Would you accept a pull request exposing a format function that takes an &mut [u8; 29] to format into? I think this can be implemented by moving the Display::fmt implementation to its own pub function, since it already formats into a [u8; 29].
This is useful when avoiding allocations (or using an arena/bump allocator) and sending the response as an &[IoSlice] with the vectored writing functions.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.