diff --git a/content/base/test/Makefile.in b/content/base/test/Makefile.in index 303d80ea7368..305989f699c8 100644 --- a/content/base/test/Makefile.in +++ b/content/base/test/Makefile.in @@ -248,6 +248,8 @@ _TEST_FILES1 = test_bug5141.html \ test_bug454325.html \ file_bug391728_2.html \ test_bug456262.html \ + test_bug482935.html \ + bug482935.sjs \ test_bug590870.html \ file_bug590870.html \ test_bug590812.html \ diff --git a/content/base/test/bug482935.sjs b/content/base/test/bug482935.sjs new file mode 100644 index 000000000000..daadb5ab2fae --- /dev/null +++ b/content/base/test/bug482935.sjs @@ -0,0 +1,12 @@ +function handleRequest(request, response) { + var body = "initial"; + + try { + body = request.getHeader("X-Request"); + } catch(e) { + body = "request.getHeader() failed! Exception: " + e; + } + + response.setHeader("Cache-Control", "max-age=3600"); + response.bodyOutputStream.write(body, body.length); +} diff --git a/content/base/test/test_bug482935.html b/content/base/test/test_bug482935.html new file mode 100644 index 000000000000..202556f3cb13 --- /dev/null +++ b/content/base/test/test_bug482935.html @@ -0,0 +1,121 @@ + + + + Test bug 482935 + + + + + + + + diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index 59f1b699fc67..b60c9a5d441c 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -3870,6 +3870,9 @@ nsHttpChannel::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult st LOG(("nsHttpChannel::OnStopRequest [this=%p request=%p status=%x]\n", this, request, status)); + // allow content to be cached if it was loaded successfully (bug #482935) + PRBool contentComplete = NS_SUCCEEDED(status); + // honor the cancelation status even if the underlying transaction completed. if (mCanceled || NS_FAILED(mStatus)) status = mStatus; @@ -3962,7 +3965,7 @@ nsHttpChannel::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult st } if (mCacheEntry) - CloseCacheEntry(PR_TRUE); + CloseCacheEntry(!contentComplete); if (mOfflineCacheEntry) CloseOfflineCacheEntry();