Commit graph

4 commits

Author SHA1 Message Date
Reedy
c8276f731a tests: Add more use statements in namespaced classes
Change-Id: I2629cfcb09fde6f18be824779a2c12c013ea0cb5
2024-02-18 21:31:02 +00:00
Jakob Warkotsch
64ddedb63d ConditionalHeaderUtil: Handle If-None-Match: *
The relevant section in the RFC says the following:

> If the field-value is "*", the condition is false if the origin
> server has a current representation for the target resource.
> An origin server that evaluates an If-None-Match condition MUST NOT
> perform the requested method if the condition evaluates to false;
> instead, the origin server MUST respond with either a) the 304 (Not
> Modified) status code if the request method is GET or HEAD or b) the
> 412 (Precondition Failed) status code for all other request methods.

https://httpwg.org/specs/rfc9110.html

Bug: T319382
Change-Id: Ieb3269d61de42242602ec9c46e19c4f2c3b37f6e
2022-10-07 09:06:04 +00:00
daniel
39b721667a REST: Allow weak ETags to match strong ETags.
This changes handling of the If-Match header so a weak ETag coming from
the client may match a strong ETag generated by the handler.

This is needed because ETags may get "weakened" on the way to the client
by proxies and middleware, e.g. Varnish applying compression, see
<https://varnish-cache.org/docs/6.0/users-guide/compression.html>.

This behavior is technically a violation of RFC 7232 section 3.1, but it
should actually be safe: A client sending a weak ETag is still ok with
getting a strong match, and a handler that generates a strong ETag knows
that it can rely on strong semantics holding, even if the tag sent by
the client is weak.

Bug: T310710
Bug: T238849
Change-Id: I2a604f2f46719a5f74ddac1b1fa58c8a36910240
2022-06-27 12:52:42 +00:00
Tim Starling
558471f044 Conditional request support
* Added ConditionalHeaderUtil, a conditional request helper class meant
  for composition into Handler. I evaluated the composer package
  micheh/psr7-cache for this role but I decided that I prefer DIY
  code rather than some rather ugly glue.
* Check conditional request headers prior to entry into
  Handler::execute(). Contrary to what was previously documented, use
  the results of getLastModified() and getETag() to set headers in the
  response. This is convenient and can be overridden in the Handler if
  desired by overriding a one-line function.
* Instead of locking up header parsing inside ConditionalHeaderUtil as
  was done in micheh/psr7-cache, make a start on a new reusable header
  parsing framework, with recursive descent parsers for HTTP-date and
  IfNoneMatch.

Change-Id: I260809081cad7701df8620ab03834158670d4230
2019-10-14 12:01:25 +11:00