2009-08-18 12:05:15 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set sw=2 ts=8 et tw=80 : */
|
|
|
|
|
|
|
|
/* ***** 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
|
|
|
|
* The Mozilla Foundation
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2009
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Jason Duell <jduell.mcbugs@gmail.com>
|
2010-04-07 01:43:09 -07:00
|
|
|
* Daniel Witte <dwitte@mozilla.com>
|
2010-08-10 20:11:57 -07:00
|
|
|
* Honza Bambas <honzab@firemni.cz>
|
2009-08-18 12:05:15 -07:00
|
|
|
*
|
|
|
|
* 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 ***** */
|
|
|
|
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
#include "nsHttp.h"
|
2010-06-18 03:49:28 -07:00
|
|
|
#include "mozilla/dom/TabChild.h"
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
#include "mozilla/net/NeckoChild.h"
|
2009-08-18 12:05:15 -07:00
|
|
|
#include "mozilla/net/HttpChannelChild.h"
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
|
|
|
|
#include "nsStringStream.h"
|
|
|
|
#include "nsHttpHandler.h"
|
|
|
|
#include "nsMimeTypes.h"
|
|
|
|
#include "nsNetUtil.h"
|
2010-08-13 01:06:40 -07:00
|
|
|
#include "nsSerializationHelper.h"
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
|
2010-08-05 21:59:37 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace net {
|
|
|
|
|
2010-08-10 20:11:57 -07:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2009-08-18 12:05:15 -07:00
|
|
|
HttpChannelChild::HttpChannelChild()
|
2010-10-15 22:26:14 -07:00
|
|
|
: ChannelEventQueue<HttpChannelChild>(this)
|
|
|
|
, mIsFromCache(PR_FALSE)
|
2010-06-23 23:55:19 -07:00
|
|
|
, mCacheEntryAvailable(PR_FALSE)
|
|
|
|
, mCacheExpirationTime(nsICache::NO_EXPIRATION_TIME)
|
2010-08-10 20:07:09 -07:00
|
|
|
, mSendResumeAt(false)
|
|
|
|
, mSuspendCount(0)
|
2010-06-27 09:44:15 -07:00
|
|
|
, mIPCOpen(false)
|
2011-01-24 14:58:20 -08:00
|
|
|
, mKeptAlive(false)
|
2009-08-18 12:05:15 -07:00
|
|
|
{
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
LOG(("Creating HttpChannelChild @%x\n", this));
|
2009-08-18 12:05:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
HttpChannelChild::~HttpChannelChild()
|
|
|
|
{
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
LOG(("Destroying HttpChannelChild @%x\n", this));
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::nsISupports
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2010-04-23 07:19:33 -07:00
|
|
|
// Override nsHashPropertyBag's AddRef: we don't need thread-safe refcnt
|
|
|
|
NS_IMPL_ADDREF(HttpChannelChild)
|
2010-08-13 01:06:40 -07:00
|
|
|
|
|
|
|
NS_IMETHODIMP_(nsrefcnt) HttpChannelChild::Release()
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(0 != mRefCnt, "dup release");
|
|
|
|
NS_ASSERT_OWNINGTHREAD(HttpChannelChild);
|
|
|
|
--mRefCnt;
|
|
|
|
NS_LOG_RELEASE(this, mRefCnt, "HttpChannelChild");
|
|
|
|
|
2011-01-24 14:58:20 -08:00
|
|
|
if (mRefCnt == 1 && mKeptAlive && mIPCOpen) {
|
|
|
|
mKeptAlive = false;
|
2010-08-13 01:06:40 -07:00
|
|
|
// Send_delete calls NeckoChild::DeallocPHttpChannel, which will release
|
|
|
|
// again to refcount==0
|
|
|
|
PHttpChannelChild::Send__delete__(this);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mRefCnt == 0) {
|
|
|
|
mRefCnt = 1; /* stabilize */
|
|
|
|
delete this;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return mRefCnt;
|
|
|
|
}
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN(HttpChannelChild)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIRequest)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIChannel)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIHttpChannel)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIHttpChannelInternal)
|
2010-06-23 23:55:19 -07:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsICacheInfoChannel)
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIResumableChannel)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupportsPriority)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIProxiedChannel)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsITraceableChannel)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIApplicationCacheContainer)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIApplicationCacheChannel)
|
2010-08-10 20:11:57 -07:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIAsyncVerifyRedirectCallback)
|
2010-11-23 14:56:06 -08:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIChildChannel)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIHttpChannelChild)
|
2010-08-13 01:06:40 -07:00
|
|
|
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIAssociatedContentSecurity, GetAssociatedContentSecurity())
|
2010-04-07 01:43:09 -07:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(HttpBaseChannel)
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::PHttpChannelChild
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2010-06-27 09:44:15 -07:00
|
|
|
void
|
|
|
|
HttpChannelChild::AddIPDLReference()
|
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(!mIPCOpen, "Attempt to retain more than one IPDL reference");
|
|
|
|
mIPCOpen = true;
|
|
|
|
AddRef();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
HttpChannelChild::ReleaseIPDLReference()
|
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(mIPCOpen, "Attempt to release nonexistent IPDL reference");
|
|
|
|
mIPCOpen = false;
|
|
|
|
Release();
|
|
|
|
}
|
|
|
|
|
2010-09-20 11:37:13 -07:00
|
|
|
class StartRequestEvent : public ChannelEvent
|
2010-08-05 21:59:37 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
StartRequestEvent(HttpChannelChild* child,
|
|
|
|
const nsHttpResponseHead& responseHead,
|
|
|
|
const PRBool& useResponseHead,
|
2010-10-01 21:17:23 -07:00
|
|
|
const RequestHeaderTuples& requestHeaders,
|
2010-08-05 21:59:37 -07:00
|
|
|
const PRBool& isFromCache,
|
|
|
|
const PRBool& cacheEntryAvailable,
|
|
|
|
const PRUint32& cacheExpirationTime,
|
2010-08-13 01:06:40 -07:00
|
|
|
const nsCString& cachedCharset,
|
|
|
|
const nsCString& securityInfoSerialization)
|
2010-08-05 21:59:37 -07:00
|
|
|
: mChild(child)
|
|
|
|
, mResponseHead(responseHead)
|
2010-10-01 21:17:23 -07:00
|
|
|
, mRequestHeaders(requestHeaders)
|
2010-08-05 21:59:37 -07:00
|
|
|
, mUseResponseHead(useResponseHead)
|
|
|
|
, mIsFromCache(isFromCache)
|
|
|
|
, mCacheEntryAvailable(cacheEntryAvailable)
|
|
|
|
, mCacheExpirationTime(cacheExpirationTime)
|
|
|
|
, mCachedCharset(cachedCharset)
|
2010-08-13 01:06:40 -07:00
|
|
|
, mSecurityInfoSerialization(securityInfoSerialization)
|
2010-08-05 21:59:37 -07:00
|
|
|
{}
|
|
|
|
|
|
|
|
void Run()
|
|
|
|
{
|
2010-10-01 21:17:23 -07:00
|
|
|
mChild->OnStartRequest(mResponseHead, mUseResponseHead, mRequestHeaders,
|
|
|
|
mIsFromCache, mCacheEntryAvailable,
|
|
|
|
mCacheExpirationTime, mCachedCharset,
|
|
|
|
mSecurityInfoSerialization);
|
2010-08-05 21:59:37 -07:00
|
|
|
}
|
|
|
|
private:
|
|
|
|
HttpChannelChild* mChild;
|
|
|
|
nsHttpResponseHead mResponseHead;
|
2010-10-01 21:17:23 -07:00
|
|
|
RequestHeaderTuples mRequestHeaders;
|
|
|
|
PRPackedBool mUseResponseHead;
|
|
|
|
PRPackedBool mIsFromCache;
|
|
|
|
PRPackedBool mCacheEntryAvailable;
|
2010-08-05 21:59:37 -07:00
|
|
|
PRUint32 mCacheExpirationTime;
|
|
|
|
nsCString mCachedCharset;
|
2010-08-13 01:06:40 -07:00
|
|
|
nsCString mSecurityInfoSerialization;
|
2010-08-05 21:59:37 -07:00
|
|
|
};
|
|
|
|
|
2010-10-20 10:12:32 -07:00
|
|
|
bool
|
|
|
|
HttpChannelChild::RecvAssociateApplicationCache(const nsCString &groupID,
|
|
|
|
const nsCString &clientID)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
mApplicationCache = do_CreateInstance(
|
|
|
|
NS_APPLICATIONCACHE_CONTRACTID, &rv);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
mLoadedFromApplicationCache = PR_TRUE;
|
|
|
|
mApplicationCache->InitAsHandle(groupID, clientID);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
bool
|
2010-06-18 03:32:00 -07:00
|
|
|
HttpChannelChild::RecvOnStartRequest(const nsHttpResponseHead& responseHead,
|
2010-06-23 23:55:19 -07:00
|
|
|
const PRBool& useResponseHead,
|
2010-10-01 21:17:23 -07:00
|
|
|
const RequestHeaderTuples& requestHeaders,
|
2010-06-23 23:55:19 -07:00
|
|
|
const PRBool& isFromCache,
|
|
|
|
const PRBool& cacheEntryAvailable,
|
|
|
|
const PRUint32& cacheExpirationTime,
|
2010-08-13 01:06:40 -07:00
|
|
|
const nsCString& cachedCharset,
|
|
|
|
const nsCString& securityInfoSerialization)
|
2010-08-05 21:59:37 -07:00
|
|
|
{
|
|
|
|
if (ShouldEnqueue()) {
|
|
|
|
EnqueueEvent(new StartRequestEvent(this, responseHead, useResponseHead,
|
2010-10-01 21:17:23 -07:00
|
|
|
requestHeaders,
|
2010-08-05 21:59:37 -07:00
|
|
|
isFromCache, cacheEntryAvailable,
|
2010-08-13 01:06:40 -07:00
|
|
|
cacheExpirationTime, cachedCharset,
|
|
|
|
securityInfoSerialization));
|
2010-08-05 21:59:37 -07:00
|
|
|
} else {
|
2010-10-01 21:17:23 -07:00
|
|
|
OnStartRequest(responseHead, useResponseHead, requestHeaders, isFromCache,
|
2010-08-13 01:06:40 -07:00
|
|
|
cacheEntryAvailable, cacheExpirationTime, cachedCharset,
|
|
|
|
securityInfoSerialization);
|
2010-08-05 21:59:37 -07:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
HttpChannelChild::OnStartRequest(const nsHttpResponseHead& responseHead,
|
|
|
|
const PRBool& useResponseHead,
|
2010-10-01 21:17:23 -07:00
|
|
|
const RequestHeaderTuples& requestHeaders,
|
2010-08-05 21:59:37 -07:00
|
|
|
const PRBool& isFromCache,
|
|
|
|
const PRBool& cacheEntryAvailable,
|
|
|
|
const PRUint32& cacheExpirationTime,
|
2010-08-13 01:06:40 -07:00
|
|
|
const nsCString& cachedCharset,
|
|
|
|
const nsCString& securityInfoSerialization)
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
{
|
|
|
|
LOG(("HttpChannelChild::RecvOnStartRequest [this=%x]\n", this));
|
|
|
|
|
2010-08-12 02:05:16 -07:00
|
|
|
if (useResponseHead && !mCanceled)
|
2010-06-18 03:32:00 -07:00
|
|
|
mResponseHead = new nsHttpResponseHead(responseHead);
|
2010-08-13 01:06:40 -07:00
|
|
|
|
|
|
|
if (!securityInfoSerialization.IsEmpty()) {
|
|
|
|
NS_DeserializeObject(securityInfoSerialization,
|
|
|
|
getter_AddRefs(mSecurityInfo));
|
|
|
|
}
|
2010-06-18 03:32:00 -07:00
|
|
|
|
2010-06-23 23:55:19 -07:00
|
|
|
mIsFromCache = isFromCache;
|
|
|
|
mCacheEntryAvailable = cacheEntryAvailable;
|
|
|
|
mCacheExpirationTime = cacheExpirationTime;
|
|
|
|
mCachedCharset = cachedCharset;
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
|
2010-08-05 21:59:37 -07:00
|
|
|
AutoEventEnqueuer ensureSerialDispatch(this);
|
|
|
|
|
2010-10-01 21:17:23 -07:00
|
|
|
// replace our request headers with what actually got sent in the parent
|
|
|
|
mRequestHead.ClearHeaders();
|
|
|
|
for (PRUint32 i = 0; i < requestHeaders.Length(); i++) {
|
|
|
|
mRequestHead.Headers().SetHeader(nsHttp::ResolveAtom(requestHeaders[i].mHeader),
|
|
|
|
requestHeaders[i].mValue);
|
|
|
|
}
|
|
|
|
|
2010-04-07 01:43:09 -07:00
|
|
|
nsresult rv = mListener->OnStartRequest(this, mListenerContext);
|
2010-09-15 15:55:08 -07:00
|
|
|
if (NS_FAILED(rv)) {
|
2010-08-12 02:05:16 -07:00
|
|
|
Cancel(rv);
|
2010-09-15 15:55:08 -07:00
|
|
|
return;
|
2010-04-20 20:16:50 -07:00
|
|
|
}
|
2010-09-15 15:55:08 -07:00
|
|
|
|
|
|
|
if (mResponseHead)
|
|
|
|
SetCookie(mResponseHead->PeekHeader(nsHttp::Set_Cookie));
|
|
|
|
|
|
|
|
rv = ApplyContentConversions();
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
Cancel(rv);
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
}
|
|
|
|
|
2010-09-20 11:37:13 -07:00
|
|
|
class DataAvailableEvent : public ChannelEvent
|
2010-04-20 20:16:50 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
DataAvailableEvent(HttpChannelChild* child,
|
|
|
|
const nsCString& data,
|
|
|
|
const PRUint32& offset,
|
|
|
|
const PRUint32& count)
|
|
|
|
: mChild(child)
|
|
|
|
, mData(data)
|
|
|
|
, mOffset(offset)
|
|
|
|
, mCount(count) {}
|
|
|
|
|
2010-08-05 21:59:37 -07:00
|
|
|
void Run() { mChild->OnDataAvailable(mData, mOffset, mCount); }
|
2010-04-20 20:16:50 -07:00
|
|
|
private:
|
|
|
|
HttpChannelChild* mChild;
|
|
|
|
nsCString mData;
|
|
|
|
PRUint32 mOffset;
|
|
|
|
PRUint32 mCount;
|
|
|
|
};
|
|
|
|
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
bool
|
|
|
|
HttpChannelChild::RecvOnDataAvailable(const nsCString& data,
|
|
|
|
const PRUint32& offset,
|
|
|
|
const PRUint32& count)
|
2010-04-20 20:16:50 -07:00
|
|
|
{
|
2010-08-05 21:59:37 -07:00
|
|
|
if (ShouldEnqueue()) {
|
|
|
|
EnqueueEvent(new DataAvailableEvent(this, data, offset, count));
|
|
|
|
} else {
|
|
|
|
OnDataAvailable(data, offset, count);
|
|
|
|
}
|
|
|
|
return true;
|
2010-04-20 20:16:50 -07:00
|
|
|
}
|
|
|
|
|
2010-08-05 21:59:37 -07:00
|
|
|
void
|
2010-04-20 20:16:50 -07:00
|
|
|
HttpChannelChild::OnDataAvailable(const nsCString& data,
|
|
|
|
const PRUint32& offset,
|
|
|
|
const PRUint32& count)
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
{
|
2010-08-12 02:05:16 -07:00
|
|
|
LOG(("HttpChannelChild::OnDataAvailable [this=%x]\n", this));
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
|
2010-08-12 02:05:16 -07:00
|
|
|
if (mCanceled)
|
|
|
|
return;
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
|
|
|
|
// NOTE: the OnDataAvailable contract requires the client to read all the data
|
|
|
|
// in the inputstream. This code relies on that ('data' will go away after
|
|
|
|
// this function). Apparently the previous, non-e10s behavior was to actually
|
|
|
|
// support only reading part of the data, allowing later calls to read the
|
|
|
|
// rest.
|
|
|
|
nsCOMPtr<nsIInputStream> stringStream;
|
|
|
|
nsresult rv = NS_NewByteInputStream(getter_AddRefs(stringStream),
|
|
|
|
data.get(),
|
|
|
|
count,
|
|
|
|
NS_ASSIGNMENT_DEPEND);
|
2010-06-15 16:07:10 -07:00
|
|
|
if (NS_FAILED(rv)) {
|
2010-08-12 02:05:16 -07:00
|
|
|
Cancel(rv);
|
2010-08-05 21:59:37 -07:00
|
|
|
return;
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
}
|
2010-08-05 21:59:37 -07:00
|
|
|
|
|
|
|
AutoEventEnqueuer ensureSerialDispatch(this);
|
|
|
|
|
2010-04-07 01:43:09 -07:00
|
|
|
rv = mListener->OnDataAvailable(this, mListenerContext,
|
|
|
|
stringStream, offset, count);
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
stringStream->Close();
|
2010-06-15 16:07:10 -07:00
|
|
|
if (NS_FAILED(rv)) {
|
2010-08-12 02:05:16 -07:00
|
|
|
Cancel(rv);
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-20 11:37:13 -07:00
|
|
|
class StopRequestEvent : public ChannelEvent
|
2010-04-20 20:16:50 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
StopRequestEvent(HttpChannelChild* child,
|
|
|
|
const nsresult& statusCode)
|
|
|
|
: mChild(child)
|
|
|
|
, mStatusCode(statusCode) {}
|
|
|
|
|
2010-08-05 21:59:37 -07:00
|
|
|
void Run() { mChild->OnStopRequest(mStatusCode); }
|
2010-04-20 20:16:50 -07:00
|
|
|
private:
|
|
|
|
HttpChannelChild* mChild;
|
|
|
|
nsresult mStatusCode;
|
|
|
|
};
|
|
|
|
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
bool
|
|
|
|
HttpChannelChild::RecvOnStopRequest(const nsresult& statusCode)
|
2010-04-20 20:16:50 -07:00
|
|
|
{
|
2010-08-05 21:59:37 -07:00
|
|
|
if (ShouldEnqueue()) {
|
|
|
|
EnqueueEvent(new StopRequestEvent(this, statusCode));
|
|
|
|
} else {
|
|
|
|
OnStopRequest(statusCode);
|
|
|
|
}
|
|
|
|
return true;
|
2010-04-20 20:16:50 -07:00
|
|
|
}
|
|
|
|
|
2010-08-05 21:59:37 -07:00
|
|
|
void
|
2010-04-20 20:16:50 -07:00
|
|
|
HttpChannelChild::OnStopRequest(const nsresult& statusCode)
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
{
|
2010-08-12 02:05:16 -07:00
|
|
|
LOG(("HttpChannelChild::OnStopRequest [this=%x status=%u]\n",
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
this, statusCode));
|
|
|
|
|
|
|
|
mIsPending = PR_FALSE;
|
2010-04-23 07:19:33 -07:00
|
|
|
|
2010-12-06 15:28:45 -08:00
|
|
|
if (!mCanceled && NS_SUCCEEDED(mStatus))
|
2010-08-12 02:05:16 -07:00
|
|
|
mStatus = statusCode;
|
|
|
|
|
|
|
|
{ // We must flush the queue before we Send__delete__
|
|
|
|
// (although we really shouldn't receive any msgs after OnStop),
|
2010-08-05 21:59:37 -07:00
|
|
|
// so make sure this goes out of scope before then.
|
|
|
|
AutoEventEnqueuer ensureSerialDispatch(this);
|
2010-08-12 02:05:16 -07:00
|
|
|
|
2010-12-06 15:28:45 -08:00
|
|
|
mListener->OnStopRequest(this, mListenerContext, mStatus);
|
2010-08-12 02:05:16 -07:00
|
|
|
|
2010-08-05 21:59:37 -07:00
|
|
|
mListener = 0;
|
|
|
|
mListenerContext = 0;
|
|
|
|
mCacheEntryAvailable = PR_FALSE;
|
|
|
|
if (mLoadGroup)
|
2010-12-06 15:28:45 -08:00
|
|
|
mLoadGroup->RemoveRequest(this, nsnull, mStatus);
|
2010-08-05 21:59:37 -07:00
|
|
|
}
|
2010-05-28 17:26:45 -07:00
|
|
|
|
2011-01-24 14:58:20 -08:00
|
|
|
if (!(mLoadFlags & LOAD_DOCUMENT_URI)) {
|
|
|
|
// This calls NeckoChild::DeallocPHttpChannel(), which deletes |this| if IPDL
|
|
|
|
// holds the last reference. Don't rely on |this| existing after here.
|
|
|
|
PHttpChannelChild::Send__delete__(this);
|
|
|
|
} else {
|
|
|
|
// We need to keep the document loading channel alive for further
|
|
|
|
// communication, mainly for collecting a security state values.
|
|
|
|
mKeptAlive = true;
|
|
|
|
SendDocumentChannelCleanup();
|
|
|
|
}
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
}
|
|
|
|
|
2010-09-20 11:37:13 -07:00
|
|
|
class ProgressEvent : public ChannelEvent
|
2010-04-20 20:16:50 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
ProgressEvent(HttpChannelChild* child,
|
|
|
|
const PRUint64& progress,
|
|
|
|
const PRUint64& progressMax)
|
|
|
|
: mChild(child)
|
|
|
|
, mProgress(progress)
|
|
|
|
, mProgressMax(progressMax) {}
|
|
|
|
|
2010-08-05 21:59:37 -07:00
|
|
|
void Run() { mChild->OnProgress(mProgress, mProgressMax); }
|
2010-04-20 20:16:50 -07:00
|
|
|
private:
|
|
|
|
HttpChannelChild* mChild;
|
|
|
|
PRUint64 mProgress, mProgressMax;
|
|
|
|
};
|
|
|
|
|
2010-05-13 10:28:51 -07:00
|
|
|
bool
|
|
|
|
HttpChannelChild::RecvOnProgress(const PRUint64& progress,
|
|
|
|
const PRUint64& progressMax)
|
2010-04-20 20:16:50 -07:00
|
|
|
{
|
2010-08-05 21:59:37 -07:00
|
|
|
if (ShouldEnqueue()) {
|
|
|
|
EnqueueEvent(new ProgressEvent(this, progress, progressMax));
|
|
|
|
} else {
|
|
|
|
OnProgress(progress, progressMax);
|
|
|
|
}
|
|
|
|
return true;
|
2010-04-20 20:16:50 -07:00
|
|
|
}
|
|
|
|
|
2010-08-05 21:59:37 -07:00
|
|
|
void
|
2010-04-20 20:16:50 -07:00
|
|
|
HttpChannelChild::OnProgress(const PRUint64& progress,
|
|
|
|
const PRUint64& progressMax)
|
2010-05-13 10:28:51 -07:00
|
|
|
{
|
2010-08-12 02:05:16 -07:00
|
|
|
LOG(("HttpChannelChild::OnProgress [this=%p progress=%llu/%llu]\n",
|
2010-05-13 10:28:51 -07:00
|
|
|
this, progress, progressMax));
|
|
|
|
|
2010-08-12 02:05:16 -07:00
|
|
|
if (mCanceled)
|
|
|
|
return;
|
|
|
|
|
2010-05-13 10:28:51 -07:00
|
|
|
// cache the progress sink so we don't have to query for it each time.
|
|
|
|
if (!mProgressSink)
|
|
|
|
GetCallback(mProgressSink);
|
|
|
|
|
2010-08-05 21:59:37 -07:00
|
|
|
AutoEventEnqueuer ensureSerialDispatch(this);
|
|
|
|
|
2010-05-13 10:28:51 -07:00
|
|
|
// block socket status event after Cancel or OnStopRequest has been called.
|
|
|
|
if (mProgressSink && NS_SUCCEEDED(mStatus) && mIsPending &&
|
|
|
|
!(mLoadFlags & LOAD_BACKGROUND))
|
|
|
|
{
|
2010-08-12 02:05:16 -07:00
|
|
|
if (progress > 0) {
|
2010-05-13 10:28:51 -07:00
|
|
|
NS_ASSERTION(progress <= progressMax, "unexpected progress values");
|
|
|
|
mProgressSink->OnProgress(this, nsnull, progress, progressMax);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-20 11:37:13 -07:00
|
|
|
class StatusEvent : public ChannelEvent
|
2010-04-20 20:16:50 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
StatusEvent(HttpChannelChild* child,
|
|
|
|
const nsresult& status,
|
|
|
|
const nsString& statusArg)
|
|
|
|
: mChild(child)
|
|
|
|
, mStatus(status)
|
|
|
|
, mStatusArg(statusArg) {}
|
|
|
|
|
2010-08-05 21:59:37 -07:00
|
|
|
void Run() { mChild->OnStatus(mStatus, mStatusArg); }
|
2010-04-20 20:16:50 -07:00
|
|
|
private:
|
|
|
|
HttpChannelChild* mChild;
|
|
|
|
nsresult mStatus;
|
|
|
|
nsString mStatusArg;
|
|
|
|
};
|
|
|
|
|
2010-05-13 10:28:51 -07:00
|
|
|
bool
|
|
|
|
HttpChannelChild::RecvOnStatus(const nsresult& status,
|
|
|
|
const nsString& statusArg)
|
2010-04-20 20:16:50 -07:00
|
|
|
{
|
2010-08-05 21:59:37 -07:00
|
|
|
if (ShouldEnqueue()) {
|
|
|
|
EnqueueEvent(new StatusEvent(this, status, statusArg));
|
|
|
|
} else {
|
|
|
|
OnStatus(status, statusArg);
|
|
|
|
}
|
|
|
|
return true;
|
2010-04-20 20:16:50 -07:00
|
|
|
}
|
|
|
|
|
2010-08-05 21:59:37 -07:00
|
|
|
void
|
2010-04-20 20:16:50 -07:00
|
|
|
HttpChannelChild::OnStatus(const nsresult& status,
|
|
|
|
const nsString& statusArg)
|
2010-05-13 10:28:51 -07:00
|
|
|
{
|
2010-08-12 02:05:16 -07:00
|
|
|
LOG(("HttpChannelChild::OnStatus [this=%p status=%x]\n", this, status));
|
|
|
|
|
|
|
|
if (mCanceled)
|
|
|
|
return;
|
2010-05-13 10:28:51 -07:00
|
|
|
|
|
|
|
// cache the progress sink so we don't have to query for it each time.
|
|
|
|
if (!mProgressSink)
|
|
|
|
GetCallback(mProgressSink);
|
|
|
|
|
2010-08-05 21:59:37 -07:00
|
|
|
AutoEventEnqueuer ensureSerialDispatch(this);
|
|
|
|
|
2010-05-13 10:28:51 -07:00
|
|
|
// block socket status event after Cancel or OnStopRequest has been called.
|
|
|
|
if (mProgressSink && NS_SUCCEEDED(mStatus) && mIsPending &&
|
|
|
|
!(mLoadFlags & LOAD_BACKGROUND))
|
|
|
|
{
|
|
|
|
mProgressSink->OnStatus(this, nsnull, status, statusArg.get());
|
|
|
|
}
|
2010-04-20 20:16:50 -07:00
|
|
|
}
|
|
|
|
|
2010-09-20 11:37:13 -07:00
|
|
|
class CancelEvent : public ChannelEvent
|
2010-08-12 02:05:16 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
CancelEvent(HttpChannelChild* child, const nsresult& status)
|
|
|
|
: mChild(child)
|
|
|
|
, mStatus(status) {}
|
|
|
|
|
|
|
|
void Run() { mChild->OnCancel(mStatus); }
|
|
|
|
private:
|
|
|
|
HttpChannelChild* mChild;
|
|
|
|
nsresult mStatus;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool
|
|
|
|
HttpChannelChild::RecvCancelEarly(const nsresult& status)
|
|
|
|
{
|
|
|
|
if (ShouldEnqueue()) {
|
|
|
|
EnqueueEvent(new CancelEvent(this, status));
|
|
|
|
} else {
|
|
|
|
OnCancel(status);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
HttpChannelChild::OnCancel(const nsresult& status)
|
|
|
|
{
|
|
|
|
LOG(("HttpChannelChild::OnCancel [this=%p status=%x]\n", this, status));
|
|
|
|
|
|
|
|
if (mCanceled)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mCanceled = true;
|
|
|
|
mStatus = status;
|
|
|
|
|
|
|
|
mIsPending = false;
|
|
|
|
if (mLoadGroup)
|
|
|
|
mLoadGroup->RemoveRequest(this, nsnull, mStatus);
|
|
|
|
|
|
|
|
if (mListener) {
|
|
|
|
mListener->OnStartRequest(this, mListenerContext);
|
|
|
|
mListener->OnStopRequest(this, mListenerContext, mStatus);
|
|
|
|
}
|
|
|
|
|
|
|
|
mListener = NULL;
|
|
|
|
mListenerContext = NULL;
|
|
|
|
|
2011-01-24 14:58:20 -08:00
|
|
|
if (mIPCOpen)
|
|
|
|
PHttpChannelChild::Send__delete__(this);
|
2010-08-12 02:05:16 -07:00
|
|
|
}
|
|
|
|
|
2010-09-15 12:26:15 -07:00
|
|
|
class DeleteSelfEvent : public ChannelEvent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DeleteSelfEvent(HttpChannelChild* child) : mChild(child) {}
|
|
|
|
void Run() { mChild->DeleteSelf(); }
|
|
|
|
private:
|
|
|
|
HttpChannelChild* mChild;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool
|
|
|
|
HttpChannelChild::RecvDeleteSelf()
|
|
|
|
{
|
|
|
|
if (ShouldEnqueue()) {
|
|
|
|
EnqueueEvent(new DeleteSelfEvent(this));
|
|
|
|
} else {
|
|
|
|
DeleteSelf();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
HttpChannelChild::DeleteSelf()
|
|
|
|
{
|
2011-01-24 14:58:20 -08:00
|
|
|
Send__delete__(this);
|
2010-09-15 12:26:15 -07:00
|
|
|
}
|
|
|
|
|
2010-09-20 11:37:13 -07:00
|
|
|
class Redirect1Event : public ChannelEvent
|
2010-08-10 20:11:57 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
Redirect1Event(HttpChannelChild* child,
|
2010-11-23 14:56:06 -08:00
|
|
|
const PRUint32& newChannelId,
|
2010-08-10 20:11:57 -07:00
|
|
|
const IPC::URI& newURI,
|
|
|
|
const PRUint32& redirectFlags,
|
|
|
|
const nsHttpResponseHead& responseHead)
|
|
|
|
: mChild(child)
|
2010-11-23 14:56:06 -08:00
|
|
|
, mNewChannelId(newChannelId)
|
2010-08-10 20:11:57 -07:00
|
|
|
, mNewURI(newURI)
|
|
|
|
, mRedirectFlags(redirectFlags)
|
|
|
|
, mResponseHead(responseHead) {}
|
|
|
|
|
|
|
|
void Run()
|
|
|
|
{
|
2010-11-23 14:56:06 -08:00
|
|
|
mChild->Redirect1Begin(mNewChannelId, mNewURI, mRedirectFlags,
|
2010-08-10 20:11:57 -07:00
|
|
|
mResponseHead);
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
HttpChannelChild* mChild;
|
2010-11-23 14:56:06 -08:00
|
|
|
PRUint32 mNewChannelId;
|
2010-08-10 20:11:57 -07:00
|
|
|
IPC::URI mNewURI;
|
|
|
|
PRUint32 mRedirectFlags;
|
|
|
|
nsHttpResponseHead mResponseHead;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool
|
2010-11-23 14:56:06 -08:00
|
|
|
HttpChannelChild::RecvRedirect1Begin(const PRUint32& newChannelId,
|
|
|
|
const URI& newUri,
|
2010-08-10 20:11:57 -07:00
|
|
|
const PRUint32& redirectFlags,
|
|
|
|
const nsHttpResponseHead& responseHead)
|
|
|
|
{
|
|
|
|
if (ShouldEnqueue()) {
|
2010-11-23 14:56:06 -08:00
|
|
|
EnqueueEvent(new Redirect1Event(this, newChannelId, newUri, redirectFlags,
|
2010-08-10 20:11:57 -07:00
|
|
|
responseHead));
|
|
|
|
} else {
|
2010-11-23 14:56:06 -08:00
|
|
|
Redirect1Begin(newChannelId, newUri, redirectFlags, responseHead);
|
2010-08-10 20:11:57 -07:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-11-23 14:56:06 -08:00
|
|
|
HttpChannelChild::Redirect1Begin(const PRUint32& newChannelId,
|
2010-08-10 20:11:57 -07:00
|
|
|
const IPC::URI& newURI,
|
|
|
|
const PRUint32& redirectFlags,
|
|
|
|
const nsHttpResponseHead& responseHead)
|
|
|
|
{
|
2010-11-23 14:56:06 -08:00
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIIOService> ioService;
|
|
|
|
rv = gHttpHandler->GetIOService(getter_AddRefs(ioService));
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
// Veto redirect. nsHttpChannel decides to cancel or continue.
|
|
|
|
OnRedirectVerifyCallback(rv);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-08-10 20:11:57 -07:00
|
|
|
nsCOMPtr<nsIURI> uri(newURI);
|
|
|
|
|
2010-11-23 14:56:06 -08:00
|
|
|
nsCOMPtr<nsIChannel> newChannel;
|
|
|
|
rv = ioService->NewChannelFromURI(uri, getter_AddRefs(newChannel));
|
2010-08-12 02:05:16 -07:00
|
|
|
if (NS_FAILED(rv)) {
|
2010-11-23 14:56:06 -08:00
|
|
|
// Veto redirect. nsHttpChannel decides to cancel or continue.
|
|
|
|
OnRedirectVerifyCallback(rv);
|
2010-08-12 02:05:16 -07:00
|
|
|
return;
|
|
|
|
}
|
2010-08-10 20:11:57 -07:00
|
|
|
|
|
|
|
// We won't get OnStartRequest, set cookies here.
|
|
|
|
mResponseHead = new nsHttpResponseHead(responseHead);
|
|
|
|
SetCookie(mResponseHead->PeekHeader(nsHttp::Set_Cookie));
|
|
|
|
|
|
|
|
PRBool preserveMethod = (mResponseHead->Status() == 307);
|
2010-11-23 14:56:06 -08:00
|
|
|
rv = SetupReplacementChannel(uri, newChannel, preserveMethod);
|
2010-08-12 02:05:16 -07:00
|
|
|
if (NS_FAILED(rv)) {
|
2010-10-08 22:07:49 -07:00
|
|
|
// Veto redirect. nsHttpChannel decides to cancel or continue.
|
2010-11-23 14:56:06 -08:00
|
|
|
OnRedirectVerifyCallback(rv);
|
2010-08-12 02:05:16 -07:00
|
|
|
return;
|
|
|
|
}
|
2010-08-10 20:11:57 -07:00
|
|
|
|
2010-11-23 14:56:06 -08:00
|
|
|
mRedirectChannelChild = do_QueryInterface(newChannel);
|
|
|
|
if (mRedirectChannelChild) {
|
|
|
|
mRedirectChannelChild->ConnectParent(newChannelId);
|
|
|
|
} else {
|
|
|
|
NS_ERROR("Redirecting to a protocol that doesn't support universal protocol redirect");
|
|
|
|
}
|
2010-08-10 20:11:57 -07:00
|
|
|
|
2010-08-12 02:05:16 -07:00
|
|
|
rv = gHttpHandler->AsyncOnChannelRedirect(this,
|
2010-11-23 14:56:06 -08:00
|
|
|
newChannel,
|
2010-08-12 02:05:16 -07:00
|
|
|
redirectFlags);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
OnRedirectVerifyCallback(rv);
|
2010-08-10 20:11:57 -07:00
|
|
|
}
|
|
|
|
|
2010-09-20 11:37:13 -07:00
|
|
|
class Redirect3Event : public ChannelEvent
|
2010-08-10 20:11:57 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
Redirect3Event(HttpChannelChild* child) : mChild(child) {}
|
|
|
|
void Run() { mChild->Redirect3Complete(); }
|
|
|
|
private:
|
|
|
|
HttpChannelChild* mChild;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool
|
|
|
|
HttpChannelChild::RecvRedirect3Complete()
|
|
|
|
{
|
|
|
|
if (ShouldEnqueue()) {
|
|
|
|
EnqueueEvent(new Redirect3Event(this));
|
|
|
|
} else {
|
|
|
|
Redirect3Complete();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
HttpChannelChild::Redirect3Complete()
|
|
|
|
{
|
2010-11-23 14:56:06 -08:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
// Chrome channel has been AsyncOpen'd. Reflect this in child.
|
|
|
|
if (mRedirectChannelChild)
|
|
|
|
rv = mRedirectChannelChild->CompleteRedirectSetup(mListener,
|
|
|
|
mListenerContext);
|
2010-08-10 20:11:57 -07:00
|
|
|
|
|
|
|
// Redirecting to new channel: shut this down and init new channel
|
|
|
|
if (mLoadGroup)
|
|
|
|
mLoadGroup->RemoveRequest(this, nsnull, NS_BINDING_ABORTED);
|
|
|
|
|
|
|
|
if (NS_FAILED(rv))
|
2010-10-08 22:07:49 -07:00
|
|
|
NS_WARNING("CompleteRedirectSetup failed, HttpChannelChild already open?");
|
|
|
|
|
|
|
|
// Release ref to new channel.
|
|
|
|
mRedirectChannelChild = nsnull;
|
2010-08-10 20:11:57 -07:00
|
|
|
}
|
|
|
|
|
2010-11-23 14:56:06 -08:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::nsIChildChannel
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::ConnectParent(PRUint32 id)
|
|
|
|
{
|
|
|
|
mozilla::dom::TabChild* tabChild = nsnull;
|
|
|
|
nsCOMPtr<nsITabChild> iTabChild;
|
|
|
|
GetCallback(iTabChild);
|
|
|
|
if (iTabChild) {
|
|
|
|
tabChild = static_cast<mozilla::dom::TabChild*>(iTabChild.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
// The socket transport in the chrome process now holds a logical ref to us
|
|
|
|
// until OnStopRequest, or we do a redirect, or we hit an IPDL error.
|
|
|
|
AddIPDLReference();
|
|
|
|
|
|
|
|
if (!gNeckoChild->SendPHttpChannelConstructor(this, tabChild))
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
if (!SendConnectChannel(id))
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2010-08-10 20:11:57 -07:00
|
|
|
HttpChannelChild::CompleteRedirectSetup(nsIStreamListener *listener,
|
|
|
|
nsISupports *aContext)
|
|
|
|
{
|
|
|
|
LOG(("HttpChannelChild::FinishRedirectSetup [this=%x]\n", this));
|
|
|
|
|
|
|
|
NS_ENSURE_TRUE(!mIsPending, NS_ERROR_IN_PROGRESS);
|
|
|
|
NS_ENSURE_TRUE(!mWasOpened, NS_ERROR_ALREADY_OPENED);
|
|
|
|
|
2010-10-08 22:07:49 -07:00
|
|
|
/*
|
|
|
|
* No need to check for cancel: we don't get here if nsHttpChannel canceled
|
|
|
|
* before AsyncOpen(); if it's canceled after that, OnStart/Stop will just
|
|
|
|
* get called with error code as usual. So just setup mListener and make the
|
|
|
|
* channel reflect AsyncOpen'ed state.
|
|
|
|
*/
|
|
|
|
|
2010-08-10 20:11:57 -07:00
|
|
|
mIsPending = PR_TRUE;
|
|
|
|
mWasOpened = PR_TRUE;
|
|
|
|
mListener = listener;
|
|
|
|
mListenerContext = aContext;
|
|
|
|
|
|
|
|
// add ourselves to the load group.
|
|
|
|
if (mLoadGroup)
|
|
|
|
mLoadGroup->AddRequest(this, nsnull);
|
|
|
|
|
2010-08-12 02:05:16 -07:00
|
|
|
// We already have an open IPDL connection to the parent. If on-modify-request
|
|
|
|
// listeners or load group observers canceled us, let the parent handle it
|
|
|
|
// and send it back to us naturally.
|
2010-08-10 20:11:57 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::nsIAsyncVerifyRedirectCallback
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::OnRedirectVerifyCallback(nsresult result)
|
|
|
|
{
|
2010-11-23 14:56:06 -08:00
|
|
|
nsCOMPtr<nsIHttpChannel> newHttpChannel =
|
|
|
|
do_QueryInterface(mRedirectChannelChild);
|
|
|
|
|
|
|
|
if (newHttpChannel) {
|
|
|
|
// Must not be called until after redirect observers called.
|
|
|
|
newHttpChannel->SetOriginalURI(mRedirectOriginalURI);
|
|
|
|
}
|
|
|
|
|
|
|
|
RequestHeaderTuples emptyHeaders;
|
|
|
|
RequestHeaderTuples* headerTuples = &emptyHeaders;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIHttpChannelChild> newHttpChannelChild =
|
|
|
|
do_QueryInterface(mRedirectChannelChild);
|
|
|
|
if (newHttpChannelChild && NS_SUCCEEDED(result)) {
|
|
|
|
newHttpChannelChild->AddCookiesToRequest();
|
|
|
|
newHttpChannelChild->GetHeaderTuples(&headerTuples);
|
|
|
|
}
|
2010-08-10 20:11:57 -07:00
|
|
|
|
2010-10-08 22:07:58 -07:00
|
|
|
// After we verify redirect, nsHttpChannel may hit the network: must give
|
|
|
|
// "http-on-modify-request" observers the chance to cancel before that.
|
|
|
|
if (NS_SUCCEEDED(result))
|
2010-11-23 14:56:06 -08:00
|
|
|
gHttpHandler->OnModifyRequest(newHttpChannel);
|
2010-10-08 22:07:58 -07:00
|
|
|
|
2010-11-23 14:56:06 -08:00
|
|
|
return SendRedirect2Verify(result, *headerTuples);
|
2010-08-10 20:11:57 -07:00
|
|
|
}
|
|
|
|
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::nsIRequest
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2010-04-07 01:43:09 -07:00
|
|
|
HttpChannelChild::Cancel(nsresult status)
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
{
|
2010-08-12 02:05:16 -07:00
|
|
|
if (!mCanceled) {
|
|
|
|
// If this cancel occurs before nsHttpChannel has been set up, AsyncOpen
|
|
|
|
// is responsible for cleaning up.
|
|
|
|
mCanceled = true;
|
|
|
|
mStatus = status;
|
|
|
|
if (mIPCOpen)
|
|
|
|
SendCancel(status);
|
|
|
|
}
|
2010-03-27 18:53:46 -07:00
|
|
|
return NS_OK;
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::Suspend()
|
|
|
|
{
|
2010-08-10 20:07:09 -07:00
|
|
|
NS_ENSURE_TRUE(mIPCOpen, NS_ERROR_NOT_AVAILABLE);
|
|
|
|
SendSuspend();
|
|
|
|
mSuspendCount++;
|
|
|
|
return NS_OK;
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::Resume()
|
|
|
|
{
|
2010-08-10 20:07:09 -07:00
|
|
|
NS_ENSURE_TRUE(mIPCOpen, NS_ERROR_NOT_AVAILABLE);
|
|
|
|
NS_ENSURE_TRUE(mSuspendCount > 0, NS_ERROR_UNEXPECTED);
|
|
|
|
SendResume();
|
|
|
|
mSuspendCount--;
|
2010-09-17 00:23:25 -07:00
|
|
|
if (!mSuspendCount) {
|
|
|
|
// If we were suspended outside of an event handler (bug 595972) we'll
|
|
|
|
// consider ourselves unqueued. This is a legal state of affairs but
|
|
|
|
// FlushEventQueue() can't easily ensure this fact, so we'll do some
|
|
|
|
// fudging to set the invariants correctly.
|
|
|
|
if (mQueuePhase == PHASE_UNQUEUED)
|
|
|
|
mQueuePhase = PHASE_FINISHED_QUEUEING;
|
2010-08-10 20:07:09 -07:00
|
|
|
FlushEventQueue();
|
2010-09-17 00:23:25 -07:00
|
|
|
}
|
2010-08-10 20:07:09 -07:00
|
|
|
return NS_OK;
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::nsIChannel
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::GetSecurityInfo(nsISupports **aSecurityInfo)
|
|
|
|
{
|
2010-03-27 18:53:46 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(aSecurityInfo);
|
2010-08-13 01:06:40 -07:00
|
|
|
NS_IF_ADDREF(*aSecurityInfo = mSecurityInfo);
|
2010-03-27 18:53:46 -07:00
|
|
|
return NS_OK;
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::AsyncOpen(nsIStreamListener *listener, nsISupports *aContext)
|
|
|
|
{
|
|
|
|
LOG(("HttpChannelChild::AsyncOpen [this=%x uri=%s]\n", this, mSpec.get()));
|
|
|
|
|
2010-08-12 02:05:16 -07:00
|
|
|
if (mCanceled)
|
|
|
|
return mStatus;
|
|
|
|
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
NS_ENSURE_TRUE(gNeckoChild != nsnull, NS_ERROR_FAILURE);
|
|
|
|
NS_ENSURE_ARG_POINTER(listener);
|
|
|
|
NS_ENSURE_TRUE(!mIsPending, NS_ERROR_IN_PROGRESS);
|
|
|
|
NS_ENSURE_TRUE(!mWasOpened, NS_ERROR_ALREADY_OPENED);
|
|
|
|
|
|
|
|
// Port checked in parent, but duplicate here so we can return with error
|
2010-04-10 22:13:57 -07:00
|
|
|
// immediately
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
nsresult rv;
|
|
|
|
rv = NS_CheckPortSafety(mURI);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
2010-06-15 16:07:10 -07:00
|
|
|
const char *cookieHeader = mRequestHead.PeekHeader(nsHttp::Cookie);
|
|
|
|
if (cookieHeader) {
|
|
|
|
mUserSetCookieHeader = cookieHeader;
|
|
|
|
}
|
|
|
|
|
|
|
|
AddCookiesToRequest();
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
|
2010-05-30 15:30:28 -07:00
|
|
|
//
|
|
|
|
// NOTE: From now on we must return NS_OK; all errors must be handled via
|
|
|
|
// OnStart/OnStopRequest
|
|
|
|
//
|
|
|
|
|
2010-04-10 22:13:57 -07:00
|
|
|
// notify "http-on-modify-request" observers
|
|
|
|
gHttpHandler->OnModifyRequest(this);
|
|
|
|
|
|
|
|
mIsPending = PR_TRUE;
|
|
|
|
mWasOpened = PR_TRUE;
|
2010-04-07 01:43:09 -07:00
|
|
|
mListener = listener;
|
|
|
|
mListenerContext = aContext;
|
|
|
|
|
2010-04-10 22:13:57 -07:00
|
|
|
// add ourselves to the load group.
|
|
|
|
if (mLoadGroup)
|
|
|
|
mLoadGroup->AddRequest(this, nsnull);
|
|
|
|
|
2010-08-12 02:05:16 -07:00
|
|
|
if (mCanceled) {
|
|
|
|
// We may have been canceled already, either by on-modify-request
|
|
|
|
// listeners or by load group observers; in that case, don't create IPDL
|
|
|
|
// connection. See nsHttpChannel::AsyncOpen().
|
|
|
|
|
|
|
|
// Clear mCanceled here, or we will bail out at top of OnCancel().
|
|
|
|
mCanceled = false;
|
|
|
|
OnCancel(mStatus);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2010-04-10 22:13:57 -07:00
|
|
|
|
2010-10-20 10:12:32 -07:00
|
|
|
nsCString appCacheClientId;
|
|
|
|
if (mInheritApplicationCache) {
|
|
|
|
// Pick up an application cache from the notification
|
|
|
|
// callbacks if available
|
|
|
|
nsCOMPtr<nsIApplicationCacheContainer> appCacheContainer;
|
|
|
|
GetCallback(appCacheContainer);
|
|
|
|
|
|
|
|
if (appCacheContainer) {
|
|
|
|
nsCOMPtr<nsIApplicationCache> appCache;
|
|
|
|
rv = appCacheContainer->GetApplicationCache(getter_AddRefs(appCache));
|
|
|
|
if (NS_SUCCEEDED(rv) && appCache) {
|
|
|
|
appCache->GetClientID(appCacheClientId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-10 22:13:57 -07:00
|
|
|
//
|
|
|
|
// Send request to the chrome process...
|
|
|
|
//
|
|
|
|
|
|
|
|
// FIXME: bug 558623: Combine constructor and SendAsyncOpen into one IPC msg
|
2010-06-18 03:49:28 -07:00
|
|
|
|
|
|
|
mozilla::dom::TabChild* tabChild = nsnull;
|
|
|
|
nsCOMPtr<nsITabChild> iTabChild;
|
|
|
|
GetCallback(iTabChild);
|
|
|
|
if (iTabChild) {
|
|
|
|
tabChild = static_cast<mozilla::dom::TabChild*>(iTabChild.get());
|
|
|
|
}
|
|
|
|
|
2010-08-10 20:11:57 -07:00
|
|
|
// The socket transport in the chrome process now holds a logical ref to us
|
|
|
|
// until OnStopRequest, or we do a redirect, or we hit an IPDL error.
|
2010-06-27 09:44:15 -07:00
|
|
|
AddIPDLReference();
|
|
|
|
|
2010-06-18 03:49:28 -07:00
|
|
|
gNeckoChild->SendPHttpChannelConstructor(this, tabChild);
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
|
2010-08-10 20:11:57 -07:00
|
|
|
SendAsyncOpen(IPC::URI(mURI), IPC::URI(mOriginalURI),
|
|
|
|
IPC::URI(mDocumentURI), IPC::URI(mReferrer), mLoadFlags,
|
2010-10-21 11:36:13 -07:00
|
|
|
mRequestHeaders, mRequestHead.Method(),
|
|
|
|
IPC::InputStream(mUploadStream), mUploadStreamHasHeaders,
|
|
|
|
mPriority, mRedirectionLimit, mAllowPipelining,
|
|
|
|
mForceAllowThirdPartyCookie, mSendResumeAt,
|
2010-10-20 10:12:32 -07:00
|
|
|
mStartPos, mEntityID, mChooseApplicationCache,
|
|
|
|
appCacheClientId);
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::nsIHttpChannel
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::SetRequestHeader(const nsACString& aHeader,
|
|
|
|
const nsACString& aValue,
|
|
|
|
PRBool aMerge)
|
|
|
|
{
|
2010-04-07 01:43:09 -07:00
|
|
|
nsresult rv = HttpBaseChannel::SetRequestHeader(aHeader, aValue, aMerge);
|
2010-03-23 08:14:36 -07:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
RequestHeaderTuple* tuple = mRequestHeaders.AppendElement();
|
|
|
|
if (!tuple)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
tuple->mHeader = aHeader;
|
|
|
|
tuple->mValue = aValue;
|
|
|
|
tuple->mMerge = aMerge;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::nsIHttpChannelInternal
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::SetupFallbackChannel(const char *aFallbackKey)
|
|
|
|
{
|
|
|
|
DROP_DEAD();
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2010-06-23 23:55:19 -07:00
|
|
|
// HttpChannelChild::nsICacheInfoChannel
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2010-06-23 23:55:19 -07:00
|
|
|
HttpChannelChild::GetCacheTokenExpirationTime(PRUint32 *_retval)
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
{
|
2010-06-23 23:55:19 -07:00
|
|
|
NS_ENSURE_ARG_POINTER(_retval);
|
|
|
|
if (!mCacheEntryAvailable)
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
|
2010-06-23 23:55:19 -07:00
|
|
|
*_retval = mCacheExpirationTime;
|
2010-03-27 18:53:46 -07:00
|
|
|
return NS_OK;
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2010-06-23 23:55:19 -07:00
|
|
|
HttpChannelChild::GetCacheTokenCachedCharset(nsACString &_retval)
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
{
|
2010-06-23 23:55:19 -07:00
|
|
|
if (!mCacheEntryAvailable)
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
|
2010-06-23 23:55:19 -07:00
|
|
|
_retval = mCachedCharset;
|
|
|
|
return NS_OK;
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
2010-06-23 23:55:19 -07:00
|
|
|
HttpChannelChild::SetCacheTokenCachedCharset(const nsACString &aCharset)
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
{
|
2010-06-27 09:44:15 -07:00
|
|
|
if (!mCacheEntryAvailable || !mIPCOpen)
|
2010-06-23 23:55:19 -07:00
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
|
2010-06-23 23:55:19 -07:00
|
|
|
mCachedCharset = aCharset;
|
|
|
|
if (!SendSetCacheTokenCachedCharset(PromiseFlatCString(aCharset))) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2010-03-27 18:53:46 -07:00
|
|
|
HttpChannelChild::IsFromCache(PRBool *value)
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
{
|
2010-03-27 18:53:46 -07:00
|
|
|
if (!mIsPending)
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
2010-06-23 23:55:19 -07:00
|
|
|
*value = mIsFromCache;
|
2010-03-27 18:53:46 -07:00
|
|
|
return NS_OK;
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::nsIResumableChannel
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::ResumeAt(PRUint64 startPos, const nsACString& entityID)
|
|
|
|
{
|
2010-08-10 20:07:09 -07:00
|
|
|
ENSURE_CALLED_BEFORE_ASYNC_OPEN();
|
|
|
|
mStartPos = startPos;
|
|
|
|
mEntityID = entityID;
|
|
|
|
mSendResumeAt = true;
|
|
|
|
return NS_OK;
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
}
|
|
|
|
|
2010-08-10 20:07:09 -07:00
|
|
|
// GetEntityID is shared in HttpBaseChannel
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::nsISupportsPriority
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::SetPriority(PRInt32 aPriority)
|
|
|
|
{
|
2010-04-10 21:53:35 -07:00
|
|
|
PRInt16 newValue = CLAMP(aPriority, PR_INT16_MIN, PR_INT16_MAX);
|
|
|
|
if (mPriority == newValue)
|
|
|
|
return NS_OK;
|
|
|
|
mPriority = newValue;
|
2010-06-27 09:44:15 -07:00
|
|
|
if (mIPCOpen)
|
2010-04-10 21:53:35 -07:00
|
|
|
SendSetPriority(mPriority);
|
|
|
|
return NS_OK;
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::nsIProxiedChannel
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::GetProxyInfo(nsIProxyInfo **aProxyInfo)
|
|
|
|
{
|
|
|
|
DROP_DEAD();
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::nsITraceableChannel
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::SetNewListener(nsIStreamListener *listener,
|
|
|
|
nsIStreamListener **oldListener)
|
|
|
|
{
|
|
|
|
DROP_DEAD();
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::nsIApplicationCacheContainer
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::GetApplicationCache(nsIApplicationCache **aApplicationCache)
|
|
|
|
{
|
2010-10-20 10:12:32 -07:00
|
|
|
NS_IF_ADDREF(*aApplicationCache = mApplicationCache);
|
|
|
|
return NS_OK;
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::SetApplicationCache(nsIApplicationCache *aApplicationCache)
|
|
|
|
{
|
2010-10-20 10:12:32 -07:00
|
|
|
NS_ENSURE_TRUE(!mWasOpened, NS_ERROR_ALREADY_OPENED);
|
|
|
|
|
|
|
|
mApplicationCache = aApplicationCache;
|
|
|
|
return NS_OK;
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::nsIApplicationCacheChannel
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2010-10-20 10:12:32 -07:00
|
|
|
HttpChannelChild::GetLoadedFromApplicationCache(PRBool *aLoadedFromApplicationCache)
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
{
|
2010-10-20 10:12:32 -07:00
|
|
|
*aLoadedFromApplicationCache = mLoadedFromApplicationCache;
|
2010-03-27 18:53:46 -07:00
|
|
|
return NS_OK;
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2010-10-20 10:12:32 -07:00
|
|
|
HttpChannelChild::GetInheritApplicationCache(PRBool *aInherit)
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
{
|
2010-10-20 10:12:32 -07:00
|
|
|
*aInherit = mInheritApplicationCache;
|
|
|
|
return NS_OK;
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
2010-10-20 10:12:32 -07:00
|
|
|
HttpChannelChild::SetInheritApplicationCache(PRBool aInherit)
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
{
|
2010-10-20 10:12:32 -07:00
|
|
|
mInheritApplicationCache = aInherit;
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2010-10-20 10:12:32 -07:00
|
|
|
HttpChannelChild::GetChooseApplicationCache(PRBool *aChoose)
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
{
|
2010-10-20 10:12:32 -07:00
|
|
|
*aChoose = mChooseApplicationCache;
|
|
|
|
return NS_OK;
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
}
|
2010-10-20 10:12:32 -07:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::SetChooseApplicationCache(PRBool aChoose)
|
|
|
|
{
|
|
|
|
mChooseApplicationCache = aChoose;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
NS_IMETHODIMP
|
2010-10-20 10:12:32 -07:00
|
|
|
HttpChannelChild::MarkOfflineCacheEntryAsForeign()
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
{
|
2010-10-20 10:12:32 -07:00
|
|
|
SendMarkOfflineCacheEntryAsForeign();
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-08-13 01:06:40 -07:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::nsIAssociatedContentSecurity
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool
|
|
|
|
HttpChannelChild::GetAssociatedContentSecurity(
|
|
|
|
nsIAssociatedContentSecurity** _result)
|
|
|
|
{
|
|
|
|
if (!mSecurityInfo)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIAssociatedContentSecurity> assoc =
|
|
|
|
do_QueryInterface(mSecurityInfo);
|
|
|
|
if (!assoc)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (_result)
|
|
|
|
assoc.forget(_result);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* attribute unsigned long countSubRequestsHighSecurity; */
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::GetCountSubRequestsHighSecurity(
|
|
|
|
PRInt32 *aSubRequestsHighSecurity)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAssociatedContentSecurity> assoc;
|
|
|
|
if (!GetAssociatedContentSecurity(getter_AddRefs(assoc)))
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
return assoc->GetCountSubRequestsHighSecurity(aSubRequestsHighSecurity);
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::SetCountSubRequestsHighSecurity(
|
|
|
|
PRInt32 aSubRequestsHighSecurity)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAssociatedContentSecurity> assoc;
|
|
|
|
if (!GetAssociatedContentSecurity(getter_AddRefs(assoc)))
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
return assoc->SetCountSubRequestsHighSecurity(aSubRequestsHighSecurity);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* attribute unsigned long countSubRequestsLowSecurity; */
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::GetCountSubRequestsLowSecurity(
|
|
|
|
PRInt32 *aSubRequestsLowSecurity)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAssociatedContentSecurity> assoc;
|
|
|
|
if (!GetAssociatedContentSecurity(getter_AddRefs(assoc)))
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
return assoc->GetCountSubRequestsLowSecurity(aSubRequestsLowSecurity);
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::SetCountSubRequestsLowSecurity(
|
|
|
|
PRInt32 aSubRequestsLowSecurity)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAssociatedContentSecurity> assoc;
|
|
|
|
if (!GetAssociatedContentSecurity(getter_AddRefs(assoc)))
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
return assoc->SetCountSubRequestsLowSecurity(aSubRequestsLowSecurity);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* attribute unsigned long countSubRequestsBrokenSecurity; */
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::GetCountSubRequestsBrokenSecurity(
|
|
|
|
PRInt32 *aSubRequestsBrokenSecurity)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAssociatedContentSecurity> assoc;
|
|
|
|
if (!GetAssociatedContentSecurity(getter_AddRefs(assoc)))
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
return assoc->GetCountSubRequestsBrokenSecurity(aSubRequestsBrokenSecurity);
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::SetCountSubRequestsBrokenSecurity(
|
|
|
|
PRInt32 aSubRequestsBrokenSecurity)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAssociatedContentSecurity> assoc;
|
|
|
|
if (!GetAssociatedContentSecurity(getter_AddRefs(assoc)))
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
return assoc->SetCountSubRequestsBrokenSecurity(aSubRequestsBrokenSecurity);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* attribute unsigned long countSubRequestsNoSecurity; */
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::GetCountSubRequestsNoSecurity(PRInt32 *aSubRequestsNoSecurity)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAssociatedContentSecurity> assoc;
|
|
|
|
if (!GetAssociatedContentSecurity(getter_AddRefs(assoc)))
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
return assoc->GetCountSubRequestsNoSecurity(aSubRequestsNoSecurity);
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::SetCountSubRequestsNoSecurity(PRInt32 aSubRequestsNoSecurity)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAssociatedContentSecurity> assoc;
|
|
|
|
if (!GetAssociatedContentSecurity(getter_AddRefs(assoc)))
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
return assoc->SetCountSubRequestsNoSecurity(aSubRequestsNoSecurity);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::Flush()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAssociatedContentSecurity> assoc;
|
|
|
|
if (!GetAssociatedContentSecurity(getter_AddRefs(assoc)))
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
PRInt32 hi, low, broken, no;
|
|
|
|
|
|
|
|
rv = assoc->GetCountSubRequestsHighSecurity(&hi);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
rv = assoc->GetCountSubRequestsLowSecurity(&low);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
rv = assoc->GetCountSubRequestsBrokenSecurity(&broken);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
rv = assoc->GetCountSubRequestsNoSecurity(&no);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
if (mIPCOpen)
|
|
|
|
SendUpdateAssociatedContentSecurity(hi, low, broken, no);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
|
2010-11-23 14:56:06 -08:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::nsIHttpChannelChild
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP HttpChannelChild::AddCookiesToRequest()
|
|
|
|
{
|
|
|
|
HttpBaseChannel::AddCookiesToRequest();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP HttpChannelChild::GetHeaderTuples(RequestHeaderTuples **aHeaderTuples)
|
|
|
|
{
|
|
|
|
*aHeaderTuples = &mRequestHeaders;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 11:55:33 -07:00
|
|
|
//------------------------------------------------------------------------------
|
2010-08-10 20:11:57 -07:00
|
|
|
|
2009-08-18 12:05:15 -07:00
|
|
|
}} // mozilla::net
|