Closed Bug 305420 Opened 19 years ago Closed 18 years ago

XMLHttpRequest.responseText is empty on 304 response

Categories

(Core :: XML, defect)

1.7 Branch
x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: autarch, Unassigned)

Details

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.10) Gecko/20050730 Firefox/1.0.6 (Debian package 1.0.6-2)
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.10) Gecko/20050730 Firefox/1.0.6 (Debian package 1.0.6-2)

I wrote some code to set "If-Modified-Since" headers when using XMLHttpRequest.
 This worked well enough (I'll file another bug for a cosmetic problem) and the
server responds with a 304 when appropriate.

Unfortunately, when XMLHttpRequest sees a 304 repsonse the responseText property
is not set, which is useless.  It needs to fetch the requested resource from the
local cache and populate the responseText (and presumably responseXML)
properties, or there's no point to setting caching headers ;)

Reproducible: Always

Steps to Reproduce:
1. Set an If-Modified-Since header as part of an XMLHttpRequest using the
setRequestHeader method
2. Send the request.
3. Take a look at the responseText after the request is sent.

Actual Results:  
responseText is not set when status is 304.

Expected Results:  
set the darn responseText ;)
Is there a reason this bug is filed in the Firefox product (I'd normally just
move it but since it has a NEW status I'm not so sure)?
Assignee: nobody → xml
Component: General → XML
Product: Firefox → Core
QA Contact: general → ashshbhatt
Version: unspecified → 1.8 Branch
Dave, can you still reproduce this problem with a recent build?
Version: 1.8 Branch → 1.7 Branch
I suspect this is fixed now by bug 268844
hrm, although bug 331825 probably broke it :)
WONTFIX.  if you set if-modified-since headers manually then you are making an explicit conditional request.  there is no message body in a 304 response.
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → WONTFIX
(In reply to comment #5)
> WONTFIX.  if you set if-modified-since headers manually then you are making an
> explicit conditional request.  there is no message body in a 304 response.

I understand the thinking behind this, but I think there's still a bug in here. Basically, if response{Text,XML} don't get automatically populated from the cache on a 304, that makes sense. However, I think there still needs to be a way to get the data from the cache.

In other words, a request made via XMLHttpRequest should be able to emulate the behavior of the browser in handling a 304, even if that emulation requires some additional code on the JS author's side. Without that ability, there's no useful way to handle a 304 with XHR.
if you don't set any headers explicitly, then a 304 will get turned into a 200 automatically in ff 1.5 and 2.0.
Ok, from a careful reading of 331825 it sounds like the XHR component is now transparently making caching work, which is exactly what I'd hoped for.

Thanks.
You need to log in before you can comment on or make changes to this bug.