- http://bugzilla.opendarwin.org/show_bug.cgi?id=5499
Page reload does not send any cache control headers
WebCore:
* bindings/js/kjs_window.cpp:
(KJS::LocationFunc::callAsFunction): Call scheduleRefresh() for Location::Reload.
* page/Frame.h: Add scheduleRefresh(). Don't derive from TransferJob or implement its methods - that was
used only for storing response HTTP headers, which was an overkill.
* page/FramePrivate.h: Replace TransferJob with a HashMap for storing response headers.
* page/Frame.cpp:
(WebCore::Frame::didOpenURL): Don't needlessly change d->m_cachePolicy. Don't create a TransferJob.
(WebCore::Frame::stopLoading): Directly access the metadata map, instead of going through a TransferJob.
(WebCore::Frame::receivedFirstData): Ditto.
(WebCore::Frame::addMetaData): Ditto.
(WebCore::Frame::scheduleRefresh): A new function that schedules a refresh, similarly to what
scheduleRedirection() does.
(WebCore::Frame::changeLocation): Set request.reload attribute based on the current cache policy.
WebKit:
* WebView/WebFrame.m:
(-[WebFrame _addExtraFieldsToRequest:mainResource:alwaysFromRequest:]): Set a proper Cache-Control header for
reload requests.
(-[WebFrame loadRequest:]): Reset loadType to WebFrameLoadTypeStandard (after a reload, it stayed at
WebFrameLoadTypeReload, so _addExtraFieldsToRequest erroneously added a Cache-Control header to them).
LayoutTests:
* http/tests/misc/refresh-headers-expected.txt: Added.
* http/tests/misc/refresh-headers.php: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@14920
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-06-19 Alexey Proskuryakov <ap@nypop.com>
+
+ Reviewed by Darin.
+
+ - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=5499
+ Page reload does not send any cache control headers
+
+ * http/tests/misc/refresh-headers-expected.txt: Added.
+ * http/tests/misc/refresh-headers.php: Added.
+
2006-06-19 Alexey Proskuryakov <ap@nypop.com>
Reviewed by Darin.
--- /dev/null
+SUCCESS
+
+Test for bug 5499: Page reload does not send any cache control headers.
--- /dev/null
+<?php
+ $gotMaxAge=false;
+ $gotNoCache=false;
+ $headers = getallheaders();
+
+ foreach ($headers as $name => $content) {
+ if (0 == strcasecmp($name, "Cache-Control") && 0 == strcasecmp($content, "max-age=0"))
+ {
+ $gotMaxAge = true;
+ }
+
+ if ((0 == strcasecmp($name, "Cache-Control") && 0 == strcasecmp($content, "no-cache")) ||
+ (0 == strcasecmp($name, "Pragma") && 0 == strcasecmp($content, "no-cache")))
+ {
+ $gotNoCache = true;
+ }
+ }
+
+ if ($gotNoCache) {
+ echo '<p>Got a no-cache directive; FAILURE!</p>';
+ echo '<script>if (window.layoutTestController) { layoutTestController.notifyDone(); }</script>';
+ } else if ($gotMaxAge) {
+ echo '<p>SUCCESS</p>';
+ echo '<script>if (window.layoutTestController) { layoutTestController.notifyDone(); }</script>';
+ } else {
+ echo '<body onload="window.location.reload();">';
+ echo '<p>No cache control headers, reloading...</p>';
+ echo '<script>if (window.layoutTestController) { layoutTestController.waitUntilDone(); }</script>';
+ echo '<script>function test() {window.location.reload();}</script>';
+ }
+
+ echo '<script>if (window.layoutTestController) { layoutTestController.dumpAsText(); }</script>';
+ echo '<p>Test for <a href="http://bugzilla.opendarwin.org/show_bug.cgi?id=5499">bug 5499</a>: Page reload does not send any cache control headers.</p>';
+?>
+2006-06-19 Alexey Proskuryakov <ap@nypop.com>
+
+ Reviewed by Darin.
+
+ - http://bugzilla.opendarwin.org/show_bug.cgi?id=5499
+ Page reload does not send any cache control headers
+
+ Test: http/tests/misc/refresh-headers.php
+
+ * bindings/js/kjs_window.cpp:
+ (KJS::LocationFunc::callAsFunction): Call scheduleRefresh() for Location::Reload.
+
+ * page/Frame.h: Add scheduleRefresh(). Don't derive from TransferJob or implement its methods - that was
+ used only for storing response HTTP headers, which was an overkill.
+
+ * page/FramePrivate.h: Replace TransferJob with a HashMap for storing response headers.
+
+ * page/Frame.cpp:
+ (WebCore::Frame::didOpenURL): Don't needlessly change d->m_cachePolicy. Don't create a TransferJob.
+ (WebCore::Frame::stopLoading): Directly access the metadata map, instead of going through a TransferJob.
+ (WebCore::Frame::receivedFirstData): Ditto.
+ (WebCore::Frame::addMetaData): Ditto.
+ (WebCore::Frame::scheduleRefresh): A new function that schedules a refresh, similarly to what
+ scheduleRedirection() does.
+ (WebCore::Frame::changeLocation): Set request.reload attribute based on the current cache policy.
+
2006-06-19 Ben Goodger <bengoodger@gmail.com>
Reviewed by Darin.
case Location::Reload:
{
const Window* window = Window::retrieveWindow(frame);
- Frame* activePart = Window::retrieveActive(exec)->frame();
if (!frame->url().url().startsWith("javascript:", false) || (window && window->isSafeScript(exec))) {
bool userGesture = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter())->wasRunByUserGesture();
- frame->scheduleLocationChange(frame->url().url(), activePart->referrer(), true/*lock history*/, userGesture);
+ frame->scheduleRefresh(userGesture);
}
break;
}
#include "SegmentedString.h"
#include "TextDocument.h"
#include "TextIterator.h"
-#include "TransferJob.h"
#include "TypingCommand.h"
#include "cssstyleselector.h"
#include "htmlediting.h"
closeURL();
- if (d->m_request.reload)
- d->m_cachePolicy = KIO::CC_Refresh;
- else
- d->m_cachePolicy = KIO::CC_Verify;
-
- if (d->m_request.doPost() && url.protocol().startsWith("http")) {
- d->m_job = new TransferJob(this, "POST", url, d->m_request.postData);
- d->m_job->addMetaData("content-type", d->m_request.contentType());
- } else
- d->m_job = new TransferJob(this, "GET", url);
-
d->m_bComplete = false;
d->m_bLoadingMainResource = true;
d->m_bLoadEventEmitted = false;
{
if (d->m_doc && d->m_doc->tokenizer())
d->m_doc->tokenizer()->stopParsing();
-
- if (d->m_job)
- {
- d->m_job->kill();
- d->m_job = 0;
- }
+
+ d->m_metaData.clear();
if (sendUnload) {
if (d->m_doc) {
DeprecatedString qData;
// Support for http-refresh
- qData = d->m_job->queryMetaData("http-refresh").deprecatedString();
+ qData = d->m_metaData.get("http-refresh").deprecatedString();
if (!qData.isEmpty()) {
double delay;
int pos = qData.find(';');
}
// Support for http last-modified
- d->m_lastModified = d->m_job->queryMetaData("modified");
-}
-
-void Frame::receivedAllData(TransferJob* job)
-{
- d->m_job = 0;
-
- if (job->error()) {
- checkCompleted();
- return;
- }
-
- d->m_workingURL = KURL();
-
- if (d->m_doc->parsing())
- end(); // will call completed()
+ d->m_lastModified = d->m_metaData.get("modified");
}
void Frame::childBegin()
startRedirectionTimer();
}
+void Frame::scheduleRefresh(bool userGesture)
+{
+ // Handle a location change of a page with no document as a special case.
+ // This may happen when a frame requests a refresh of another frame.
+ d->m_scheduledRedirection = d->m_doc ? locationChangeScheduled : locationChangeScheduledDuringLoad;
+
+ // If a refresh was scheduled during a load, then stop the current load.
+ // Otherwise when the current load transitions from a provisional to a
+ // committed state, pending redirects may be cancelled.
+ if (d->m_scheduledRedirection == locationChangeScheduledDuringLoad)
+ stopLoading(true);
+
+ d->m_delayRedirect = 0;
+ d->m_redirectURL = url().url();
+ d->m_redirectReferrer = referrer();
+ d->m_redirectLockHistory = true;
+ d->m_redirectUserGesture = userGesture;
+ d->m_cachePolicy = KIO::CC_Refresh;
+ stopRedirectionTimer();
+ if (d->m_bComplete)
+ startRedirectionTimer();
+}
+
bool Frame::isScheduledLocationChangePending() const
{
switch (d->m_scheduledRedirection) {
if (!referrer.isEmpty())
request.setReferrer(referrer);
+ request.reload = (d->m_cachePolicy == KIO::CC_Reload) || (d->m_cachePolicy == KIO::CC_Refresh);
+
urlSelected(request, "_self");
}
changeLocation(URL, referrer, lockHistory, userGesture);
}
-void Frame::receivedRedirect(TransferJob*, const KURL& url)
-{
- d->m_workingURL = url;
-}
-
DeprecatedString Frame::encoding() const
{
if (d->m_haveEncoding && !d->m_encoding.isEmpty())
void Frame::addMetaData(const String& key, const String& value)
{
- d->m_job->addMetaData(key, value);
+ d->m_metaData.set(key, value);
}
// This does the same kind of work that Frame::openURL does, except it relies on the fact
#include "Node.h"
#include "TextAffinity.h"
#include "TextGranularity.h"
-#include "TransferJobClient.h"
#include <wtf/Vector.h>
#include "RenderObject.h"
ObjectContentPlugin,
};
-class Frame : public Shared<Frame>, Noncopyable, TransferJobClient {
+class Frame : public Shared<Frame>, Noncopyable {
public:
enum { NoXPosForVerticalArrowNavigation = INT_MIN };
*/
void changeLocation(const DeprecatedString& URL, const DeprecatedString& referrer, bool lockHistory = true, bool userGesture = false);
void scheduleLocationChange(const DeprecatedString& url, const DeprecatedString& referrer, bool lockHistory = true, bool userGesture = false);
+ void scheduleRefresh(bool userGesture = false);
bool isScheduledLocationChangePending() const;
/**
void reparseConfiguration();
private:
- virtual void receivedRedirect(TransferJob*, const KURL&);
- virtual void receivedAllData(TransferJob*);
void childBegin();
, m_bJavaEnabled(true)
, m_bPluginsEnabled(true)
, m_settings(0)
- , m_job(0)
, m_bComplete(true)
, m_bLoadingMainResource(false)
, m_bLoadEventEmitted(true)
KHTMLSettings* m_settings;
- TransferJob* m_job;
+ HashMap<String, String> m_metaData;
String m_kjsStatusBarText;
String m_kjsDefaultStatusBarText;
+2006-06-19 Alexey Proskuryakov <ap@nypop.com>
+
+ Reviewed by Darin.
+
+ - http://bugzilla.opendarwin.org/show_bug.cgi?id=5499
+ Page reload does not send any cache control headers
+
+ * WebView/WebFrame.m:
+ (-[WebFrame _addExtraFieldsToRequest:mainResource:alwaysFromRequest:]): Set a proper Cache-Control header for
+ reload requests.
+ (-[WebFrame loadRequest:]): Reset loadType to WebFrameLoadTypeStandard (after a reload, it stayed at
+ WebFrameLoadTypeReload, so _addExtraFieldsToRequest erroneously added a Cache-Control header to them).
+
2006-06-19 John Sullivan <sullivan@apple.com>
Reviewed by Darin.
{
[request _web_setHTTPUserAgent:[[self webView] userAgentForURL:[request URL]]];
+ if (_private->loadType == WebFrameLoadTypeReload)
+ [request setValue:@"max-age=0" forHTTPHeaderField:@"Cache-Control"];
+
// Don't set the cookie policy URL if it's already been set.
if ([request mainDocumentURL] == nil) {
if (mainResource && (self == [[self webView] mainFrame] || f))
- (void)loadRequest:(NSURLRequest *)request
{
+ // FIXME: is this the right place to reset loadType? Perhaps, this should be done
+ // after loading is finished or aborted.
+ _private->loadType = WebFrameLoadTypeStandard;
+
[self _loadRequest:request archive:nil];
}