2009-08-18 23:05:15 +04: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
|
2011-03-22 22:16:33 +03:00
|
|
|
* the Mozilla Foundation.
|
2009-08-18 23:05:15 +04:00
|
|
|
* 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-08-11 07:11:57 +04:00
|
|
|
* Honza Bambas <honzab@firemni.cz>
|
2009-08-18 23:05:15 +04: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 ***** */
|
|
|
|
|
|
|
|
#include "mozilla/net/HttpChannelParent.h"
|
2010-06-18 14:49:28 +04:00
|
|
|
#include "mozilla/dom/TabParent.h"
|
2010-08-11 07:11:57 +04:00
|
|
|
#include "mozilla/net/NeckoParent.h"
|
2010-11-24 01:56:06 +03:00
|
|
|
#include "mozilla/unused.h"
|
2010-08-11 07:11:57 +04:00
|
|
|
#include "HttpChannelParentListener.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 22:55:33 +04:00
|
|
|
#include "nsHttpChannel.h"
|
2010-04-07 12:43:09 +04:00
|
|
|
#include "nsHttpHandler.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 22:55:33 +04:00
|
|
|
#include "nsNetUtil.h"
|
2010-04-11 08:53:35 +04:00
|
|
|
#include "nsISupportsPriority.h"
|
2010-04-27 03:23:45 +04:00
|
|
|
#include "nsIAuthPromptProvider.h"
|
|
|
|
#include "nsIDocShellTreeItem.h"
|
2010-06-02 01:52:19 +04:00
|
|
|
#include "nsIBadCertListener2.h"
|
2010-06-24 10:55:19 +04:00
|
|
|
#include "nsICacheEntryDescriptor.h"
|
2010-08-13 12:06:40 +04:00
|
|
|
#include "nsSerializationHelper.h"
|
|
|
|
#include "nsISerializable.h"
|
|
|
|
#include "nsIAssociatedContentSecurity.h"
|
2010-10-20 21:12:32 +04:00
|
|
|
#include "nsIApplicationCacheService.h"
|
|
|
|
#include "nsIOfflineCacheUpdate.h"
|
2010-11-24 01:56:06 +03:00
|
|
|
#include "nsIRedirectChannelRegistrar.h"
|
2009-08-18 23:05:15 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace net {
|
|
|
|
|
2010-07-19 22:33:33 +04:00
|
|
|
HttpChannelParent::HttpChannelParent(PBrowserParent* iframeEmbedding)
|
2011-04-10 07:42:05 +04:00
|
|
|
: mIPCClosed(false)
|
|
|
|
, mStoredStatus(0)
|
|
|
|
, mStoredProgress(0)
|
|
|
|
, mStoredProgressMax(0)
|
2011-07-05 10:12:32 +04:00
|
|
|
, mHeadersToSyncToChild(nsnull)
|
2009-08-18 23:05:15 +04:00
|
|
|
{
|
2010-04-07 12:43:09 +04:00
|
|
|
// Ensure gHttpHandler is initialized: we need the atom table up and running.
|
|
|
|
nsIHttpProtocolHandler* handler;
|
|
|
|
CallGetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "http", &handler);
|
|
|
|
NS_ASSERTION(handler, "no http handler");
|
2010-06-18 14:49:28 +04:00
|
|
|
|
2011-08-31 01:45:31 +04:00
|
|
|
mTabParent = do_QueryObject(static_cast<TabParent*>(iframeEmbedding));
|
2009-08-18 23:05:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
HttpChannelParent::~HttpChannelParent()
|
|
|
|
{
|
2010-04-26 05:56:51 +04:00
|
|
|
gHttpHandler->Release();
|
2009-08-18 23:05:15 +04:00
|
|
|
}
|
|
|
|
|
2010-05-12 06:53:25 +04:00
|
|
|
void
|
|
|
|
HttpChannelParent::ActorDestroy(ActorDestroyReason why)
|
|
|
|
{
|
|
|
|
// We may still have refcount>0 if nsHttpChannel hasn't called OnStopRequest
|
|
|
|
// yet, but we must not send any more msgs to child.
|
|
|
|
mIPCClosed = true;
|
|
|
|
}
|
|
|
|
|
2009-08-18 23:05:15 +04: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 22:55:33 +04:00
|
|
|
// HttpChannelParent::nsISupports
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2011-07-05 10:12:32 +04:00
|
|
|
NS_IMPL_ISUPPORTS7(HttpChannelParent,
|
2010-11-24 01:56:06 +03:00
|
|
|
nsIInterfaceRequestor,
|
|
|
|
nsIProgressEventSink,
|
|
|
|
nsIRequestObserver,
|
|
|
|
nsIStreamListener,
|
|
|
|
nsIParentChannel,
|
2011-07-05 10:12:32 +04:00
|
|
|
nsIParentRedirectingChannel,
|
|
|
|
nsIHttpHeaderVisitor)
|
2010-11-24 01:56:06 +03:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelParent::nsIInterfaceRequestor
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelParent::GetInterface(const nsIID& aIID, void **result)
|
|
|
|
{
|
|
|
|
if (aIID.Equals(NS_GET_IID(nsIAuthPromptProvider)) ||
|
|
|
|
aIID.Equals(NS_GET_IID(nsISecureBrowserUI))) {
|
|
|
|
if (!mTabParent)
|
|
|
|
return NS_NOINTERFACE;
|
|
|
|
|
|
|
|
return mTabParent->QueryInterface(aIID, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
return QueryInterface(aIID, result);
|
|
|
|
}
|
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 22:55:33 +04:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelParent::PHttpChannelParent
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool
|
2010-04-26 19:24:21 +04:00
|
|
|
HttpChannelParent::RecvAsyncOpen(const IPC::URI& aURI,
|
|
|
|
const IPC::URI& aOriginalURI,
|
|
|
|
const IPC::URI& aDocURI,
|
|
|
|
const IPC::URI& aReferrerURI,
|
2010-03-23 18:14:36 +03:00
|
|
|
const PRUint32& loadFlags,
|
2010-04-07 12:43:09 +04:00
|
|
|
const RequestHeaderTuples& requestHeaders,
|
|
|
|
const nsHttpAtom& requestMethod,
|
2010-10-21 22:36:13 +04:00
|
|
|
const IPC::InputStream& uploadStream,
|
|
|
|
const PRBool& uploadStreamHasHeaders,
|
2010-04-11 08:53:35 +04:00
|
|
|
const PRUint16& priority,
|
2010-04-07 12:43:09 +04:00
|
|
|
const PRUint8& redirectionLimit,
|
|
|
|
const PRBool& allowPipelining,
|
2010-08-11 07:07:09 +04:00
|
|
|
const PRBool& forceAllowThirdPartyCookie,
|
|
|
|
const bool& doResumeAt,
|
|
|
|
const PRUint64& startPos,
|
2010-10-20 21:12:32 +04:00
|
|
|
const nsCString& entityID,
|
|
|
|
const bool& chooseApplicationCache,
|
|
|
|
const nsCString& appCacheClientID)
|
2009-08-18 23:05:15 +04:00
|
|
|
{
|
2010-07-26 23:59:34 +04:00
|
|
|
nsCOMPtr<nsIURI> uri(aURI);
|
|
|
|
nsCOMPtr<nsIURI> originalUri(aOriginalURI);
|
|
|
|
nsCOMPtr<nsIURI> docUri(aDocURI);
|
|
|
|
nsCOMPtr<nsIURI> referrerUri(aReferrerURI);
|
|
|
|
|
2010-04-26 19:24:21 +04:00
|
|
|
nsCString uriSpec;
|
|
|
|
uri->GetSpec(uriSpec);
|
|
|
|
LOG(("HttpChannelParent RecvAsyncOpen [this=%x uri=%s]\n",
|
|
|
|
this, uriSpec.get()));
|
2010-04-07 12:43:09 +04: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 22:55:33 +04:00
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIIOService> ios(do_GetIOService(&rv));
|
|
|
|
if (NS_FAILED(rv))
|
2011-06-12 05:37:03 +04:00
|
|
|
return SendFailedAsyncOpen(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 22:55:33 +04:00
|
|
|
|
2010-04-23 18:19:33 +04:00
|
|
|
rv = NS_NewChannel(getter_AddRefs(mChannel), uri, ios, nsnull, nsnull, loadFlags);
|
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 22:55:33 +04:00
|
|
|
if (NS_FAILED(rv))
|
2011-06-12 05:37:03 +04:00
|
|
|
return SendFailedAsyncOpen(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 22:55:33 +04:00
|
|
|
|
2010-04-23 18:19:33 +04:00
|
|
|
nsHttpChannel *httpChan = static_cast<nsHttpChannel *>(mChannel.get());
|
2010-04-07 12:43:09 +04:00
|
|
|
|
2010-08-11 07:07:09 +04:00
|
|
|
if (doResumeAt)
|
|
|
|
httpChan->ResumeAt(startPos, entityID);
|
|
|
|
|
2010-04-26 19:24:21 +04:00
|
|
|
if (originalUri)
|
|
|
|
httpChan->SetOriginalURI(originalUri);
|
|
|
|
if (docUri)
|
|
|
|
httpChan->SetDocumentURI(docUri);
|
|
|
|
if (referrerUri)
|
|
|
|
httpChan->SetReferrerInternal(referrerUri);
|
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 22:55:33 +04:00
|
|
|
if (loadFlags != nsIRequest::LOAD_NORMAL)
|
2010-04-07 12:43:44 +04:00
|
|
|
httpChan->SetLoadFlags(loadFlags);
|
2010-03-23 18:14:36 +03:00
|
|
|
|
2010-06-16 03:07:10 +04:00
|
|
|
for (PRUint32 i = 0; i < requestHeaders.Length(); i++) {
|
2010-03-23 18:14:36 +03:00
|
|
|
httpChan->SetRequestHeader(requestHeaders[i].mHeader,
|
|
|
|
requestHeaders[i].mValue,
|
|
|
|
requestHeaders[i].mMerge);
|
2010-06-16 03:07:10 +04:00
|
|
|
}
|
2010-03-23 18:14:36 +03:00
|
|
|
|
2010-11-24 01:56:06 +03:00
|
|
|
nsRefPtr<HttpChannelParentListener> channelListener =
|
|
|
|
new HttpChannelParentListener(this);
|
2010-08-11 07:11:57 +04:00
|
|
|
|
2010-11-24 01:56:06 +03:00
|
|
|
httpChan->SetNotificationCallbacks(channelListener);
|
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 22:55:33 +04:00
|
|
|
|
2010-04-07 12:43:09 +04:00
|
|
|
httpChan->SetRequestMethod(nsDependentCString(requestMethod.get()));
|
2010-05-31 02:30:28 +04:00
|
|
|
|
2010-10-21 22:36:13 +04:00
|
|
|
nsCOMPtr<nsIInputStream> stream(uploadStream);
|
|
|
|
if (stream) {
|
2010-05-31 02:30:28 +04:00
|
|
|
httpChan->InternalSetUploadStream(stream);
|
2010-10-21 22:36:13 +04:00
|
|
|
httpChan->SetUploadStreamHasHeaders(uploadStreamHasHeaders);
|
2010-05-31 02:30:28 +04:00
|
|
|
}
|
|
|
|
|
2010-04-11 08:53:35 +04:00
|
|
|
if (priority != nsISupportsPriority::PRIORITY_NORMAL)
|
|
|
|
httpChan->SetPriority(priority);
|
2010-04-07 12:43:09 +04:00
|
|
|
httpChan->SetRedirectionLimit(redirectionLimit);
|
|
|
|
httpChan->SetAllowPipelining(allowPipelining);
|
2010-04-07 12:43:44 +04:00
|
|
|
httpChan->SetForceAllowThirdPartyCookie(forceAllowThirdPartyCookie);
|
2010-04-07 12:43:09 +04:00
|
|
|
|
2010-10-20 21:12:32 +04:00
|
|
|
nsCOMPtr<nsIApplicationCacheChannel> appCacheChan =
|
|
|
|
do_QueryInterface(mChannel);
|
|
|
|
nsCOMPtr<nsIApplicationCacheService> appCacheService =
|
|
|
|
do_GetService(NS_APPLICATIONCACHESERVICE_CONTRACTID);
|
|
|
|
|
|
|
|
PRBool setChooseApplicationCache = chooseApplicationCache;
|
|
|
|
if (appCacheChan && appCacheService) {
|
|
|
|
// We might potentially want to drop this flag (that is TRUE by default)
|
|
|
|
// after we succefully associate the channel with an application cache
|
|
|
|
// reported by the channel child. Dropping it here may be too early.
|
|
|
|
appCacheChan->SetInheritApplicationCache(PR_FALSE);
|
|
|
|
if (!appCacheClientID.IsEmpty()) {
|
|
|
|
nsCOMPtr<nsIApplicationCache> appCache;
|
|
|
|
rv = appCacheService->GetApplicationCache(appCacheClientID,
|
|
|
|
getter_AddRefs(appCache));
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
appCacheChan->SetApplicationCache(appCache);
|
|
|
|
setChooseApplicationCache = PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (setChooseApplicationCache) {
|
|
|
|
nsCOMPtr<nsIOfflineCacheUpdateService> offlineUpdateService =
|
|
|
|
do_GetService("@mozilla.org/offlinecacheupdate-service;1", &rv);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
rv = offlineUpdateService->OfflineAppAllowedForURI(uri,
|
|
|
|
nsnull,
|
|
|
|
&setChooseApplicationCache);
|
|
|
|
|
|
|
|
if (setChooseApplicationCache && NS_SUCCEEDED(rv))
|
|
|
|
appCacheChan->SetChooseApplicationCache(PR_TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-24 01:56:06 +03:00
|
|
|
rv = httpChan->AsyncOpen(channelListener, nsnull);
|
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 22:55:33 +04:00
|
|
|
if (NS_FAILED(rv))
|
2011-06-12 05:37:03 +04:00
|
|
|
return SendFailedAsyncOpen(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 22:55:33 +04:00
|
|
|
|
2009-09-18 03:09:20 +04:00
|
|
|
return true;
|
2009-08-18 23:05:15 +04:00
|
|
|
}
|
|
|
|
|
2010-11-24 01:56:06 +03:00
|
|
|
bool
|
|
|
|
HttpChannelParent::RecvConnectChannel(const PRUint32& channelId)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
LOG(("Looking for a registered channel [this=%p, id=%d]", this, channelId));
|
|
|
|
rv = NS_LinkRedirectChannels(channelId, this, getter_AddRefs(mChannel));
|
|
|
|
LOG((" found channel %p, rv=%08x", mChannel.get(), rv));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-04-11 08:53:35 +04:00
|
|
|
bool
|
|
|
|
HttpChannelParent::RecvSetPriority(const PRUint16& priority)
|
|
|
|
{
|
2011-06-12 05:37:03 +04:00
|
|
|
if (mChannel) {
|
|
|
|
nsHttpChannel *httpChan = static_cast<nsHttpChannel *>(mChannel.get());
|
|
|
|
httpChan->SetPriority(priority);
|
|
|
|
}
|
2010-09-16 00:12:38 +04:00
|
|
|
|
2010-11-24 01:56:06 +03:00
|
|
|
nsCOMPtr<nsISupportsPriority> priorityRedirectChannel =
|
|
|
|
do_QueryInterface(mRedirectChannel);
|
|
|
|
if (priorityRedirectChannel)
|
|
|
|
priorityRedirectChannel->SetPriority(priority);
|
|
|
|
|
2010-04-11 08:53:35 +04:00
|
|
|
return true;
|
|
|
|
}
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 22:55:33 +04:00
|
|
|
|
2010-08-11 07:07:09 +04:00
|
|
|
bool
|
|
|
|
HttpChannelParent::RecvSuspend()
|
|
|
|
{
|
2011-06-12 05:37:03 +04:00
|
|
|
if (mChannel) {
|
|
|
|
mChannel->Suspend();
|
|
|
|
}
|
2010-08-11 07:07:09 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
HttpChannelParent::RecvResume()
|
|
|
|
{
|
2011-06-12 05:37:03 +04:00
|
|
|
if (mChannel) {
|
|
|
|
mChannel->Resume();
|
|
|
|
}
|
2010-08-11 07:07:09 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-12 13:05:16 +04:00
|
|
|
bool
|
|
|
|
HttpChannelParent::RecvCancel(const nsresult& status)
|
|
|
|
{
|
|
|
|
// May receive cancel before channel has been constructed!
|
|
|
|
if (mChannel) {
|
|
|
|
nsHttpChannel *httpChan = static_cast<nsHttpChannel *>(mChannel.get());
|
|
|
|
httpChan->Cancel(status);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-24 10:55:19 +04:00
|
|
|
bool
|
|
|
|
HttpChannelParent::RecvSetCacheTokenCachedCharset(const nsCString& charset)
|
|
|
|
{
|
2011-01-25 01:58:20 +03:00
|
|
|
if (mCacheDescriptor)
|
2011-06-17 00:25:20 +04:00
|
|
|
mCacheDescriptor->SetMetaDataElement("charset", charset.get());
|
2010-06-24 10:55:19 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-13 12:06:40 +04:00
|
|
|
bool
|
|
|
|
HttpChannelParent::RecvUpdateAssociatedContentSecurity(const PRInt32& high,
|
|
|
|
const PRInt32& low,
|
|
|
|
const PRInt32& broken,
|
|
|
|
const PRInt32& no)
|
|
|
|
{
|
|
|
|
nsHttpChannel *chan = static_cast<nsHttpChannel *>(mChannel.get());
|
|
|
|
|
|
|
|
nsCOMPtr<nsISupports> secInfo;
|
|
|
|
chan->GetSecurityInfo(getter_AddRefs(secInfo));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIAssociatedContentSecurity> assoc = do_QueryInterface(secInfo);
|
|
|
|
if (!assoc)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
assoc->SetCountSubRequestsHighSecurity(high);
|
|
|
|
assoc->SetCountSubRequestsLowSecurity(low);
|
|
|
|
assoc->SetCountSubRequestsBrokenSecurity(broken);
|
|
|
|
assoc->SetCountSubRequestsNoSecurity(no);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-11 07:11:57 +04:00
|
|
|
bool
|
2010-10-09 09:07:58 +04:00
|
|
|
HttpChannelParent::RecvRedirect2Verify(const nsresult& result,
|
2010-08-11 07:11:57 +04:00
|
|
|
const RequestHeaderTuples& changedHeaders)
|
|
|
|
{
|
2010-11-24 01:56:06 +03:00
|
|
|
if (NS_SUCCEEDED(result)) {
|
|
|
|
nsCOMPtr<nsIHttpChannel> newHttpChannel =
|
|
|
|
do_QueryInterface(mRedirectChannel);
|
|
|
|
|
|
|
|
if (newHttpChannel) {
|
|
|
|
for (PRUint32 i = 0; i < changedHeaders.Length(); i++) {
|
|
|
|
newHttpChannel->SetRequestHeader(changedHeaders[i].mHeader,
|
|
|
|
changedHeaders[i].mValue,
|
|
|
|
changedHeaders[i].mMerge);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mRedirectCallback->OnRedirectVerifyCallback(result);
|
|
|
|
mRedirectCallback = nsnull;
|
2010-08-11 07:11:57 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-18 02:17:00 +04:00
|
|
|
bool
|
|
|
|
HttpChannelParent::RecvDocumentChannelCleanup()
|
|
|
|
{
|
|
|
|
// We must clear the cache entry here, else we'll block other channels from
|
|
|
|
// reading it if we've got it open for writing.
|
2011-01-25 01:58:20 +03:00
|
|
|
mCacheDescriptor = 0;
|
2010-08-18 02:17:00 +04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-10-20 21:12:32 +04:00
|
|
|
bool
|
|
|
|
HttpChannelParent::RecvMarkOfflineCacheEntryAsForeign()
|
|
|
|
{
|
|
|
|
nsHttpChannel *httpChan = static_cast<nsHttpChannel *>(mChannel.get());
|
|
|
|
httpChan->MarkOfflineCacheEntryAsForeign();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
Bug 530952: Electrolysis HTTP Channel implementation. author=jduell, r=bsmedberg, sr=bz
- Supports only primitive xpcshell HTTP requests which don't set/get HTTP
headers, don't do redirects, observers, load groups, or anything else other
than basic things like looking at the reply body, Content-type, Content-length, etc.
- Tested with network/test/unit_ipc/test_simple_wrap.js (patch @ bug 521922)
- Only used if "NECKO_E10S_HTTP" set in environment.
- Force http.h to get #included before any IPDL files, to centralize #define
handling of LOG and to make sure FORCE_PR_LOGGING is set if needed (bug
545995)
2009-09-22 22:55:33 +04:00
|
|
|
//-----------------------------------------------------------------------------
|
2010-11-24 01:56:06 +03:00
|
|
|
// HttpChannelParent::nsIRequestObserver
|
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 22:55:33 +04:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2010-11-24 01:56:06 +03:00
|
|
|
NS_IMETHODIMP
|
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 22:55:33 +04:00
|
|
|
HttpChannelParent::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext)
|
|
|
|
{
|
|
|
|
LOG(("HttpChannelParent::OnStartRequest [this=%x]\n", this));
|
|
|
|
|
2010-03-23 18:14:36 +03:00
|
|
|
nsHttpChannel *chan = static_cast<nsHttpChannel *>(aRequest);
|
|
|
|
nsHttpResponseHead *responseHead = chan->GetResponseHead();
|
2010-10-02 08:17:23 +04:00
|
|
|
nsHttpRequestHead *requestHead = chan->GetRequestHead();
|
2010-06-24 10:55:19 +04:00
|
|
|
PRBool isFromCache = false;
|
|
|
|
chan->IsFromCache(&isFromCache);
|
2010-08-13 12:06:40 +04:00
|
|
|
PRUint32 expirationTime = nsICache::NO_EXPIRATION_TIME;
|
2010-06-24 10:55:19 +04:00
|
|
|
chan->GetCacheTokenExpirationTime(&expirationTime);
|
|
|
|
nsCString cachedCharset;
|
|
|
|
chan->GetCacheTokenCachedCharset(cachedCharset);
|
|
|
|
|
2010-10-20 21:12:32 +04:00
|
|
|
PRBool loadedFromApplicationCache;
|
|
|
|
chan->GetLoadedFromApplicationCache(&loadedFromApplicationCache);
|
|
|
|
if (loadedFromApplicationCache) {
|
|
|
|
nsCOMPtr<nsIApplicationCache> appCache;
|
|
|
|
chan->GetApplicationCache(getter_AddRefs(appCache));
|
|
|
|
nsCString appCacheGroupId;
|
|
|
|
nsCString appCacheClientId;
|
|
|
|
appCache->GetGroupID(appCacheGroupId);
|
|
|
|
appCache->GetClientID(appCacheClientId);
|
|
|
|
if (mIPCClosed ||
|
|
|
|
!SendAssociateApplicationCache(appCacheGroupId, appCacheClientId))
|
|
|
|
{
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-16 02:55:08 +04:00
|
|
|
nsCOMPtr<nsIEncodedChannel> encodedChannel = do_QueryInterface(aRequest);
|
|
|
|
if (encodedChannel)
|
|
|
|
encodedChannel->SetApplyConversion(PR_FALSE);
|
|
|
|
|
2011-01-25 01:58:20 +03:00
|
|
|
// Keep the cache entry for future use in RecvSetCacheTokenCachedCharset().
|
|
|
|
// It could be already released by nsHttpChannel at that time.
|
|
|
|
chan->GetCacheToken(getter_AddRefs(mCacheDescriptor));
|
2010-06-24 10:55:19 +04:00
|
|
|
|
2010-08-13 12:06:40 +04:00
|
|
|
nsCString secInfoSerialization;
|
|
|
|
nsCOMPtr<nsISupports> secInfoSupp;
|
|
|
|
chan->GetSecurityInfo(getter_AddRefs(secInfoSupp));
|
|
|
|
if (secInfoSupp) {
|
|
|
|
nsCOMPtr<nsISerializable> secInfoSer = do_QueryInterface(secInfoSupp);
|
|
|
|
if (secInfoSer)
|
|
|
|
NS_SerializeToString(secInfoSer, secInfoSerialization);
|
|
|
|
}
|
|
|
|
|
2011-07-05 10:12:32 +04:00
|
|
|
// sync request headers to child, in case they've changed
|
2010-10-02 08:17:23 +04:00
|
|
|
RequestHeaderTuples headers;
|
2011-07-05 10:12:32 +04:00
|
|
|
mHeadersToSyncToChild = &headers;
|
|
|
|
requestHead->Headers().VisitHeaders(this);
|
|
|
|
mHeadersToSyncToChild = 0;
|
2010-10-02 08:17:23 +04:00
|
|
|
|
2011-05-05 19:45:59 +04:00
|
|
|
nsHttpChannel *httpChan = static_cast<nsHttpChannel *>(mChannel.get());
|
2010-06-24 10:55:19 +04:00
|
|
|
if (mIPCClosed ||
|
|
|
|
!SendOnStartRequest(responseHead ? *responseHead : nsHttpResponseHead(),
|
2010-10-02 08:17:23 +04:00
|
|
|
!!responseHead,
|
|
|
|
headers,
|
|
|
|
isFromCache,
|
2011-01-25 01:58:20 +03:00
|
|
|
mCacheDescriptor ? PR_TRUE : PR_FALSE,
|
2011-05-05 19:45:59 +04:00
|
|
|
expirationTime, cachedCharset, secInfoSerialization,
|
|
|
|
httpChan->GetSelfAddr(), httpChan->GetPeerAddr()))
|
2010-08-13 12:06:40 +04: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 22:55:33 +04:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
2010-06-18 14:32:00 +04: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 22:55:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-11-24 01:56:06 +03:00
|
|
|
NS_IMETHODIMP
|
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 22:55:33 +04:00
|
|
|
HttpChannelParent::OnStopRequest(nsIRequest *aRequest,
|
|
|
|
nsISupports *aContext,
|
|
|
|
nsresult aStatusCode)
|
|
|
|
{
|
|
|
|
LOG(("HttpChannelParent::OnStopRequest: [this=%x status=%ul]\n",
|
|
|
|
this, aStatusCode));
|
|
|
|
|
2010-05-12 06:53:25 +04:00
|
|
|
if (mIPCClosed || !SendOnStopRequest(aStatusCode))
|
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 22:55:33 +04:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-11-24 01:56:06 +03:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelParent::nsIStreamListener
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
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 22:55:33 +04:00
|
|
|
HttpChannelParent::OnDataAvailable(nsIRequest *aRequest,
|
|
|
|
nsISupports *aContext,
|
|
|
|
nsIInputStream *aInputStream,
|
|
|
|
PRUint32 aOffset,
|
|
|
|
PRUint32 aCount)
|
|
|
|
{
|
|
|
|
LOG(("HttpChannelParent::OnDataAvailable [this=%x]\n", this));
|
2011-04-10 07:42:05 +04:00
|
|
|
|
2010-08-12 13:12:08 +04:00
|
|
|
nsCString data;
|
|
|
|
nsresult rv = NS_ReadInputStreamToString(aInputStream, data, aCount);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
2011-04-10 07:42:05 +04:00
|
|
|
// OnDataAvailable is always preceded by OnStatus/OnProgress calls that set
|
|
|
|
// mStoredStatus/mStoredProgress(Max) to appropriate values, unless
|
|
|
|
// LOAD_BACKGROUND set. In that case, they'll have garbage values, but
|
|
|
|
// child doesn't use them.
|
|
|
|
if (mIPCClosed || !SendOnTransportAndData(mStoredStatus, mStoredProgress,
|
|
|
|
mStoredProgressMax, data, aOffset,
|
|
|
|
aCount)) {
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
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 22:55:33 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-05-13 21:28:51 +04:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelParent::nsIProgressEventSink
|
|
|
|
//-----------------------------------------------------------------------------
|
2010-08-11 07:11:57 +04:00
|
|
|
|
2010-05-13 21:28:51 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelParent::OnProgress(nsIRequest *aRequest,
|
|
|
|
nsISupports *aContext,
|
|
|
|
PRUint64 aProgress,
|
|
|
|
PRUint64 aProgressMax)
|
|
|
|
{
|
2011-04-10 07:42:05 +04:00
|
|
|
// OnStatus has always just set mStoredStatus. If it indicates this precedes
|
|
|
|
// OnDataAvailable, store and ODA will send to child.
|
|
|
|
if (mStoredStatus == nsISocketTransport::STATUS_RECEIVING_FROM ||
|
|
|
|
mStoredStatus == nsITransport::STATUS_READING)
|
|
|
|
{
|
|
|
|
mStoredProgress = aProgress;
|
|
|
|
mStoredProgressMax = aProgressMax;
|
|
|
|
} else {
|
|
|
|
// Send to child now. The only case I've observed that this handles (i.e.
|
|
|
|
// non-ODA status with progress > 0) is data upload progress notification
|
|
|
|
// (status == nsISocketTransport::STATUS_SENDING_TO)
|
|
|
|
if (mIPCClosed || !SendOnProgress(aProgress, aProgressMax))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
2010-05-13 21:28:51 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelParent::OnStatus(nsIRequest *aRequest,
|
|
|
|
nsISupports *aContext,
|
|
|
|
nsresult aStatus,
|
|
|
|
const PRUnichar *aStatusArg)
|
|
|
|
{
|
2011-04-10 07:42:05 +04:00
|
|
|
// If this precedes OnDataAvailable, store and ODA will send to child.
|
|
|
|
if (aStatus == nsISocketTransport::STATUS_RECEIVING_FROM ||
|
|
|
|
aStatus == nsITransport::STATUS_READING)
|
|
|
|
{
|
|
|
|
mStoredStatus = aStatus;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
// Otherwise, send to child now
|
|
|
|
if (mIPCClosed || !SendOnStatus(aStatus))
|
2010-05-13 21:28:51 +04:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-11-24 01:56:06 +03:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelParent::nsIParentChannel
|
|
|
|
//-----------------------------------------------------------------------------
|
2009-08-18 23:05:15 +04:00
|
|
|
|
2010-11-24 01:56:06 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelParent::Delete()
|
|
|
|
{
|
|
|
|
if (!mIPCClosed)
|
2011-03-22 22:16:33 +03:00
|
|
|
unused << SendDeleteSelf();
|
2010-11-24 01:56:06 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelParent::nsIParentRedirectingChannel
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelParent::StartRedirect(PRUint32 newChannelId,
|
|
|
|
nsIChannel* newChannel,
|
|
|
|
PRUint32 redirectFlags,
|
|
|
|
nsIAsyncVerifyRedirectCallback* callback)
|
|
|
|
{
|
|
|
|
if (mIPCClosed)
|
|
|
|
return NS_BINDING_ABORTED;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> newURI;
|
|
|
|
newChannel->GetURI(getter_AddRefs(newURI));
|
|
|
|
|
|
|
|
nsHttpChannel *httpChan = static_cast<nsHttpChannel *>(mChannel.get());
|
|
|
|
nsHttpResponseHead *responseHead = httpChan->GetResponseHead();
|
|
|
|
bool result = SendRedirect1Begin(newChannelId,
|
|
|
|
IPC::URI(newURI),
|
|
|
|
redirectFlags,
|
|
|
|
responseHead ? *responseHead
|
|
|
|
: nsHttpResponseHead());
|
|
|
|
if (!result)
|
|
|
|
return NS_BINDING_ABORTED;
|
|
|
|
|
|
|
|
// Result is handled in RecvRedirect2Verify above
|
|
|
|
|
|
|
|
mRedirectChannel = newChannel;
|
|
|
|
mRedirectCallback = callback;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelParent::CompleteRedirect(PRBool succeeded)
|
|
|
|
{
|
|
|
|
if (succeeded && !mIPCClosed) {
|
|
|
|
// TODO: check return value: assume child dead if failed
|
|
|
|
unused << SendRedirect3Complete();
|
|
|
|
}
|
|
|
|
|
|
|
|
mRedirectChannel = nsnull;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-07-05 10:12:32 +04:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelParent::nsIHttpHeaderVisitor
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
HttpChannelParent::VisitHeader(const nsACString &header, const nsACString &value)
|
|
|
|
{
|
|
|
|
// Will be set unless some random code QI's us to nsIHttpHeaderVisitor
|
|
|
|
NS_ENSURE_STATE(mHeadersToSyncToChild);
|
|
|
|
|
|
|
|
RequestHeaderTuple* tuple = mHeadersToSyncToChild->AppendElement();
|
|
|
|
tuple->mHeader = header;
|
|
|
|
tuple->mValue = value;
|
|
|
|
tuple->mMerge = false; // headers already merged:
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-11-24 01:56:06 +03:00
|
|
|
}} // mozilla::net
|