You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SocketsHttpHandler (and WinHttpHandler) do not enforce response Content-Length correctness #62906
There are three modes of operation to look at here:
HTTP/1 - Content-Length, unchunked.
Note user is only sending us a single Content-Length here.
If server sends too little, we will hang with timeout.
If server sends too much, we will close connection via the read-ahead task OR throw a parse error when reading next response.
HTTP/1 - Content-Length, chunked.
Now server is sending us two content lengths: one in Content-Length header and one that is the total number of bytes received via chunked encoding.
Spec says we can either handle it or treat it as an error, and that if we handle it, we should use the total chunked encoding bytes received and ignore the Content-Length header.
If we did choose to handle it, we need to make a choice of altering Content-Length header returned to caller, or if that inconsistency should be kept there for the caller to handle. It sounds like current behavior today is the latter.
HTTP/2
This also has two content lengths: one in Content-Length header and one that is the total number of bytes received via DATA frames.
Spec says we should treat as error and RST_STREAM.
For the HTTP/1 case of receiving both, my understanding is that we should handle it as chunk-encoded, whereas currently, we treat it as Content-Length.
This also changes what data the user will read from the content stream - we should be decoding chunked encoding framing.
For the HTTP/1 case of receiving both, my understanding is that we should handle it as chunk-encoded, whereas currently, we treat it as Content-Length. This also changes what data the user will read from the content stream - we should be decoding chunked encoding framing.
Activity
karelz commentedon Dec 16, 2021
Triage:
Content-Lengthmode only and chunked encoding (withContent-Length)Content-Length-- see RFCNotes:
scalablecory commentedon Dec 16, 2021
There are three modes of operation to look at here:
MihaZupan commentedon Dec 16, 2021
For the HTTP/1 case of receiving both, my understanding is that we should handle it as chunk-encoded, whereas currently, we treat it as
Content-Length.This also changes what data the user will read from the content stream - we should be decoding chunked encoding framing.
JamesNK commentedon Dec 17, 2021
Please also check HTTP/3 when you do this work. It should be similar to HTTP/2. Hopefully, the only difference in behavior is the error code.
karelz commentedon Jul 21, 2022
Triage: No customer report. Not a regression, moving to Future.
rokonec commentedon Jul 29, 2024
This has been already addressed in: #69016