diff --git a/content/base/test/Makefile.in b/content/base/test/Makefile.in index a5bc5e6fef2..e0b6c3d25b7 100644 --- a/content/base/test/Makefile.in +++ b/content/base/test/Makefile.in @@ -324,6 +324,8 @@ _TEST_FILES = test_bug5141.html \ bug466409-page.html \ bug466409-empty.css \ test_bug466409.html \ + test_bug482935.html \ + bug482935.sjs \ test_classList.html \ $(NULL) # Disabled; see bug 492181 diff --git a/content/base/test/bug482935.sjs b/content/base/test/bug482935.sjs new file mode 100644 index 00000000000..9d20eab0f19 --- /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 00000000000..89c3e103900 --- /dev/null +++ b/content/base/test/test_bug482935.html @@ -0,0 +1,121 @@ + + + + Test bug 482935 + + + + + + + + diff --git a/netwerk/protocol/http/src/nsHttpChannel.cpp b/netwerk/protocol/http/src/nsHttpChannel.cpp index 87c4aadf6be..ddd363e5bce 100644 --- a/netwerk/protocol/http/src/nsHttpChannel.cpp +++ b/netwerk/protocol/http/src/nsHttpChannel.cpp @@ -5124,6 +5124,11 @@ nsHttpChannel::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult st LOG(("nsHttpChannel::OnStopRequest [this=%x request=%x status=%x]\n", this, request, status)); + // allow content to be cached if it was loaded successfully (bug #482935) + PRBool contentComplete = PR_FALSE; + if (NS_SUCCEEDED(status)) + contentComplete = PR_TRUE; + // honor the cancelation status even if the underlying transaction completed. if (mCanceled || NS_FAILED(mStatus)) status = mStatus; @@ -5214,7 +5219,7 @@ nsHttpChannel::OnStopRequest(nsIRequest *request, nsISupports *ctxt, nsresult st } if (mCacheEntry) - CloseCacheEntry(PR_TRUE); + CloseCacheEntry(!contentComplete); if (mOfflineCacheEntry) CloseOfflineCacheEntry();