2009-08-18 19:05:15 +00: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 08:43:09 +00:00
|
|
|
* Daniel Witte <dwitte@mozilla.com>
|
2010-08-11 03:11:57 +00:00
|
|
|
* Honza Bambas <honzab@firemni.cz>
|
2009-08-18 19:05:15 +00: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 18:55:33 +00:00
|
|
|
#include "nsHttp.h"
|
2010-06-18 10:49:28 +00: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 18:55:33 +00:00
|
|
|
#include "mozilla/net/NeckoChild.h"
|
2009-08-18 19:05:15 +00: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 18:55:33 +00:00
|
|
|
|
|
|
|
#include "nsStringStream.h"
|
|
|
|
#include "nsHttpHandler.h"
|
|
|
|
#include "nsMimeTypes.h"
|
|
|
|
#include "nsNetUtil.h"
|
2010-08-13 08:06:40 +00: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 18:55:33 +00:00
|
|
|
|
2010-08-06 04:59:37 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace net {
|
|
|
|
|
2010-08-11 03:11:57 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2009-08-18 19:05:15 +00:00
|
|
|
HttpChannelChild::HttpChannelChild()
|
2010-06-24 06:55:19 +00:00
|
|
|
: mIsFromCache(PR_FALSE)
|
|
|
|
, mCacheEntryAvailable(PR_FALSE)
|
|
|
|
, mCacheExpirationTime(nsICache::NO_EXPIRATION_TIME)
|
2010-08-11 03:07:09 +00:00
|
|
|
, mSendResumeAt(false)
|
|
|
|
, mSuspendCount(0)
|
2010-06-27 16:44:15 +00:00
|
|
|
, mIPCOpen(false)
|
2010-08-13 08:06:40 +00:00
|
|
|
, mKeptAlive(false)
|
2009-08-18 19:05:15 +00: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 18:55:33 +00:00
|
|
|
LOG(("Creating HttpChannelChild @%x\n", this));
|
2009-08-18 19:05:15 +00: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 18:55:33 +00:00
|
|
|
LOG(("Destroying HttpChannelChild @%x\n", this));
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::nsISupports
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2010-04-23 14:19:33 +00:00
|
|
|
// Override nsHashPropertyBag's AddRef: we don't need thread-safe refcnt
|
|
|
|
NS_IMPL_ADDREF(HttpChannelChild)
|
2010-08-13 08:06:40 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP_(nsrefcnt) HttpChannelChild::Release()
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(0 != mRefCnt, "dup release");
|
|
|
|
NS_ASSERT_OWNINGTHREAD(HttpChannelChild);
|
|
|
|
--mRefCnt;
|
|
|
|
NS_LOG_RELEASE(this, mRefCnt, "HttpChannelChild");
|
|
|
|
|
|
|
|
if (mRefCnt == 1 && mKeptAlive && mIPCOpen) {
|
|
|
|
mKeptAlive = false;
|
|
|
|
// 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 18:55:33 +00: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-24 06:55:19 +00: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 18:55:33 +00: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-11 03:11:57 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIAsyncVerifyRedirectCallback)
|
2010-08-13 08:06:40 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIAssociatedContentSecurity, GetAssociatedContentSecurity())
|
2010-04-07 08:43:09 +00: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 18:55:33 +00:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::PHttpChannelChild
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2010-06-27 16:44:15 +00: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-08-06 04:59:37 +00:00
|
|
|
void
|
|
|
|
HttpChannelChild::FlushEventQueue()
|
|
|
|
{
|
|
|
|
NS_ABORT_IF_FALSE(mQueuePhase != PHASE_UNQUEUED,
|
|
|
|
"Queue flushing should not occur if PHASE_UNQUEUED");
|
|
|
|
|
2010-08-11 03:07:09 +00:00
|
|
|
// Queue already being flushed, or the channel's suspended.
|
|
|
|
if (mQueuePhase != PHASE_FINISHED_QUEUEING || mSuspendCount)
|
2010-08-06 04:59:37 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (mEventQueue.Length() > 0) {
|
|
|
|
// It is possible for new callbacks to be enqueued as we are
|
|
|
|
// flushing the queue, so the queue must not be cleared until
|
|
|
|
// all callbacks have run.
|
|
|
|
mQueuePhase = PHASE_FLUSHING;
|
|
|
|
|
2010-08-11 03:07:09 +00:00
|
|
|
nsRefPtr<HttpChannelChild> kungFuDeathGrip(this);
|
|
|
|
PRUint32 i;
|
|
|
|
for (i = 0; i < mEventQueue.Length(); i++) {
|
2010-08-06 04:59:37 +00:00
|
|
|
mEventQueue[i]->Run();
|
2010-08-11 03:07:09 +00:00
|
|
|
// If the callback ended up suspending us, abort all further flushing.
|
|
|
|
if (mSuspendCount)
|
|
|
|
break;
|
2010-08-06 04:59:37 +00:00
|
|
|
}
|
2010-08-11 03:07:09 +00:00
|
|
|
// We will always want to remove at least one finished callback.
|
|
|
|
if (i < mEventQueue.Length())
|
|
|
|
i++;
|
|
|
|
|
|
|
|
mEventQueue.RemoveElementsAt(0, i);
|
2010-08-06 04:59:37 +00:00
|
|
|
}
|
|
|
|
|
2010-08-11 03:07:09 +00:00
|
|
|
if (mSuspendCount)
|
|
|
|
mQueuePhase = PHASE_QUEUEING;
|
|
|
|
else
|
|
|
|
mQueuePhase = PHASE_UNQUEUED;
|
2010-08-06 04:59:37 +00:00
|
|
|
}
|
|
|
|
|
2010-09-20 18:37:13 +00:00
|
|
|
class StartRequestEvent : public ChannelEvent
|
2010-08-06 04:59:37 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
StartRequestEvent(HttpChannelChild* child,
|
|
|
|
const nsHttpResponseHead& responseHead,
|
|
|
|
const PRBool& useResponseHead,
|
2010-10-02 04:17:23 +00:00
|
|
|
const RequestHeaderTuples& requestHeaders,
|
2010-08-06 04:59:37 +00:00
|
|
|
const PRBool& isFromCache,
|
|
|
|
const PRBool& cacheEntryAvailable,
|
|
|
|
const PRUint32& cacheExpirationTime,
|
2010-08-13 08:06:40 +00:00
|
|
|
const nsCString& cachedCharset,
|
|
|
|
const nsCString& securityInfoSerialization)
|
2010-08-06 04:59:37 +00:00
|
|
|
: mChild(child)
|
|
|
|
, mResponseHead(responseHead)
|
2010-10-02 04:17:23 +00:00
|
|
|
, mRequestHeaders(requestHeaders)
|
2010-08-06 04:59:37 +00:00
|
|
|
, mUseResponseHead(useResponseHead)
|
|
|
|
, mIsFromCache(isFromCache)
|
|
|
|
, mCacheEntryAvailable(cacheEntryAvailable)
|
|
|
|
, mCacheExpirationTime(cacheExpirationTime)
|
|
|
|
, mCachedCharset(cachedCharset)
|
2010-08-13 08:06:40 +00:00
|
|
|
, mSecurityInfoSerialization(securityInfoSerialization)
|
2010-08-06 04:59:37 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
void Run()
|
|
|
|
{
|
2010-10-02 04:17:23 +00:00
|
|
|
mChild->OnStartRequest(mResponseHead, mUseResponseHead, mRequestHeaders,
|
|
|
|
mIsFromCache, mCacheEntryAvailable,
|
|
|
|
mCacheExpirationTime, mCachedCharset,
|
|
|
|
mSecurityInfoSerialization);
|
2010-08-06 04:59:37 +00:00
|
|
|
}
|
|
|
|
private:
|
|
|
|
HttpChannelChild* mChild;
|
|
|
|
nsHttpResponseHead mResponseHead;
|
2010-10-02 04:17:23 +00:00
|
|
|
RequestHeaderTuples mRequestHeaders;
|
|
|
|
PRPackedBool mUseResponseHead;
|
|
|
|
PRPackedBool mIsFromCache;
|
|
|
|
PRPackedBool mCacheEntryAvailable;
|
2010-08-06 04:59:37 +00:00
|
|
|
PRUint32 mCacheExpirationTime;
|
|
|
|
nsCString mCachedCharset;
|
2010-08-13 08:06:40 +00:00
|
|
|
nsCString mSecurityInfoSerialization;
|
2010-08-06 04:59:37 +00: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 18:55:33 +00:00
|
|
|
bool
|
2010-06-18 10:32:00 +00:00
|
|
|
HttpChannelChild::RecvOnStartRequest(const nsHttpResponseHead& responseHead,
|
2010-06-24 06:55:19 +00:00
|
|
|
const PRBool& useResponseHead,
|
2010-10-02 04:17:23 +00:00
|
|
|
const RequestHeaderTuples& requestHeaders,
|
2010-06-24 06:55:19 +00:00
|
|
|
const PRBool& isFromCache,
|
|
|
|
const PRBool& cacheEntryAvailable,
|
|
|
|
const PRUint32& cacheExpirationTime,
|
2010-08-13 08:06:40 +00:00
|
|
|
const nsCString& cachedCharset,
|
|
|
|
const nsCString& securityInfoSerialization)
|
2010-08-06 04:59:37 +00:00
|
|
|
{
|
|
|
|
if (ShouldEnqueue()) {
|
|
|
|
EnqueueEvent(new StartRequestEvent(this, responseHead, useResponseHead,
|
2010-10-02 04:17:23 +00:00
|
|
|
requestHeaders,
|
2010-08-06 04:59:37 +00:00
|
|
|
isFromCache, cacheEntryAvailable,
|
2010-08-13 08:06:40 +00:00
|
|
|
cacheExpirationTime, cachedCharset,
|
|
|
|
securityInfoSerialization));
|
2010-08-06 04:59:37 +00:00
|
|
|
} else {
|
2010-10-02 04:17:23 +00:00
|
|
|
OnStartRequest(responseHead, useResponseHead, requestHeaders, isFromCache,
|
2010-08-13 08:06:40 +00:00
|
|
|
cacheEntryAvailable, cacheExpirationTime, cachedCharset,
|
|
|
|
securityInfoSerialization);
|
2010-08-06 04:59:37 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
HttpChannelChild::OnStartRequest(const nsHttpResponseHead& responseHead,
|
|
|
|
const PRBool& useResponseHead,
|
2010-10-02 04:17:23 +00:00
|
|
|
const RequestHeaderTuples& requestHeaders,
|
2010-08-06 04:59:37 +00:00
|
|
|
const PRBool& isFromCache,
|
|
|
|
const PRBool& cacheEntryAvailable,
|
|
|
|
const PRUint32& cacheExpirationTime,
|
2010-08-13 08:06:40 +00: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 18:55:33 +00:00
|
|
|
{
|
|
|
|
LOG(("HttpChannelChild::RecvOnStartRequest [this=%x]\n", this));
|
|
|
|
|
2010-08-12 09:05:16 +00:00
|
|
|
if (useResponseHead && !mCanceled)
|
2010-06-18 10:32:00 +00:00
|
|
|
mResponseHead = new nsHttpResponseHead(responseHead);
|
2010-08-13 08:06:40 +00:00
|
|
|
|
|
|
|
if (!securityInfoSerialization.IsEmpty()) {
|
|
|
|
NS_DeserializeObject(securityInfoSerialization,
|
|
|
|
getter_AddRefs(mSecurityInfo));
|
|
|
|
}
|
2010-06-18 10:32:00 +00:00
|
|
|
|
2010-06-24 06:55:19 +00: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 18:55:33 +00:00
|
|
|
|
2010-08-06 04:59:37 +00:00
|
|
|
AutoEventEnqueuer ensureSerialDispatch(this);
|
|
|
|
|
2010-10-02 04:17:23 +00: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 08:43:09 +00:00
|
|
|
nsresult rv = mListener->OnStartRequest(this, mListenerContext);
|
2010-09-15 22:55:08 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
2010-08-12 09:05:16 +00:00
|
|
|
Cancel(rv);
|
2010-09-15 22:55:08 +00:00
|
|
|
return;
|
2010-04-21 03:16:50 +00:00
|
|
|
}
|
2010-09-15 22:55:08 +00: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 18:55:33 +00:00
|
|
|
}
|
|
|
|
|
2010-09-20 18:37:13 +00:00
|
|
|
class DataAvailableEvent : public ChannelEvent
|
2010-04-21 03:16:50 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
DataAvailableEvent(HttpChannelChild* child,
|
|
|
|
const nsCString& data,
|
|
|
|
const PRUint32& offset,
|
|
|
|
const PRUint32& count)
|
|
|
|
: mChild(child)
|
|
|
|
, mData(data)
|
|
|
|
, mOffset(offset)
|
|
|
|
, mCount(count) {}
|
|
|
|
|
2010-08-06 04:59:37 +00:00
|
|
|
void Run() { mChild->OnDataAvailable(mData, mOffset, mCount); }
|
2010-04-21 03:16:50 +00: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 18:55:33 +00:00
|
|
|
bool
|
|
|
|
HttpChannelChild::RecvOnDataAvailable(const nsCString& data,
|
|
|
|
const PRUint32& offset,
|
|
|
|
const PRUint32& count)
|
2010-04-21 03:16:50 +00:00
|
|
|
{
|
2010-08-06 04:59:37 +00:00
|
|
|
if (ShouldEnqueue()) {
|
|
|
|
EnqueueEvent(new DataAvailableEvent(this, data, offset, count));
|
|
|
|
} else {
|
|
|
|
OnDataAvailable(data, offset, count);
|
|
|
|
}
|
|
|
|
return true;
|
2010-04-21 03:16:50 +00:00
|
|
|
}
|
|
|
|
|
2010-08-06 04:59:37 +00:00
|
|
|
void
|
2010-04-21 03:16:50 +00: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 18:55:33 +00:00
|
|
|
{
|
2010-08-12 09:05:16 +00: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 18:55:33 +00:00
|
|
|
|
2010-08-12 09:05:16 +00: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 18:55:33 +00: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 23:07:10 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
2010-08-12 09:05:16 +00:00
|
|
|
Cancel(rv);
|
2010-08-06 04:59:37 +00: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 18:55:33 +00:00
|
|
|
}
|
2010-08-06 04:59:37 +00:00
|
|
|
|
|
|
|
AutoEventEnqueuer ensureSerialDispatch(this);
|
|
|
|
|
2010-04-07 08:43:09 +00: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 18:55:33 +00:00
|
|
|
stringStream->Close();
|
2010-06-15 23:07:10 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
2010-08-12 09:05:16 +00: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 18:55:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-20 18:37:13 +00:00
|
|
|
class StopRequestEvent : public ChannelEvent
|
2010-04-21 03:16:50 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
StopRequestEvent(HttpChannelChild* child,
|
|
|
|
const nsresult& statusCode)
|
|
|
|
: mChild(child)
|
|
|
|
, mStatusCode(statusCode) {}
|
|
|
|
|
2010-08-06 04:59:37 +00:00
|
|
|
void Run() { mChild->OnStopRequest(mStatusCode); }
|
2010-04-21 03:16:50 +00: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 18:55:33 +00:00
|
|
|
bool
|
|
|
|
HttpChannelChild::RecvOnStopRequest(const nsresult& statusCode)
|
2010-04-21 03:16:50 +00:00
|
|
|
{
|
2010-08-06 04:59:37 +00:00
|
|
|
if (ShouldEnqueue()) {
|
|
|
|
EnqueueEvent(new StopRequestEvent(this, statusCode));
|
|
|
|
} else {
|
|
|
|
OnStopRequest(statusCode);
|
|
|
|
}
|
|
|
|
return true;
|
2010-04-21 03:16:50 +00:00
|
|
|
}
|
|
|
|
|
2010-08-06 04:59:37 +00:00
|
|
|
void
|
2010-04-21 03:16:50 +00: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 18:55:33 +00:00
|
|
|
{
|
2010-08-12 09:05:16 +00: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 18:55:33 +00:00
|
|
|
this, statusCode));
|
|
|
|
|
|
|
|
mIsPending = PR_FALSE;
|
2010-04-23 14:19:33 +00:00
|
|
|
|
2010-08-12 09:05:16 +00:00
|
|
|
if (!mCanceled)
|
|
|
|
mStatus = statusCode;
|
|
|
|
|
|
|
|
{ // We must flush the queue before we Send__delete__
|
|
|
|
// (although we really shouldn't receive any msgs after OnStop),
|
2010-08-06 04:59:37 +00:00
|
|
|
// so make sure this goes out of scope before then.
|
|
|
|
AutoEventEnqueuer ensureSerialDispatch(this);
|
2010-08-12 09:05:16 +00:00
|
|
|
|
2010-08-06 04:59:37 +00:00
|
|
|
mListener->OnStopRequest(this, mListenerContext, statusCode);
|
2010-08-12 09:05:16 +00:00
|
|
|
|
2010-08-06 04:59:37 +00:00
|
|
|
mListener = 0;
|
|
|
|
mListenerContext = 0;
|
|
|
|
mCacheEntryAvailable = PR_FALSE;
|
|
|
|
if (mLoadGroup)
|
|
|
|
mLoadGroup->RemoveRequest(this, nsnull, statusCode);
|
|
|
|
}
|
2010-05-29 00:26:45 +00:00
|
|
|
|
2010-08-13 08:06:40 +00: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;
|
2010-08-17 22:17:00 +00:00
|
|
|
SendDocumentChannelCleanup();
|
2010-08-13 08:06:40 +00: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 18:55:33 +00:00
|
|
|
}
|
|
|
|
|
2010-09-20 18:37:13 +00:00
|
|
|
class ProgressEvent : public ChannelEvent
|
2010-04-21 03:16:50 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
ProgressEvent(HttpChannelChild* child,
|
|
|
|
const PRUint64& progress,
|
|
|
|
const PRUint64& progressMax)
|
|
|
|
: mChild(child)
|
|
|
|
, mProgress(progress)
|
|
|
|
, mProgressMax(progressMax) {}
|
|
|
|
|
2010-08-06 04:59:37 +00:00
|
|
|
void Run() { mChild->OnProgress(mProgress, mProgressMax); }
|
2010-04-21 03:16:50 +00:00
|
|
|
private:
|
|
|
|
HttpChannelChild* mChild;
|
|
|
|
PRUint64 mProgress, mProgressMax;
|
|
|
|
};
|
|
|
|
|
2010-05-13 17:28:51 +00:00
|
|
|
bool
|
|
|
|
HttpChannelChild::RecvOnProgress(const PRUint64& progress,
|
|
|
|
const PRUint64& progressMax)
|
2010-04-21 03:16:50 +00:00
|
|
|
{
|
2010-08-06 04:59:37 +00:00
|
|
|
if (ShouldEnqueue()) {
|
|
|
|
EnqueueEvent(new ProgressEvent(this, progress, progressMax));
|
|
|
|
} else {
|
|
|
|
OnProgress(progress, progressMax);
|
|
|
|
}
|
|
|
|
return true;
|
2010-04-21 03:16:50 +00:00
|
|
|
}
|
|
|
|
|
2010-08-06 04:59:37 +00:00
|
|
|
void
|
2010-04-21 03:16:50 +00:00
|
|
|
HttpChannelChild::OnProgress(const PRUint64& progress,
|
|
|
|
const PRUint64& progressMax)
|
2010-05-13 17:28:51 +00:00
|
|
|
{
|
2010-08-12 09:05:16 +00:00
|
|
|
LOG(("HttpChannelChild::OnProgress [this=%p progress=%llu/%llu]\n",
|
2010-05-13 17:28:51 +00:00
|
|
|
this, progress, progressMax));
|
|
|
|
|
2010-08-12 09:05:16 +00:00
|
|
|
if (mCanceled)
|
|
|
|
return;
|
|
|
|
|
2010-05-13 17:28:51 +00:00
|
|
|
// cache the progress sink so we don't have to query for it each time.
|
|
|
|
if (!mProgressSink)
|
|
|
|
GetCallback(mProgressSink);
|
|
|
|
|
2010-08-06 04:59:37 +00:00
|
|
|
AutoEventEnqueuer ensureSerialDispatch(this);
|
|
|
|
|
2010-05-13 17:28:51 +00:00
|
|
|
// block socket status event after Cancel or OnStopRequest has been called.
|
|
|
|
if (mProgressSink && NS_SUCCEEDED(mStatus) && mIsPending &&
|
|
|
|
!(mLoadFlags & LOAD_BACKGROUND))
|
|
|
|
{
|
2010-08-12 09:05:16 +00:00
|
|
|
if (progress > 0) {
|
2010-05-13 17:28:51 +00:00
|
|
|
NS_ASSERTION(progress <= progressMax, "unexpected progress values");
|
|
|
|
mProgressSink->OnProgress(this, nsnull, progress, progressMax);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-20 18:37:13 +00:00
|
|
|
class StatusEvent : public ChannelEvent
|
2010-04-21 03:16:50 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
StatusEvent(HttpChannelChild* child,
|
|
|
|
const nsresult& status,
|
|
|
|
const nsString& statusArg)
|
|
|
|
: mChild(child)
|
|
|
|
, mStatus(status)
|
|
|
|
, mStatusArg(statusArg) {}
|
|
|
|
|
2010-08-06 04:59:37 +00:00
|
|
|
void Run() { mChild->OnStatus(mStatus, mStatusArg); }
|
2010-04-21 03:16:50 +00:00
|
|
|
private:
|
|
|
|
HttpChannelChild* mChild;
|
|
|
|
nsresult mStatus;
|
|
|
|
nsString mStatusArg;
|
|
|
|
};
|
|
|
|
|
2010-05-13 17:28:51 +00:00
|
|
|
bool
|
|
|
|
HttpChannelChild::RecvOnStatus(const nsresult& status,
|
|
|
|
const nsString& statusArg)
|
2010-04-21 03:16:50 +00:00
|
|
|
{
|
2010-08-06 04:59:37 +00:00
|
|
|
if (ShouldEnqueue()) {
|
|
|
|
EnqueueEvent(new StatusEvent(this, status, statusArg));
|
|
|
|
} else {
|
|
|
|
OnStatus(status, statusArg);
|
|
|
|
}
|
|
|
|
return true;
|
2010-04-21 03:16:50 +00:00
|
|
|
}
|
|
|
|
|
2010-08-06 04:59:37 +00:00
|
|
|
void
|
2010-04-21 03:16:50 +00:00
|
|
|
HttpChannelChild::OnStatus(const nsresult& status,
|
|
|
|
const nsString& statusArg)
|
2010-05-13 17:28:51 +00:00
|
|
|
{
|
2010-08-12 09:05:16 +00:00
|
|
|
LOG(("HttpChannelChild::OnStatus [this=%p status=%x]\n", this, status));
|
|
|
|
|
|
|
|
if (mCanceled)
|
|
|
|
return;
|
2010-05-13 17:28:51 +00:00
|
|
|
|
|
|
|
// cache the progress sink so we don't have to query for it each time.
|
|
|
|
if (!mProgressSink)
|
|
|
|
GetCallback(mProgressSink);
|
|
|
|
|
2010-08-06 04:59:37 +00:00
|
|
|
AutoEventEnqueuer ensureSerialDispatch(this);
|
|
|
|
|
2010-05-13 17:28:51 +00: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-21 03:16:50 +00:00
|
|
|
}
|
|
|
|
|
2010-09-20 18:37:13 +00:00
|
|
|
class CancelEvent : public ChannelEvent
|
2010-08-12 09:05:16 +00: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;
|
|
|
|
|
|
|
|
if (mIPCOpen)
|
|
|
|
PHttpChannelChild::Send__delete__(this);
|
|
|
|
}
|
|
|
|
|
2010-09-15 19:26:15 +00: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()
|
|
|
|
{
|
|
|
|
Send__delete__(this);
|
|
|
|
}
|
|
|
|
|
2010-09-20 18:37:13 +00:00
|
|
|
class Redirect1Event : public ChannelEvent
|
2010-08-11 03:11:57 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
Redirect1Event(HttpChannelChild* child,
|
|
|
|
PHttpChannelChild* newChannel,
|
|
|
|
const IPC::URI& newURI,
|
|
|
|
const PRUint32& redirectFlags,
|
|
|
|
const nsHttpResponseHead& responseHead)
|
|
|
|
: mChild(child)
|
|
|
|
, mNewChannel(newChannel)
|
|
|
|
, mNewURI(newURI)
|
|
|
|
, mRedirectFlags(redirectFlags)
|
|
|
|
, mResponseHead(responseHead) {}
|
|
|
|
|
|
|
|
void Run()
|
|
|
|
{
|
|
|
|
mChild->Redirect1Begin(mNewChannel, mNewURI, mRedirectFlags,
|
|
|
|
mResponseHead);
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
HttpChannelChild* mChild;
|
|
|
|
PHttpChannelChild* mNewChannel;
|
|
|
|
IPC::URI mNewURI;
|
|
|
|
PRUint32 mRedirectFlags;
|
|
|
|
nsHttpResponseHead mResponseHead;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool
|
|
|
|
HttpChannelChild::RecvRedirect1Begin(PHttpChannelChild* newChannel,
|
|
|
|
const IPC::URI& newURI,
|
|
|
|
const PRUint32& redirectFlags,
|
|
|
|
const nsHttpResponseHead& responseHead)
|
|
|
|
{
|
|
|
|
if (ShouldEnqueue()) {
|
|
|
|
EnqueueEvent(new Redirect1Event(this, newChannel, newURI, redirectFlags,
|
|
|
|
responseHead));
|
|
|
|
} else {
|
|
|
|
Redirect1Begin(newChannel, newURI, redirectFlags, responseHead);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
HttpChannelChild::Redirect1Begin(PHttpChannelChild* newChannel,
|
|
|
|
const IPC::URI& newURI,
|
|
|
|
const PRUint32& redirectFlags,
|
|
|
|
const nsHttpResponseHead& responseHead)
|
|
|
|
{
|
|
|
|
HttpChannelChild*
|
|
|
|
newHttpChannelChild = static_cast<HttpChannelChild*>(newChannel);
|
|
|
|
nsCOMPtr<nsIURI> uri(newURI);
|
|
|
|
|
|
|
|
nsresult rv =
|
|
|
|
newHttpChannelChild->HttpBaseChannel::Init(uri, mCaps,
|
|
|
|
mConnectionInfo->ProxyInfo());
|
2010-08-12 09:05:16 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
2010-10-09 05:07:49 +00:00
|
|
|
// Veto redirect. nsHttpChannel decides to cancel or continue.
|
2010-10-09 05:07:58 +00:00
|
|
|
SendRedirect2Verify(rv, newHttpChannelChild->mRequestHeaders);
|
2010-08-12 09:05:16 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-08-11 03:11:57 +00:00
|
|
|
|
|
|
|
// We won't get OnStartRequest, set cookies here.
|
|
|
|
mResponseHead = new nsHttpResponseHead(responseHead);
|
|
|
|
SetCookie(mResponseHead->PeekHeader(nsHttp::Set_Cookie));
|
|
|
|
|
|
|
|
PRBool preserveMethod = (mResponseHead->Status() == 307);
|
|
|
|
rv = SetupReplacementChannel(uri, newHttpChannelChild, preserveMethod);
|
2010-08-12 09:05:16 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
2010-10-09 05:07:49 +00:00
|
|
|
// Veto redirect. nsHttpChannel decides to cancel or continue.
|
2010-10-09 05:07:58 +00:00
|
|
|
SendRedirect2Verify(rv, newHttpChannelChild->mRequestHeaders);
|
2010-08-12 09:05:16 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-08-11 03:11:57 +00:00
|
|
|
|
|
|
|
mRedirectChannelChild = newHttpChannelChild;
|
|
|
|
|
2010-08-12 09:05:16 +00:00
|
|
|
rv = gHttpHandler->AsyncOnChannelRedirect(this,
|
|
|
|
newHttpChannelChild,
|
|
|
|
redirectFlags);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
OnRedirectVerifyCallback(rv);
|
2010-08-11 03:11:57 +00:00
|
|
|
}
|
|
|
|
|
2010-09-20 18:37:13 +00:00
|
|
|
class Redirect3Event : public ChannelEvent
|
2010-08-11 03:11:57 +00: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()
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
// Redirecting to new channel: shut this down and init new channel
|
|
|
|
if (mLoadGroup)
|
|
|
|
mLoadGroup->RemoveRequest(this, nsnull, NS_BINDING_ABORTED);
|
|
|
|
|
|
|
|
// Chrome channel has been AsyncOpen'd. Reflect this in child.
|
|
|
|
rv = mRedirectChannelChild->CompleteRedirectSetup(mListener,
|
|
|
|
mListenerContext);
|
|
|
|
if (NS_FAILED(rv))
|
2010-10-09 05:07:49 +00:00
|
|
|
NS_WARNING("CompleteRedirectSetup failed, HttpChannelChild already open?");
|
|
|
|
|
|
|
|
// Release ref to new channel.
|
|
|
|
mRedirectChannelChild = nsnull;
|
2010-08-11 03:11:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
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-09 05:07:49 +00: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-11 03:11:57 +00: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 09:05:16 +00: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-11 03:11:57 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::nsIAsyncVerifyRedirectCallback
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::OnRedirectVerifyCallback(nsresult result)
|
|
|
|
{
|
|
|
|
// Cookies may have been changed by redirect observers
|
|
|
|
mRedirectChannelChild->AddCookiesToRequest();
|
|
|
|
// Must not be called until after redirect observers called.
|
|
|
|
mRedirectChannelChild->SetOriginalURI(mRedirectOriginalURI);
|
|
|
|
|
2010-10-09 05:07:58 +00: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))
|
|
|
|
gHttpHandler->OnModifyRequest(mRedirectChannelChild);
|
|
|
|
|
|
|
|
return SendRedirect2Verify(result, mRedirectChannelChild->mRequestHeaders);
|
2010-08-11 03:11:57 +00: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 18:55:33 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::nsIRequest
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2010-04-07 08:43:09 +00: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 18:55:33 +00:00
|
|
|
{
|
2010-08-12 09:05:16 +00: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-28 01:53:46 +00: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 18:55:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::Suspend()
|
|
|
|
{
|
2010-08-11 03:07:09 +00: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 18:55:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::Resume()
|
|
|
|
{
|
2010-08-11 03:07:09 +00:00
|
|
|
NS_ENSURE_TRUE(mIPCOpen, NS_ERROR_NOT_AVAILABLE);
|
|
|
|
NS_ENSURE_TRUE(mSuspendCount > 0, NS_ERROR_UNEXPECTED);
|
|
|
|
SendResume();
|
|
|
|
mSuspendCount--;
|
2010-09-17 07:23:25 +00: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-11 03:07:09 +00:00
|
|
|
FlushEventQueue();
|
2010-09-17 07:23:25 +00:00
|
|
|
}
|
2010-08-11 03:07:09 +00: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 18:55:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::nsIChannel
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::GetSecurityInfo(nsISupports **aSecurityInfo)
|
|
|
|
{
|
2010-03-28 01:53:46 +00:00
|
|
|
NS_ENSURE_ARG_POINTER(aSecurityInfo);
|
2010-08-13 08:06:40 +00:00
|
|
|
NS_IF_ADDREF(*aSecurityInfo = mSecurityInfo);
|
2010-03-28 01:53:46 +00: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 18:55:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::AsyncOpen(nsIStreamListener *listener, nsISupports *aContext)
|
|
|
|
{
|
|
|
|
LOG(("HttpChannelChild::AsyncOpen [this=%x uri=%s]\n", this, mSpec.get()));
|
|
|
|
|
2010-08-12 09:05:16 +00: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 18:55:33 +00: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-11 05:13:57 +00: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 18:55:33 +00:00
|
|
|
nsresult rv;
|
|
|
|
rv = NS_CheckPortSafety(mURI);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
2010-05-30 22:30:28 +00:00
|
|
|
// Prepare uploadStream for POST data
|
|
|
|
nsCAutoString uploadStreamData;
|
|
|
|
PRInt32 uploadStreamInfo;
|
|
|
|
|
|
|
|
if (mUploadStream) {
|
|
|
|
// Read entire POST stream into string:
|
|
|
|
// This is a temporary measure until bug 564553 is implemented: we're doing
|
|
|
|
// a blocking read of a potentially arbitrarily large stream, so this isn't
|
|
|
|
// performant/safe for large file uploads.
|
|
|
|
PRUint32 bytes;
|
|
|
|
mUploadStream->Available(&bytes);
|
|
|
|
if (bytes > 0) {
|
|
|
|
rv = NS_ReadInputStreamToString(mUploadStream, uploadStreamData, bytes);
|
2010-06-15 23:07:10 +00:00
|
|
|
if (NS_FAILED(rv))
|
2010-05-30 22:30:28 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
uploadStreamInfo = mUploadStreamHasHeaders ?
|
|
|
|
eUploadStream_hasHeaders : eUploadStream_hasNoHeaders;
|
|
|
|
} else {
|
|
|
|
uploadStreamInfo = eUploadStream_null;
|
|
|
|
}
|
|
|
|
|
2010-06-15 23:07:10 +00: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 18:55:33 +00:00
|
|
|
|
2010-05-30 22:30:28 +00:00
|
|
|
//
|
|
|
|
// NOTE: From now on we must return NS_OK; all errors must be handled via
|
|
|
|
// OnStart/OnStopRequest
|
|
|
|
//
|
|
|
|
|
2010-04-11 05:13:57 +00:00
|
|
|
// notify "http-on-modify-request" observers
|
|
|
|
gHttpHandler->OnModifyRequest(this);
|
|
|
|
|
|
|
|
mIsPending = PR_TRUE;
|
|
|
|
mWasOpened = PR_TRUE;
|
2010-04-07 08:43:09 +00:00
|
|
|
mListener = listener;
|
|
|
|
mListenerContext = aContext;
|
|
|
|
|
2010-04-11 05:13:57 +00:00
|
|
|
// add ourselves to the load group.
|
|
|
|
if (mLoadGroup)
|
|
|
|
mLoadGroup->AddRequest(this, nsnull);
|
|
|
|
|
2010-08-12 09:05:16 +00: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-11 05:13:57 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Send request to the chrome process...
|
|
|
|
//
|
|
|
|
|
|
|
|
// FIXME: bug 558623: Combine constructor and SendAsyncOpen into one IPC msg
|
2010-06-18 10:49:28 +00:00
|
|
|
|
|
|
|
mozilla::dom::TabChild* tabChild = nsnull;
|
|
|
|
nsCOMPtr<nsITabChild> iTabChild;
|
|
|
|
GetCallback(iTabChild);
|
|
|
|
if (iTabChild) {
|
|
|
|
tabChild = static_cast<mozilla::dom::TabChild*>(iTabChild.get());
|
|
|
|
}
|
|
|
|
|
2010-08-11 03:11:57 +00: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 16:44:15 +00:00
|
|
|
AddIPDLReference();
|
|
|
|
|
2010-06-18 10:49:28 +00: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 18:55:33 +00:00
|
|
|
|
2010-08-11 03:11:57 +00:00
|
|
|
SendAsyncOpen(IPC::URI(mURI), IPC::URI(mOriginalURI),
|
|
|
|
IPC::URI(mDocumentURI), IPC::URI(mReferrer), mLoadFlags,
|
|
|
|
mRequestHeaders, mRequestHead.Method(), uploadStreamData,
|
|
|
|
uploadStreamInfo, mPriority, mRedirectionLimit,
|
2010-08-11 03:07:09 +00:00
|
|
|
mAllowPipelining, mForceAllowThirdPartyCookie, mSendResumeAt,
|
|
|
|
mStartPos, mEntityID);
|
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 18:55:33 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::nsIHttpChannel
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::SetRequestHeader(const nsACString& aHeader,
|
|
|
|
const nsACString& aValue,
|
|
|
|
PRBool aMerge)
|
|
|
|
{
|
2010-04-07 08:43:09 +00:00
|
|
|
nsresult rv = HttpBaseChannel::SetRequestHeader(aHeader, aValue, aMerge);
|
2010-03-23 15:14:36 +00: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 18:55:33 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::nsIHttpChannelInternal
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::SetupFallbackChannel(const char *aFallbackKey)
|
|
|
|
{
|
|
|
|
DROP_DEAD();
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2010-06-24 06:55:19 +00: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 18:55:33 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2010-06-24 06:55:19 +00: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 18:55:33 +00:00
|
|
|
{
|
2010-06-24 06:55:19 +00: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 18:55:33 +00:00
|
|
|
|
2010-06-24 06:55:19 +00:00
|
|
|
*_retval = mCacheExpirationTime;
|
2010-03-28 01:53:46 +00: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 18:55:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2010-06-24 06:55:19 +00: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 18:55:33 +00:00
|
|
|
{
|
2010-06-24 06:55:19 +00: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 18:55:33 +00:00
|
|
|
|
2010-06-24 06:55:19 +00: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 18:55:33 +00:00
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
2010-06-24 06:55:19 +00: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 18:55:33 +00:00
|
|
|
{
|
2010-06-27 16:44:15 +00:00
|
|
|
if (!mCacheEntryAvailable || !mIPCOpen)
|
2010-06-24 06:55:19 +00: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 18:55:33 +00:00
|
|
|
|
2010-06-24 06:55:19 +00: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 18:55:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2010-03-28 01:53:46 +00: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 18:55:33 +00:00
|
|
|
{
|
2010-03-28 01:53:46 +00:00
|
|
|
if (!mIsPending)
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
2010-06-24 06:55:19 +00:00
|
|
|
*value = mIsFromCache;
|
2010-03-28 01:53:46 +00: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 18:55:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::nsIResumableChannel
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::ResumeAt(PRUint64 startPos, const nsACString& entityID)
|
|
|
|
{
|
2010-08-11 03:07:09 +00: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 18:55:33 +00:00
|
|
|
}
|
|
|
|
|
2010-08-11 03:07:09 +00: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 18:55:33 +00:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::nsISupportsPriority
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::SetPriority(PRInt32 aPriority)
|
|
|
|
{
|
2010-04-11 04:53:35 +00:00
|
|
|
PRInt16 newValue = CLAMP(aPriority, PR_INT16_MIN, PR_INT16_MAX);
|
|
|
|
if (mPriority == newValue)
|
|
|
|
return NS_OK;
|
|
|
|
mPriority = newValue;
|
2010-06-27 16:44:15 +00:00
|
|
|
if (mIPCOpen)
|
2010-04-11 04:53:35 +00: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 18:55:33 +00: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)
|
|
|
|
{
|
|
|
|
DROP_DEAD();
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::SetApplicationCache(nsIApplicationCache *aApplicationCache)
|
|
|
|
{
|
2010-08-11 03:11:57 +00:00
|
|
|
// FIXME: redirects call. so stub OK for now. Fix in bug 536295.
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
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 18:55:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::nsIApplicationCacheChannel
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::GetLoadedFromApplicationCache(PRBool *retval)
|
|
|
|
{
|
2010-03-28 01:53:46 +00:00
|
|
|
// FIXME: stub for bug 536295
|
|
|
|
*retval = 0;
|
|
|
|
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 18:55:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::GetInheritApplicationCache(PRBool *aInheritApplicationCache)
|
|
|
|
{
|
|
|
|
DROP_DEAD();
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::SetInheritApplicationCache(PRBool aInheritApplicationCache)
|
|
|
|
{
|
|
|
|
// FIXME: Browser calls this early, so stub OK for now. Fix in bug 536295.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::GetChooseApplicationCache(PRBool *aChooseApplicationCache)
|
|
|
|
{
|
|
|
|
DROP_DEAD();
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::SetChooseApplicationCache(PRBool aChooseApplicationCache)
|
|
|
|
{
|
|
|
|
// FIXME: Browser calls this early, so stub OK for now. Fix in bug 536295.
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-08-13 08:06:40 +00: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 18:55:33 +00:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2010-08-11 03:11:57 +00:00
|
|
|
|
2009-08-18 19:05:15 +00:00
|
|
|
}} // mozilla::net
|
|
|
|
|