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
|
|
|
|
* 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>
|
|
|
|
*
|
|
|
|
* 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"
|
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"
|
2009-08-18 23:05:15 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace net {
|
|
|
|
|
|
|
|
// C++ file contents
|
|
|
|
HttpChannelParent::HttpChannelParent()
|
2010-05-12 06:53:25 +04:00
|
|
|
: mIPCClosed(false)
|
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");
|
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
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2010-05-13 21:28:51 +04:00
|
|
|
NS_IMPL_ISUPPORTS4(HttpChannelParent,
|
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
|
|
|
nsIRequestObserver,
|
|
|
|
nsIStreamListener,
|
2010-05-13 21:28:51 +04:00
|
|
|
nsIInterfaceRequestor,
|
|
|
|
nsIProgressEventSink);
|
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-05-31 02:30:28 +04:00
|
|
|
const nsCString& uploadStreamData,
|
|
|
|
const PRInt32& uploadStreamInfo,
|
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,
|
|
|
|
const PRBool& forceAllowThirdPartyCookie)
|
2009-08-18 23:05:15 +04:00
|
|
|
{
|
2010-04-26 19:24:21 +04:00
|
|
|
nsCOMPtr<nsIURI> uri = aURI;
|
|
|
|
nsCOMPtr<nsIURI> originalUri = aOriginalURI;
|
|
|
|
nsCOMPtr<nsIURI> docUri = aDocURI;
|
|
|
|
nsCOMPtr<nsIURI> referrerUri = aReferrerURI;
|
|
|
|
|
|
|
|
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))
|
2010-05-31 02:30:28 +04:00
|
|
|
return false; // TODO: cancel request (bug 536317), 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-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))
|
2010-05-31 02:30:28 +04:00
|
|
|
return false; // TODO: cancel request (bug 536317), 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-04-23 18:19:33 +04:00
|
|
|
nsHttpChannel *httpChan = static_cast<nsHttpChannel *>(mChannel.get());
|
2010-06-16 03:07:10 +04:00
|
|
|
httpChan->SetRemoteChannel(true);
|
2010-04-07 12:43:09 +04:00
|
|
|
|
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-04-27 03:23:45 +04:00
|
|
|
httpChan->SetNotificationCallbacks(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 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
|
|
|
|
|
|
|
if (uploadStreamInfo != eUploadStream_null) {
|
|
|
|
nsCOMPtr<nsIInputStream> stream;
|
|
|
|
rv = NS_NewPostDataStream(getter_AddRefs(stream), false, uploadStreamData, 0);
|
|
|
|
if (!NS_SUCCEEDED(rv)) {
|
|
|
|
return false; // TODO: cancel request (bug 536317), return true
|
|
|
|
}
|
|
|
|
httpChan->InternalSetUploadStream(stream);
|
|
|
|
// We're casting uploadStreamInfo into PRBool here on purpose because
|
|
|
|
// we know possible values are either 0 or 1. See uploadStreamInfoType.
|
|
|
|
httpChan->SetUploadStreamHasHeaders((PRBool) uploadStreamInfo);
|
|
|
|
}
|
|
|
|
|
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-04-07 12:43:44 +04:00
|
|
|
rv = httpChan->AsyncOpen(this, 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))
|
2010-05-31 02:30:28 +04:00
|
|
|
return false; // TODO: cancel request (bug 536317), 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
|
|
|
|
2009-09-18 03:09:20 +04:00
|
|
|
return true;
|
2009-08-18 23:05:15 +04:00
|
|
|
}
|
|
|
|
|
2010-04-11 08:53:35 +04:00
|
|
|
bool
|
|
|
|
HttpChannelParent::RecvSetPriority(const PRUint16& priority)
|
|
|
|
{
|
2010-04-29 11:02:43 +04:00
|
|
|
nsHttpChannel *httpChan = static_cast<nsHttpChannel *>(mChannel.get());
|
|
|
|
httpChan->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
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelParent::nsIRequestObserver
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
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();
|
|
|
|
NS_ABORT_IF_FALSE(responseHead, "Missing HTTP responseHead!");
|
|
|
|
|
2010-05-12 06:53:25 +04:00
|
|
|
if (mIPCClosed || !SendOnStartRequest(*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 22:55:33 +04:00
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelParent::nsIStreamListener
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelParent::OnDataAvailable(nsIRequest *aRequest,
|
|
|
|
nsISupports *aContext,
|
|
|
|
nsIInputStream *aInputStream,
|
|
|
|
PRUint32 aOffset,
|
|
|
|
PRUint32 aCount)
|
|
|
|
{
|
|
|
|
LOG(("HttpChannelParent::OnDataAvailable [this=%x]\n", this));
|
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
nsCString data;
|
|
|
|
data.SetLength(aCount);
|
|
|
|
char * p = data.BeginWriting();
|
|
|
|
PRUint32 bytesRead;
|
|
|
|
rv = aInputStream->Read(p, aCount, &bytesRead);
|
|
|
|
data.EndWriting();
|
|
|
|
if (!NS_SUCCEEDED(rv) || bytesRead != aCount) {
|
2010-06-10 07:19:28 +04:00
|
|
|
return rv; // TODO: cancel request locally (bug 536317)
|
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-05-12 06:53:25 +04:00
|
|
|
if (mIPCClosed || !SendOnDataAvailable(data, aOffset, bytesRead))
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelParent::nsIInterfaceRequestor
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2010-04-27 03:23:45 +04:00
|
|
|
HttpChannelParent::GetInterface(const nsIID& aIID, void **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
|
|
|
{
|
2010-04-27 03:23:45 +04:00
|
|
|
if (// Known interface calls:
|
|
|
|
|
|
|
|
// FIXME: HTTP Authorization (bug 537782):
|
|
|
|
// nsHttpChannel first tries to get this as an nsIAuthPromptProvider; if that
|
|
|
|
// fails, it tries as an nsIAuthPrompt2, and if that fails, an nsIAuthPrompt.
|
|
|
|
// See nsHttpChannel::GetAuthPrompt(). So if we can return any one of these,
|
|
|
|
// HTTP auth should be all set. The other two if checks can be eventually
|
|
|
|
// deleted.
|
|
|
|
aIID.Equals(NS_GET_IID(nsIAuthPromptProvider)) ||
|
|
|
|
aIID.Equals(NS_GET_IID(nsIAuthPrompt2)) ||
|
|
|
|
aIID.Equals(NS_GET_IID(nsIAuthPrompt)) ||
|
|
|
|
// FIXME: redirects (bug 536294):
|
|
|
|
// The likely solution here is for this class to implement nsIChannelEventSink
|
|
|
|
// and nsIHttpEventSink (and forward calls to any real sinks in the child), in
|
|
|
|
// which case QueryInterface() will do the work here and these if statements
|
|
|
|
// can be eventually discarded.
|
|
|
|
aIID.Equals(NS_GET_IID(nsIChannelEventSink)) ||
|
|
|
|
aIID.Equals(NS_GET_IID(nsIHttpEventSink)) ||
|
|
|
|
// FIXME: application cache (bug 536295):
|
|
|
|
aIID.Equals(NS_GET_IID(nsIApplicationCacheContainer)) ||
|
|
|
|
aIID.Equals(NS_GET_IID(nsIProgressEventSink)) ||
|
|
|
|
// FIXME: bug 561830: when fixed, we shouldn't be asked for this interface
|
2010-06-02 01:52:19 +04:00
|
|
|
aIID.Equals(NS_GET_IID(nsIDocShellTreeItem)) ||
|
|
|
|
// Let this return NS_ERROR_NO_INTERFACE: it's OK to not provide it.
|
|
|
|
aIID.Equals(NS_GET_IID(nsIBadCertListener2)))
|
2010-04-27 03:23:45 +04:00
|
|
|
{
|
|
|
|
return QueryInterface(aIID, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Interface we haven't dealt with yet. Make sure we know by dying.
|
|
|
|
// - use "grep -ri [uuid] ROOT_SRC_DIR" with the uuid from the printf to
|
|
|
|
// find the offending interface.
|
|
|
|
// - FIXME: make non-fatal before we ship
|
|
|
|
printf("*&*&*& HttpChannelParent::GetInterface: uuid=%s not impl'd yet! "
|
|
|
|
"File a bug!\n",
|
|
|
|
aIID.ToString());
|
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
|
|
|
DROP_DEAD();
|
|
|
|
}
|
|
|
|
|
2010-05-13 21:28:51 +04:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// HttpChannelParent::nsIProgressEventSink
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelParent::OnProgress(nsIRequest *aRequest,
|
|
|
|
nsISupports *aContext,
|
|
|
|
PRUint64 aProgress,
|
|
|
|
PRUint64 aProgressMax)
|
|
|
|
{
|
|
|
|
if (mIPCClosed || !SendOnProgress(aProgress, aProgressMax))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
HttpChannelParent::OnStatus(nsIRequest *aRequest,
|
|
|
|
nsISupports *aContext,
|
|
|
|
nsresult aStatus,
|
|
|
|
const PRUnichar *aStatusArg)
|
|
|
|
{
|
|
|
|
if (mIPCClosed || !SendOnStatus(aStatus, nsString(aStatusArg)))
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
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 22:55:33 +04:00
|
|
|
|
2009-08-18 23:05:15 +04:00
|
|
|
}} // mozilla::net
|
|
|
|
|