mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-13 03:24:26 +00:00
Backed out changeset f014c59ad81d
This commit is contained in:
parent
e6551e382c
commit
7b41cb93e4
@ -200,8 +200,6 @@ _TEST_FILES = test_bug5141.html \
|
||||
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://localhost: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>
|
@ -6,7 +6,7 @@
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body onload="setupTest('http://example.org/tests/extensions/cookie/test/file_loadflags_inner.html', 'example.org', 5, 1, 4)">
|
||||
<body onload="setupTest('http://example.org/tests/extensions/cookie/test/file_loadflags_inner.html', 'example.org', 5, 1, 2)">
|
||||
<p id="display"></p>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript" src="file_testloadflags.js">
|
||||
|
@ -551,17 +551,7 @@ nsIOService::NewChannelFromURI(nsIURI *aURI, nsIChannel **result)
|
||||
NS_WARNING("failed to get protocol proxy service");
|
||||
}
|
||||
if (mProxyService) {
|
||||
PRUint32 flags = 0;
|
||||
if (scheme.EqualsLiteral("http") || scheme.EqualsLiteral("https"))
|
||||
flags = nsIProtocolProxyService::RESOLVE_NON_BLOCKING;
|
||||
rv = mProxyService->Resolve(aURI, flags, 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));
|
||||
}
|
||||
rv = mProxyService->Resolve(aURI, 0, getter_AddRefs(pi));
|
||||
if (NS_FAILED(rv))
|
||||
pi = nsnull;
|
||||
}
|
||||
|
@ -924,8 +924,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
|
||||
|
@ -1122,7 +1122,7 @@ nsHttpChannel::DoReplaceWithProxy(nsIProxyInfo* pi)
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = SetupReplacementChannel(mURI, newChannel, PR_TRUE, PR_TRUE);
|
||||
rv = SetupReplacementChannel(mURI, newChannel, PR_TRUE);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
@ -1441,7 +1441,7 @@ nsHttpChannel::ProcessFallback(PRBool *fallingBack)
|
||||
rv = gHttpHandler->NewChannel(mURI, getter_AddRefs(newChannel));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = SetupReplacementChannel(mURI, newChannel, PR_TRUE, PR_FALSE);
|
||||
rv = SetupReplacementChannel(mURI, newChannel, PR_TRUE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Make sure the new channel loads from the fallback key.
|
||||
@ -2560,8 +2560,7 @@ CopyProperties(const nsAString& aKey, nsIVariant *aData, void *aClosure)
|
||||
nsresult
|
||||
nsHttpChannel::SetupReplacementChannel(nsIURI *newURI,
|
||||
nsIChannel *newChannel,
|
||||
PRBool preserveMethod,
|
||||
PRBool forProxy)
|
||||
PRBool preserveMethod)
|
||||
{
|
||||
PRUint32 newLoadFlags = mLoadFlags | LOAD_REPLACE;
|
||||
// if the original channel was using SSL and this channel is not using
|
||||
@ -2612,7 +2611,6 @@ nsHttpChannel::SetupReplacementChannel(nsIURI *newURI,
|
||||
// convey the referrer if one was used for this channel to the next one
|
||||
if (mReferrer)
|
||||
httpChannel->SetReferrer(mReferrer);
|
||||
|
||||
// convey the mAllowPipelining flag
|
||||
httpChannel->SetAllowPipelining(mAllowPipelining);
|
||||
// convey the new redirection limit
|
||||
@ -2659,39 +2657,6 @@ nsHttpChannel::SetupReplacementChannel(nsIURI *newURI,
|
||||
if (bag)
|
||||
mPropertyHash.EnumerateRead(CopyProperties, bag.get());
|
||||
|
||||
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), PR_FALSE);
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
// cacheClientID, cacheForOfflineUse
|
||||
cachingChannel->SetOfflineCacheClientID(mOfflineCacheClientID);
|
||||
cachingChannel->SetCacheForOfflineUse(mCacheForOfflineUse);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -2777,7 +2742,7 @@ nsHttpChannel::ProcessRedirection(PRUint32 redirectType)
|
||||
rv = ioService->NewChannelFromURI(newURI, getter_AddRefs(newChannel));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = SetupReplacementChannel(newURI, newChannel, preserveMethod, PR_FALSE);
|
||||
rv = SetupReplacementChannel(newURI, newChannel, preserveMethod);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRUint32 redirectFlags;
|
||||
|
@ -178,9 +178,7 @@ private:
|
||||
void HandleAsyncNotModified();
|
||||
void HandleAsyncFallback();
|
||||
nsresult PromptTempRedirect();
|
||||
nsresult SetupReplacementChannel(nsIURI *, nsIChannel *,
|
||||
PRBool preserveMethod,
|
||||
PRBool forProxy);
|
||||
nsresult SetupReplacementChannel(nsIURI *, nsIChannel *, PRBool preserveMethod);
|
||||
|
||||
// proxy specific methods
|
||||
nsresult ProxyFailover();
|
||||
|
@ -1,139 +0,0 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Google Inc.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Jeff Muizelaar <jmuizelaar@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
do_import_script("netwerk/test/httpserver/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();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user