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>
|
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"
|
|
|
|
#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"
|
|
|
|
|
2009-08-18 19:05:15 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace net {
|
|
|
|
|
|
|
|
// C++ file contents
|
|
|
|
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
|
|
|
: mState(HCC_NEW)
|
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)
|
|
|
|
NS_IMPL_RELEASE_WITH_DESTROY(HttpChannelChild, RefcountHitZero())
|
|
|
|
|
|
|
|
void
|
|
|
|
HttpChannelChild::RefcountHitZero()
|
|
|
|
{
|
|
|
|
if (mWasOpened) {
|
|
|
|
// NeckoChild::DeallocPHttpChannel will delete this
|
|
|
|
PHttpChannelChild::Send__delete__(this);
|
|
|
|
} else {
|
|
|
|
delete this; // we never opened IPDL channel
|
|
|
|
}
|
|
|
|
}
|
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)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsICachingChannel)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIUploadChannel)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIUploadChannel2)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIEncodedChannel)
|
|
|
|
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-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
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool
|
2010-03-23 15:14:36 +00:00
|
|
|
HttpChannelChild::RecvOnStartRequest(const nsHttpResponseHead& responseHead)
|
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));
|
|
|
|
|
|
|
|
mState = HCC_ONSTART;
|
|
|
|
|
2010-03-23 15:14:36 +00:00
|
|
|
mResponseHead = new nsHttpResponseHead(responseHead);
|
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-04-07 08:43:09 +00:00
|
|
|
nsresult rv = mListener->OnStartRequest(this, mListenerContext);
|
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
|
|
|
if (!NS_SUCCEEDED(rv)) {
|
|
|
|
// TODO: Cancel request:
|
|
|
|
// - Send Cancel msg to parent
|
|
|
|
// - drop any in flight OnDataAvail msgs we receive
|
|
|
|
// - make sure we do call OnStopRequest eventually
|
|
|
|
// - return true here, not false
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
HttpChannelChild::RecvOnDataAvailable(const nsCString& data,
|
|
|
|
const PRUint32& offset,
|
|
|
|
const PRUint32& count)
|
|
|
|
{
|
|
|
|
LOG(("HttpChannelChild::RecvOnDataAvailable [this=%x]\n", this));
|
|
|
|
|
|
|
|
mState = HCC_ONDATA;
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
if (!NS_SUCCEEDED(rv)) {
|
|
|
|
// TODO: what to do here? Cancel request? Very unlikely to fail.
|
|
|
|
return false;
|
|
|
|
}
|
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();
|
|
|
|
if (!NS_SUCCEEDED(rv)) {
|
|
|
|
// TODO: Cancel request: see notes in OnStartRequest
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
HttpChannelChild::RecvOnStopRequest(const nsresult& statusCode)
|
|
|
|
{
|
|
|
|
LOG(("HttpChannelChild::RecvOnStopRequest [this=%x status=%u]\n",
|
|
|
|
this, statusCode));
|
|
|
|
|
|
|
|
mState = HCC_ONSTOP;
|
|
|
|
|
|
|
|
mIsPending = PR_FALSE;
|
|
|
|
mStatus = statusCode;
|
2010-04-07 08:43:09 +00:00
|
|
|
nsresult rv = mListener->OnStopRequest(this, mListenerContext, statusCode);
|
|
|
|
mListener = 0;
|
|
|
|
mListenerContext = 0;
|
2010-04-23 14:19:33 +00:00
|
|
|
|
|
|
|
// Corresponding AddRef in AsyncOpen().
|
|
|
|
this->Release();
|
|
|
|
|
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
|
|
|
if (!NS_SUCCEEDED(rv)) {
|
|
|
|
// TODO: Cancel request: see notes in OnStartRequest
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// 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-03-28 01:53:46 +00:00
|
|
|
// FIXME: bug 536317
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
DROP_DEAD();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::Resume()
|
|
|
|
{
|
|
|
|
DROP_DEAD();
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::nsIChannel
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::GetSecurityInfo(nsISupports **aSecurityInfo)
|
|
|
|
{
|
2010-03-28 01:53:46 +00:00
|
|
|
// FIXME: Stub for bug 536301 .
|
|
|
|
NS_ENSURE_ARG_POINTER(aSecurityInfo);
|
|
|
|
*aSecurityInfo = 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::AsyncOpen(nsIStreamListener *listener, nsISupports *aContext)
|
|
|
|
{
|
|
|
|
LOG(("HttpChannelChild::AsyncOpen [this=%x uri=%s]\n", this, mSpec.get()));
|
|
|
|
|
|
|
|
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
|
|
|
|
// immediately, as we've done since before e10s.
|
|
|
|
nsresult rv;
|
|
|
|
rv = NS_CheckPortSafety(mURI);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
2010-04-23 14:19:33 +00:00
|
|
|
// The socket transport layer in the chrome process now has a logical ref to
|
|
|
|
// us, until either OnStopRequest or OnRedirect is called.
|
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->AddRef();
|
|
|
|
|
|
|
|
// TODO: Combine constructor and AsyncOpen to save one IPC msg
|
2010-04-11 04:53:35 +00:00
|
|
|
gNeckoChild->SendPHttpChannelConstructor(this);
|
2010-04-07 08:43:09 +00:00
|
|
|
mListener = listener;
|
|
|
|
mListenerContext = aContext;
|
|
|
|
|
|
|
|
// TODO: serialize mConnectionInfo across to the parent, and set it on
|
|
|
|
// the new channel somehow?
|
|
|
|
|
|
|
|
// TODO: serialize mCaps across to the parent, and set it on
|
|
|
|
// the new channel somehow?
|
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
|
|
|
|
|
|
|
// TODO: need to dupe cookies logic from nsHttpChannel.cpp?
|
|
|
|
|
|
|
|
// TODO: need to notify (child-side) http-on-modify-req observers
|
|
|
|
|
|
|
|
// TODO: add self to loadgroup?
|
|
|
|
|
2010-04-26 15:24:21 +00:00
|
|
|
SendAsyncOpen(IPC::URI(mURI), IPC::URI(mOriginalURI), IPC::URI(mDocumentURI),
|
|
|
|
IPC::URI(mReferrer), mLoadFlags, mRequestHeaders,
|
|
|
|
mRequestHead.Method(), mPriority, mRedirectionLimit,
|
|
|
|
mAllowPipelining, mForceAllowThirdPartyCookie);
|
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
|
|
|
|
|
|
|
mIsPending = PR_TRUE;
|
|
|
|
mWasOpened = PR_TRUE;
|
|
|
|
mState = HCC_OPENED;
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::nsICachingChannel
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::GetCacheToken(nsISupports **aCacheToken)
|
|
|
|
{
|
2010-03-28 01:53:46 +00:00
|
|
|
// FIXME: stub for bug 537164
|
|
|
|
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
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::SetCacheToken(nsISupports *aCacheToken)
|
|
|
|
{
|
|
|
|
DROP_DEAD();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::GetOfflineCacheToken(nsISupports **aOfflineCacheToken)
|
|
|
|
{
|
|
|
|
DROP_DEAD();
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::SetOfflineCacheToken(nsISupports *aOfflineCacheToken)
|
|
|
|
{
|
|
|
|
DROP_DEAD();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::GetCacheKey(nsISupports **aCacheKey)
|
|
|
|
{
|
2010-03-28 01:53:46 +00:00
|
|
|
// FIXME: stub for bug 537164
|
|
|
|
NS_ENSURE_ARG_POINTER(aCacheKey);
|
|
|
|
*aCacheKey = 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::SetCacheKey(nsISupports *aCacheKey)
|
|
|
|
{
|
|
|
|
DROP_DEAD();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::GetCacheAsFile(PRBool *aCacheAsFile)
|
|
|
|
{
|
|
|
|
DROP_DEAD();
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::SetCacheAsFile(PRBool aCacheAsFile)
|
|
|
|
{
|
|
|
|
DROP_DEAD();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::GetCacheForOfflineUse(PRBool *aCacheForOfflineUse)
|
|
|
|
{
|
|
|
|
DROP_DEAD();
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::SetCacheForOfflineUse(PRBool aCacheForOfflineUse)
|
|
|
|
{
|
|
|
|
DROP_DEAD();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::GetOfflineCacheClientID(nsACString& id)
|
|
|
|
{
|
|
|
|
DROP_DEAD();
|
|
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::SetOfflineCacheClientID(const nsACString& id)
|
|
|
|
{
|
|
|
|
DROP_DEAD();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::GetCacheFile(nsIFile **aCacheFile)
|
|
|
|
{
|
|
|
|
DROP_DEAD();
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
// FIXME: stub for bug 537164
|
|
|
|
*value = false;
|
|
|
|
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::nsIUploadChannel
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::SetUploadStream(nsIInputStream *aStream,
|
|
|
|
const nsACString& aContentType,
|
|
|
|
PRInt32 aContentLength)
|
|
|
|
{
|
|
|
|
DROP_DEAD();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2010-03-28 01:53:46 +00:00
|
|
|
HttpChannelChild::GetUploadStream(nsIInputStream **stream)
|
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
|
|
|
// FIXME: stub for bug 536273
|
|
|
|
NS_ENSURE_ARG_POINTER(stream);
|
|
|
|
*stream = 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
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::nsIUploadChannel2
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::ExplicitSetUploadStream(nsIInputStream *aStream,
|
|
|
|
const nsACString& aContentType,
|
|
|
|
PRInt64 aContentLength,
|
|
|
|
const nsACString& aMethod,
|
|
|
|
PRBool aStreamHasHeaders)
|
|
|
|
{
|
|
|
|
DROP_DEAD();
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::nsIEncodedChannel
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::GetContentEncodings(nsIUTF8StringEnumerator **result)
|
|
|
|
{
|
|
|
|
DROP_DEAD();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* attribute boolean applyConversion; */
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::GetApplyConversion(PRBool *aApplyConversion)
|
|
|
|
{
|
|
|
|
DROP_DEAD();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::SetApplyConversion(PRBool aApplyConversion)
|
|
|
|
{
|
|
|
|
DROP_DEAD();
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelChild::nsIResumableChannel
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::ResumeAt(PRUint64 startPos, const nsACString& entityID)
|
|
|
|
{
|
|
|
|
DROP_DEAD();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelChild::GetEntityID(nsACString& aEntityID)
|
|
|
|
{
|
|
|
|
DROP_DEAD();
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// 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;
|
|
|
|
if (mWasOpened)
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
DROP_DEAD();
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2009-08-18 19:05:15 +00:00
|
|
|
}} // mozilla::net
|
|
|
|
|