bug 767005 backout bug 235853 r=jduell
This commit is contained in:
@@ -178,8 +178,6 @@ MOCHITEST_FILES_A = \
|
||||
file_bug426646-1.html \
|
||||
file_bug426646-2.html \
|
||||
test_bug429157.html \
|
||||
test_header.html \
|
||||
header.sjs \
|
||||
test_XHR.html \
|
||||
file_XHR_pass1.xml \
|
||||
file_XHR_pass2.txt \
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
function handleRequest(request, response) {
|
||||
response.setHeader("Content-Type", "text/plain", false);
|
||||
response.setHeader("Cache-Control", "no-cache", false);
|
||||
|
||||
var value = request.hasHeader("SomeHeader") ? request.getHeader("SomeHeader")
|
||||
: "";
|
||||
response.write("SomeHeader: " + value);
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for XHR header preservation</title>
|
||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
/** Test for Bug 421622 **/
|
||||
const SJS_URL = "http://mochi.test:8888/tests/content/base/test/header.sjs";
|
||||
const VALUE = "http://www.mozilla.org/";
|
||||
|
||||
var req = new XMLHttpRequest();
|
||||
req.open("GET", SJS_URL, false);
|
||||
req.setRequestHeader("SomeHeader", VALUE);
|
||||
req.send(null);
|
||||
|
||||
is(req.responseText,
|
||||
"SomeHeader: " + VALUE,
|
||||
"Header received by server does not match what was set");
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
@@ -592,18 +592,8 @@ nsIOService::LookupProxyInfo(nsIURI *aURI,
|
||||
NS_WARNING("failed to get protocol proxy service");
|
||||
}
|
||||
if (mProxyService) {
|
||||
PRUint32 flags = 0;
|
||||
if (aScheme->EqualsLiteral("http") || aScheme->EqualsLiteral("https"))
|
||||
flags = nsIProtocolProxyService::RESOLVE_NON_BLOCKING;
|
||||
rv = mProxyService->Resolve(aProxyURI ? aProxyURI : aURI, aProxyFlags,
|
||||
getter_AddRefs(pi));
|
||||
if (rv == NS_BASE_STREAM_WOULD_BLOCK) {
|
||||
// Use an UNKNOWN proxy to defer resolution and avoid blocking.
|
||||
rv = mProxyService->NewProxyInfo(NS_LITERAL_CSTRING("unknown"),
|
||||
NS_LITERAL_CSTRING(""),
|
||||
-1, 0, 0, nsnull,
|
||||
getter_AddRefs(pi));
|
||||
}
|
||||
if (NS_FAILED(rv))
|
||||
pi = nsnull;
|
||||
}
|
||||
|
||||
@@ -910,8 +910,7 @@ nsProtocolProxyService::NewProxyInfo(const nsACString &aType,
|
||||
kProxyType_HTTP,
|
||||
kProxyType_SOCKS,
|
||||
kProxyType_SOCKS4,
|
||||
kProxyType_DIRECT,
|
||||
kProxyType_UNKNOWN
|
||||
kProxyType_DIRECT
|
||||
};
|
||||
|
||||
// resolve type; this allows us to avoid copying the type string into each
|
||||
|
||||
@@ -1522,12 +1522,11 @@ HttpBaseChannel::IsSafeMethod(nsHttpAtom method)
|
||||
nsresult
|
||||
HttpBaseChannel::SetupReplacementChannel(nsIURI *newURI,
|
||||
nsIChannel *newChannel,
|
||||
bool preserveMethod,
|
||||
bool forProxy)
|
||||
bool preserveMethod)
|
||||
{
|
||||
LOG(("HttpBaseChannel::SetupReplacementChannel "
|
||||
"[this=%p newChannel=%p preserveMethod=%d forProxy=%d]",
|
||||
this, newChannel, preserveMethod, forProxy));
|
||||
"[this=%p newChannel=%p preserveMethod=%d]",
|
||||
this, newChannel, preserveMethod));
|
||||
PRUint32 newLoadFlags = mLoadFlags | LOAD_REPLACE;
|
||||
// if the original channel was using SSL and this channel is not using
|
||||
// SSL, then no need to inhibit persistent caching. however, if the
|
||||
@@ -1650,21 +1649,6 @@ HttpBaseChannel::SetupReplacementChannel(nsIURI *newURI,
|
||||
if (timed)
|
||||
timed->SetTimingEnabled(mTimingEnabled);
|
||||
|
||||
if (forProxy) {
|
||||
// Transfer all the headers from the previous channel
|
||||
// this is needed for any headers that are not covered by the code above
|
||||
// or have been set separately. e.g. manually setting Referer without
|
||||
// setting up mReferrer
|
||||
PRUint32 count = mRequestHead.Headers().Count();
|
||||
for (PRUint32 i = 0; i < count; ++i) {
|
||||
nsHttpAtom header;
|
||||
const char *value = mRequestHead.Headers().PeekHeaderAt(i, header);
|
||||
|
||||
httpChannel->SetRequestHeader(nsDependentCString(header),
|
||||
nsDependentCString(value), false);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -197,8 +197,7 @@ protected:
|
||||
void AddCookiesToRequest();
|
||||
virtual nsresult SetupReplacementChannel(nsIURI *,
|
||||
nsIChannel *,
|
||||
bool preserveMethod,
|
||||
bool forProxy);
|
||||
bool preserveMethod);
|
||||
|
||||
// Helper function to simplify getting notification callbacks.
|
||||
template <class T>
|
||||
|
||||
@@ -722,7 +722,7 @@ HttpChannelChild::Redirect1Begin(const PRUint32& newChannelId,
|
||||
bool rewriteToGET = ShouldRewriteRedirectToGET(mResponseHead->Status(),
|
||||
mRequestHead.Method());
|
||||
|
||||
rv = SetupReplacementChannel(uri, newChannel, !rewriteToGET, false);
|
||||
rv = SetupReplacementChannel(uri, newChannel, !rewriteToGET);
|
||||
if (NS_FAILED(rv)) {
|
||||
// Veto redirect. nsHttpChannel decides to cancel or continue.
|
||||
OnRedirectVerifyCallback(rv);
|
||||
|
||||
@@ -1635,7 +1635,7 @@ nsHttpChannel::AsyncRedirectChannelToHttps()
|
||||
rv = ioService->NewChannelFromURI(upgradedURI, getter_AddRefs(newChannel));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = SetupReplacementChannel(upgradedURI, newChannel, true, false);
|
||||
rv = SetupReplacementChannel(upgradedURI, newChannel, true);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Inform consumers about this fake redirect
|
||||
@@ -1732,7 +1732,7 @@ nsHttpChannel::AsyncDoReplaceWithProxy(nsIProxyInfo* pi)
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = SetupReplacementChannel(mURI, newChannel, true, true);
|
||||
rv = SetupReplacementChannel(mURI, newChannel, true);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
@@ -2280,7 +2280,7 @@ nsHttpChannel::ProcessFallback(bool *waitingForRedirectCallback)
|
||||
rv = gHttpHandler->NewChannel(mURI, getter_AddRefs(newChannel));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = SetupReplacementChannel(mURI, newChannel, true, false);
|
||||
rv = SetupReplacementChannel(mURI, newChannel, true);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Make sure the new channel loads from the fallback key.
|
||||
@@ -3953,15 +3953,13 @@ nsHttpChannel::ClearBogusContentEncodingIfNeeded()
|
||||
nsresult
|
||||
nsHttpChannel::SetupReplacementChannel(nsIURI *newURI,
|
||||
nsIChannel *newChannel,
|
||||
bool preserveMethod,
|
||||
bool forProxy)
|
||||
bool preserveMethod)
|
||||
{
|
||||
LOG(("nsHttpChannel::SetupReplacementChannel "
|
||||
"[this=%p newChannel=%p preserveMethod=%d]",
|
||||
this, newChannel, preserveMethod));
|
||||
|
||||
nsresult rv = HttpBaseChannel::SetupReplacementChannel(newURI, newChannel,
|
||||
preserveMethod, forProxy);
|
||||
nsresult rv = HttpBaseChannel::SetupReplacementChannel(newURI, newChannel, preserveMethod);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
@@ -3984,28 +3982,6 @@ nsHttpChannel::SetupReplacementChannel(nsIURI *newURI,
|
||||
resumableChannel->ResumeAt(mStartPos, mEntityID);
|
||||
}
|
||||
|
||||
if (forProxy) {
|
||||
// Transfer the cache info to the new channel, if needed.
|
||||
nsCOMPtr<nsICachingChannel> cachingChannel = do_QueryInterface(newChannel);
|
||||
if (cachingChannel) {
|
||||
// cacheKey is just mPostID wrapped in an nsISupportsPRUint32,
|
||||
// we don't need to transfer it if it's 0.
|
||||
if (mPostID) {
|
||||
nsCOMPtr<nsISupports> cacheKey;
|
||||
GetCacheKey(getter_AddRefs(cacheKey));
|
||||
if (cacheKey) {
|
||||
cachingChannel->SetCacheKey(cacheKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIApplicationCacheChannel> appCacheChannel = do_QueryInterface(newChannel);
|
||||
if (appCacheChannel) {
|
||||
// app cache for write
|
||||
appCacheChannel->SetApplicationCacheForWrite(mApplicationCacheForWrite);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -4129,7 +4105,7 @@ nsHttpChannel::ContinueProcessRedirectionAfterFallback(nsresult rv)
|
||||
rv = ioService->NewChannelFromURI(mRedirectURI, getter_AddRefs(newChannel));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = SetupReplacementChannel(mRedirectURI, newChannel, !rewriteToGET, false);
|
||||
rv = SetupReplacementChannel(mRedirectURI, newChannel, !rewriteToGET);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRUint32 redirectFlags;
|
||||
|
||||
@@ -180,9 +180,7 @@ private:
|
||||
void HandleAsyncFallback();
|
||||
nsresult ContinueHandleAsyncFallback(nsresult);
|
||||
nsresult PromptTempRedirect();
|
||||
virtual nsresult SetupReplacementChannel(nsIURI *, nsIChannel *,
|
||||
bool preserveMethod,
|
||||
bool forProxy);
|
||||
virtual nsresult SetupReplacementChannel(nsIURI *, nsIChannel *, bool preserveMethod);
|
||||
|
||||
// proxy specific methods
|
||||
nsresult ProxyFailover();
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
do_load_httpd_js();
|
||||
|
||||
var ios = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
|
||||
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
|
||||
function make_channel(url) {
|
||||
return ios.newChannel(url, null, null)
|
||||
.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
}
|
||||
|
||||
var httpserv = null;
|
||||
|
||||
// respond with the value of the header
|
||||
function responseHandler(request, response) {
|
||||
response.setHeader("Content-Type", "text/plain", false);
|
||||
|
||||
var value = request.hasHeader("SomeHeader") ? request.getHeader("SomeHeader") : "";
|
||||
response.write("SomeHeader: " + value);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
httpserv = new nsHttpServer();
|
||||
httpserv.start(4444);
|
||||
httpserv.registerPathHandler("/test", responseHandler);
|
||||
// setup an identity so we can use the server with a different name when using
|
||||
// the server as a proxy
|
||||
httpserv.identity.add("http", "foo", 80);
|
||||
|
||||
// cache key on channel creation
|
||||
var orig_key;
|
||||
|
||||
// setup the properties that we want to be preserved
|
||||
function setup_channel(chan) {
|
||||
chan.setRequestHeader("SomeHeader", "Someval", false);
|
||||
|
||||
// set cache key to something other than 0
|
||||
orig_key = chan.QueryInterface(Ci.nsICachingChannel)
|
||||
.cacheKey.QueryInterface(Ci.nsISupportsPRUint32);
|
||||
orig_key.data = 0x32;
|
||||
chan.QueryInterface(Ci.nsICachingChannel).cacheKey = orig_key;
|
||||
}
|
||||
|
||||
// check that these properties are preserved
|
||||
function check_response(request, data) {
|
||||
// check that headers are preserved
|
||||
do_check_eq(data, "SomeHeader: Someval");
|
||||
|
||||
// check that the cacheKey is preserved
|
||||
var key = request.QueryInterface(Ci.nsICachingChannel)
|
||||
.cacheKey.QueryInterface(Ci.nsISupportsPRUint32);
|
||||
do_check_eq(key.data, orig_key.data);
|
||||
}
|
||||
|
||||
function setup_noproxy() {
|
||||
var chan = make_channel("http://localhost:4444/test");
|
||||
setup_channel(chan);
|
||||
chan.asyncOpen(new ChannelListener(test_noproxy, null), null);
|
||||
}
|
||||
|
||||
function test_noproxy(request, data, ctx) {
|
||||
check_response(request, data);
|
||||
|
||||
setup_with_proxy();
|
||||
}
|
||||
|
||||
function setup_with_proxy() {
|
||||
// Setup a PAC rule using the server we setup as the proxy
|
||||
var pac = 'data:text/plain,' +
|
||||
'function FindProxyForURL(url, host) {' +
|
||||
' return "PROXY localhost:4444";' +
|
||||
'}';
|
||||
|
||||
// Configure PAC
|
||||
prefs.setIntPref("network.proxy.type", 2);
|
||||
prefs.setCharPref("network.proxy.autoconfig_url", pac);
|
||||
|
||||
var chan = make_channel("http://foo/test");
|
||||
|
||||
setup_channel(chan);
|
||||
|
||||
chan.asyncOpen(new ChannelListener(test_with_proxy, null), null);
|
||||
}
|
||||
|
||||
function test_with_proxy(request, data, ctx) {
|
||||
check_response(request, data);
|
||||
|
||||
// cleanup PAC
|
||||
prefs.setCharPref("network.proxy.autoconfig_url", "");
|
||||
prefs.setIntPref("network.proxy.type", 0);
|
||||
|
||||
httpserv.stop(do_test_finished);
|
||||
}
|
||||
|
||||
setup_noproxy();
|
||||
|
||||
do_test_pending();
|
||||
}
|
||||
@@ -158,7 +158,6 @@ skip-if = os == "win"
|
||||
[test_protocolproxyservice.js]
|
||||
[test_proxy-failover_canceled.js]
|
||||
[test_proxy-failover_passing.js]
|
||||
[test_proxy_preservation_bug235853.js]
|
||||
[test_proxy-replace_canceled.js]
|
||||
[test_proxy-replace_passing.js]
|
||||
[test_range_requests.js]
|
||||
|
||||
Reference in New Issue
Block a user