curl / Mailing Lists / curl-users / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: --etag-save overwrites on status 304

From: Timothe Litt <litt_at_acm.org>
Date: Mon, 2 Oct 2023 14:17:28 -0400

On 02-Oct-23 14:03, Paul Gilmartin via curl-users wrote:
> On 10/2/23 11:33:36, Timothe Litt via curl-users wrote:
>>>
>> Curl should write the ETag header received with the 304.  Is the
>> server sending it?
>>
> It did not.
>
>> If not, it's a server bug.
>>
>> Note RFC2616 REQUIRES ETag to be sent "if it would have been sent in
>> a 200 response to the same request".
>>
> That's a weird contrafactual statement.  The server could not have
> "sent ... a 200 response to the same request" because the "if none
> match would have required the 304.  Should the RFC be amended?
>
> I read <https://datatracker.ietf.org/doc/html/rfc2616#section-14.26>:
>     ... the server SHOULD
>    respond with a 304 (Not Modified) response, including the cache-
>    related header fields (particularly ETag) of one of the entities that
>    matched. ...
>
> How does SHOULD differ from MUST?
>
>> If the server is sending it, but curl isn't writing it to the
>> --etag-save, it's a curl bug.
>
2616 has been updated.  A more recent RFC that addresses conditional
requests is https://datatracker.ietf.org/doc/html/rfc7232#section-4.1

> The server generating a 304 response MUST generate any of the
> following header fields that would have been sent in a 200 (OK)
> response to the same request: Cache-Control, Content-Location, Date,
> ETag, Expires, and Vary.
The statement isn't weird.  What it means is that if the request wasn't
conditional, or if the condition fails, a 200 OK would have been sent -
with the ETag (and the others listed).  When a 304 is generated instead
of a 200, it MUST contain the same ETag (and other listed headers) that
the elided 200 would have contained.

MUST and SHOULD are defined in RFC2119
https://datatracker.ietf.org/doc/html/rfc2119

MUST This word, or the terms "REQUIRED" or "SHALL", mean that the
    definition is an absolute requirement of the specification.

SHOULD This word, or the adjective "RECOMMENDED", mean that there
    may exist valid reasons in particular circumstances to ignore a
    particular item, but the full implications must be understood and
    carefully weighed before choosing a different course.


Timothe Litt
ACM Distinguished Engineer
--------------------------
This communication may not represent the ACM or my employer's views,
if any, on the matters discussed.


-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-users
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2023-10-02