mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 664163 - Fix Get(Local|Remote)(Address|Port) in HttpChannelChild. r=jduell
This commit is contained in:
parent
d2cef8692f
commit
c2d5cae269
@ -457,6 +457,8 @@ HttpChannelChild::OnStartRequest(const nsresult& channelStatus,
|
||||
mCacheEntryAvailable = cacheEntryAvailable;
|
||||
mCacheExpirationTime = cacheExpirationTime;
|
||||
mCachedCharset = cachedCharset;
|
||||
mSelfAddr = selfAddr;
|
||||
mPeerAddr = peerAddr;
|
||||
|
||||
AutoEventEnqueuer ensureSerialDispatch(mEventQ);
|
||||
|
||||
@ -486,9 +488,6 @@ HttpChannelChild::OnStartRequest(const nsresult& channelStatus,
|
||||
mTracingEnabled = false;
|
||||
|
||||
DoOnStartRequest(this, mListenerContext);
|
||||
|
||||
mSelfAddr = selfAddr;
|
||||
mPeerAddr = peerAddr;
|
||||
}
|
||||
|
||||
void
|
||||
@ -1991,36 +1990,6 @@ HttpChannelChild::SetupFallbackChannel(const char *aFallbackKey)
|
||||
DROP_DEAD();
|
||||
}
|
||||
|
||||
// The next four _should_ be implemented, but we need to figure out how
|
||||
// to transfer the data from the chrome process first.
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpChannelChild::GetRemoteAddress(nsACString & _result)
|
||||
{
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpChannelChild::GetRemotePort(int32_t * _result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_result);
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpChannelChild::GetLocalAddress(nsACString & _result)
|
||||
{
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpChannelChild::GetLocalPort(int32_t * _result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_result);
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// HttpChannelChild::nsICacheInfoChannel
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -86,10 +86,6 @@ public:
|
||||
NS_IMETHOD GetProtocolVersion(nsACString& aProtocolVersion) override;
|
||||
// nsIHttpChannelInternal
|
||||
NS_IMETHOD SetupFallbackChannel(const char *aFallbackKey) override;
|
||||
NS_IMETHOD GetLocalAddress(nsACString& addr) override;
|
||||
NS_IMETHOD GetLocalPort(int32_t* port) override;
|
||||
NS_IMETHOD GetRemoteAddress(nsACString& addr) override;
|
||||
NS_IMETHOD GetRemotePort(int32_t* port) override;
|
||||
NS_IMETHOD ForceIntercepted(uint64_t aInterceptionID) override;
|
||||
// nsISupportsPriority
|
||||
NS_IMETHOD SetPriority(int32_t value) override;
|
||||
|
75
netwerk/test/unit/test_getHost.js
Normal file
75
netwerk/test/unit/test_getHost.js
Normal file
@ -0,0 +1,75 @@
|
||||
// Test getLocalHost/getLocalPort and getRemoteHost/getRemotePort.
|
||||
|
||||
Cu.import("resource://testing-common/httpd.js");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var httpserver = new HttpServer();
|
||||
httpserver.start(-1);
|
||||
const PORT = httpserver.identity.primaryPort;
|
||||
|
||||
var gotOnStartRequest = false;
|
||||
|
||||
function CheckGetHostListener() {}
|
||||
|
||||
CheckGetHostListener.prototype = {
|
||||
onStartRequest: function(request, context) {
|
||||
dump("*** listener onStartRequest\n");
|
||||
|
||||
gotOnStartRequest = true;
|
||||
|
||||
request.QueryInterface(Components.interfaces.nsIHttpChannelInternal);
|
||||
try {
|
||||
do_check_eq(request.localAddress, "127.0.0.1");
|
||||
do_check_eq(request.localPort > 0, true);
|
||||
do_check_neq(request.localPort, PORT);
|
||||
do_check_eq(request.remoteAddress, "127.0.0.1");
|
||||
do_check_eq(request.remotePort, PORT);
|
||||
} catch (e) {
|
||||
do_check_true(0, "Get local/remote host/port throws an error!");
|
||||
}
|
||||
},
|
||||
|
||||
onStopRequest: function(request, context, statusCode) {
|
||||
dump("*** listener onStopRequest\n");
|
||||
|
||||
do_check_eq(gotOnStartRequest, true);
|
||||
httpserver.stop(do_test_finished);
|
||||
},
|
||||
|
||||
QueryInterface: function(iid) {
|
||||
if (iid.equals(Components.interfaces.nsIRequestObserver) ||
|
||||
iid.equals(Components.interfaces.nsISupports)
|
||||
)
|
||||
return this;
|
||||
throw Components.results.NS_NOINTERFACE;
|
||||
},
|
||||
}
|
||||
|
||||
function make_channel(url) {
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
return ios.newChannel2(url,
|
||||
null,
|
||||
null,
|
||||
null, // aLoadingNode
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null, // aTriggeringPrincipal
|
||||
Ci.nsILoadInfo.SEC_NORMAL,
|
||||
Ci.nsIContentPolicy.TYPE_OTHER)
|
||||
.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
}
|
||||
|
||||
function test_handler(metadata, response) {
|
||||
response.setHeader("Content-Type", "text/html", false);
|
||||
response.setStatusLine(metadata.httpVersion, 200, "OK");
|
||||
var responseBody = "blah blah";
|
||||
response.bodyOutputStream.write(responseBody, responseBody.length);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
httpserver.registerPathHandler("/testdir", test_handler);
|
||||
|
||||
var channel = make_channel("http://localhost:" + PORT + "/testdir");
|
||||
channel.asyncOpen(new CheckGetHostListener(), null);
|
||||
do_test_pending();
|
||||
}
|
@ -27,13 +27,11 @@ TracingListener.prototype = {
|
||||
request.QueryInterface(Components.interfaces.nsIHttpChannelInternal);
|
||||
|
||||
// local/remote addresses broken in e10s: disable for now
|
||||
/*
|
||||
do_check_eq(request.localAddress, "127.0.0.1");
|
||||
do_check_eq(request.localPort > 0, true);
|
||||
do_check_neq(request.localPort, PORT);
|
||||
do_check_eq(request.remoteAddress, "127.0.0.1");
|
||||
do_check_eq(request.remotePort, PORT);
|
||||
*/
|
||||
|
||||
// Make sure listener can't be replaced after OnStartRequest was called.
|
||||
request.QueryInterface(Components.interfaces.nsITraceableChannel);
|
||||
|
@ -342,6 +342,7 @@ firefox-appdir = browser
|
||||
[test_packaged_app_service_paths.js]
|
||||
[test_bug1195415.js]
|
||||
[test_cookie_blacklist.js]
|
||||
[test_getHost.js]
|
||||
[test_packaged_app_bug1214079.js]
|
||||
[test_bug412457.js]
|
||||
|
||||
|
3
netwerk/test/unit_ipc/test_getHost_wrap.js
Normal file
3
netwerk/test/unit_ipc/test_getHost_wrap.js
Normal file
@ -0,0 +1,3 @@
|
||||
function run_test() {
|
||||
run_test_in_child("../unit/test_getHost.js");
|
||||
}
|
@ -41,3 +41,4 @@ skip-if = true
|
||||
[test_redirect_history_wrap.js]
|
||||
[test_reply_without_content_type_wrap.js]
|
||||
[test_app_offline_http.js]
|
||||
[test_getHost_wrap.js]
|
||||
|
Loading…
Reference in New Issue
Block a user