hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jonathan Moore (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HTTPCLIENT-958) client cache currently allows incomplete responses to be passed on to the client
Date Fri, 25 Jun 2010 16:18:50 GMT

    [ https://issues.apache.org/jira/browse/HTTPCLIENT-958?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12882624#action_12882624
] 

Jonathan Moore commented on HTTPCLIENT-958:
-------------------------------------------

Ok, the stopgap fix is to detect this situation for 200 or 206 responses, and return a 502
(Bad Gateway) error instead. This is conditionally compliant cache behavior, although potentially
not optimal. The RFC suggests that it would be permissible to convert these responses into
properly-formatted 206 responses instead, although since the caching code does not currently
have any support for partial responses or byte ranges, this seemed too complicated to undertake
without further discussion.

The tricky thing would be if a 206 response arrived with:

Content-Length: 100
Content-Range: bytes 0-9,50-139/255

but only 50 bytes in the body; we'd have to parse the existing Content-Range to figure out
which bytes we *did* get, and then produce the appropriate:

Content-Range: bytes 0-9,50-89/255

I can work on doing this, however, if the current stopgap solution isn't acceptible (I don't
think this is a very likely case to arise in practice).


> client cache currently allows incomplete responses to be passed on to the client
> --------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-958
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-958
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: Cache
>            Reporter: Jonathan Moore
>            Priority: Minor
>         Attachments: incomplete-response.patch
>
>
> Per the HTTP/1.1 spec:
> "A cache that receives an incomplete response (for example, with fewer bytes of data
than specified in a Content-Length header) MAY store the response. However, the cache MUST
treat this as a partial response. Partial responses MAY be combined as described in section
13.5.4; the result might be a full response or might still be partial. A cache MUST NOT return
a partial response to a client without explicitly marking it as such, using the 206 (Partial
Content) status code. A cache MUST NOT return a partial response using a status code of 200
(OK)."
> (http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.8)
> For example, if a 200 response shows up with 128 bytes in the body but a Content-Length
header of 256, the cache MUST NOT pass this through unchanged.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message