зеркало из https://github.com/mozilla/pjs.git
Fixing bug 232493. Paving the way for DOM Level 3 LS. This is mostly cleanup that will make life easier (and safer) when implementing DOM LS. r=caillon@aillon.org, sr=peterv@propagandism.org
This commit is contained in:
Родитель
58b279f51e
Коммит
6e5d1ec469
|
@ -224,7 +224,7 @@ nsPolicyReference::SetupPolicyListener(nsIPolicyListener* aListener)
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsPolicyReference::Load(const char* aURI)
|
||||
nsPolicyReference::Load(const nsACString& aURI)
|
||||
{
|
||||
NS_ASSERTION(aURI, "no uri to load");
|
||||
|
||||
|
@ -240,10 +240,12 @@ nsPolicyReference::Load(const char* aURI)
|
|||
target->AddEventListener(NS_LITERAL_STRING("load"), this, PR_FALSE);
|
||||
}
|
||||
|
||||
result = mXMLHttpRequest->OpenRequest("GET", aURI, PR_TRUE, nsnull, nsnull);
|
||||
const nsAString& empty = EmptyString();
|
||||
result = mXMLHttpRequest->OpenRequest(NS_LITERAL_CSTRING("GET"),
|
||||
aURI, PR_TRUE, empty, empty);
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
mXMLHttpRequest->OverrideMimeType("text/xml");
|
||||
mXMLHttpRequest->OverrideMimeType(NS_LITERAL_CSTRING("text/xml"));
|
||||
|
||||
return mXMLHttpRequest->Send(nsnull);
|
||||
|
||||
|
|
|
@ -1,89 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** 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 the Platform for Privacy Preferences.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Harish Dhurvasula <harishd@netscape.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 ***** */
|
||||
|
||||
#ifndef NS_POLICYREFERENCE_H__
|
||||
#define NS_POLICYREFERENCE_H__
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIXMLHttpRequest.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIPolicyReference.h"
|
||||
#include "nsIPolicyListener.h"
|
||||
#include "nsIPolicyTarget.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
class nsPolicyReference : public nsIPolicyReference,
|
||||
public nsIDOMEventListener,
|
||||
public nsIPolicyTarget,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsPolicyReference();
|
||||
virtual ~nsPolicyReference( );
|
||||
|
||||
// nsIPolicyReference
|
||||
NS_DECL_NSIPOLICYREFERENCE
|
||||
// nsIPolicyReference
|
||||
NS_DECL_NSIPOLICYTARGET
|
||||
// nsIDOMEventListener
|
||||
NS_IMETHOD HandleEvent(nsIDOMEvent *aEvent);
|
||||
|
||||
protected:
|
||||
nsresult Load(const char* aURI);
|
||||
nsresult ProcessPolicyReferenceFile(nsIDOMDocument* aDocument, char** aLocation);
|
||||
nsresult ProcessPolicyRefElement(nsIDOMDocument* aDocument, nsIDOMNodeList* aNodeList, nsAString& aPolicyLocation);
|
||||
nsresult ProcessPolicyRefChildren(nsIDOMNode* aNode);
|
||||
nsresult ProcessExpiryElement(nsIDOMNodeList* aNodeList);
|
||||
|
||||
nsCOMPtr<nsIWeakReference> mListener;
|
||||
nsCOMPtr<nsIXMLHttpRequest> mXMLHttpRequest;
|
||||
nsCOMPtr<nsIDOMDocument> mDocument;
|
||||
nsCOMPtr<nsIURI> mMainURI;
|
||||
nsCOMPtr<nsIURI> mCurrentURI;
|
||||
nsCOMPtr<nsIURI> mLinkedURI;
|
||||
PRUint32 mFlags;
|
||||
PRUint32 mError;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -856,15 +856,15 @@ nsSchemaLoader::Load(const nsAString& schemaURI,
|
|||
return rv;
|
||||
}
|
||||
|
||||
rv = request->OpenRequest("GET",
|
||||
spec.get(),
|
||||
PR_FALSE, nsnull, nsnull);
|
||||
const nsAString& empty = EmptyString();
|
||||
rv = request->OpenRequest(NS_LITERAL_CSTRING("GET"), spec, PR_FALSE, empty,
|
||||
empty);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Force the mimetype of the returned stream to be xml.
|
||||
rv = request->OverrideMimeType("text/xml");
|
||||
rv = request->OverrideMimeType(NS_LITERAL_CSTRING("text/xml"));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -912,15 +912,15 @@ nsSchemaLoader::LoadAsync(const nsAString& schemaURI,
|
|||
return rv;
|
||||
}
|
||||
|
||||
rv = request->OpenRequest("GET",
|
||||
spec.get(),
|
||||
PR_TRUE, nsnull, nsnull);
|
||||
const nsAString& empty = EmptyString();
|
||||
rv = request->OpenRequest(NS_LITERAL_CSTRING("GET"), spec, PR_TRUE, empty,
|
||||
empty);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Force the mimetype of the returned stream to be xml.
|
||||
rv = request->OverrideMimeType("text/xml");
|
||||
rv = request->OverrideMimeType(NS_LITERAL_CSTRING("text/xml"));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -1163,9 +1163,7 @@ nsSchemaLoader::ProcessElement(nsSchema* aSchema,
|
|||
nsSchemaElement* elementInst;
|
||||
const nsAString& empty = EmptyString();
|
||||
|
||||
|
||||
rv = aElement->GetAttributeNS(empty, NS_LITERAL_STRING("name"),
|
||||
value);
|
||||
rv = aElement->GetAttributeNS(empty, NS_LITERAL_STRING("name"), value);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
@ -1190,7 +1188,7 @@ nsSchemaLoader::ProcessElement(nsSchema* aSchema,
|
|||
fixedValue);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
|
||||
elementInst->SetConstraints(defaultValue, fixedValue);
|
||||
|
||||
rv = aElement->GetAttributeNS(empty, NS_LITERAL_STRING("nillable"), value);
|
||||
|
|
|
@ -199,7 +199,7 @@ nsWebScriptsAccess::GetAccessInfoEntry(const char* aKey,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsWebScriptsAccess::GetDocument(const char* aDeclFilePath,
|
||||
nsWebScriptsAccess::GetDocument(const nsACString& aDeclFilePath,
|
||||
nsIDOMDocument** aDocument)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
@ -208,11 +208,13 @@ nsWebScriptsAccess::GetDocument(const char* aDeclFilePath,
|
|||
mRequest = do_CreateInstance(NS_XMLHTTPREQUEST_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
rv = mRequest->OpenRequest("GET", aDeclFilePath, PR_FALSE, nsnull, nsnull);
|
||||
|
||||
const nsAString& empty = EmptyString();
|
||||
rv = mRequest->OpenRequest(NS_LITERAL_CSTRING("GET"), aDeclFilePath,
|
||||
PR_FALSE, empty, empty);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mRequest->OverrideMimeType("text/xml");
|
||||
rv = mRequest->OverrideMimeType(NS_LITERAL_CSTRING("text/xml"));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mRequest->Send(0);
|
||||
|
@ -264,8 +266,8 @@ nsWebScriptsAccess::CreateEntry(const char* aKey,
|
|||
// it. Record the extracted info. for this session
|
||||
nsCOMPtr<nsIDOMDocument> document;
|
||||
nsresult rv =
|
||||
GetDocument(PromiseFlatCString(nsDependentCString(aKey) +
|
||||
NS_LITERAL_CSTRING("web-scripts-access.xml")).get(),
|
||||
GetDocument(nsDependentCString(aKey) +
|
||||
NS_LITERAL_CSTRING("web-scripts-access.xml"),
|
||||
getter_AddRefs(document));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (document) {
|
||||
|
|
|
@ -98,14 +98,20 @@ public:
|
|||
|
||||
protected:
|
||||
nsresult GetAccessInfoEntry(const char* aKey, AccessInfoEntry** aEntry);
|
||||
nsresult GetDocument(const char* aDeclFilePath, nsIDOMDocument** aDocument);
|
||||
nsresult GetDocument(const nsACString& aDeclFilePath,
|
||||
nsIDOMDocument** aDocument);
|
||||
nsresult GetCodebaseURI(nsIURI** aCodebase);
|
||||
nsresult CreateEntry(const char* aKey, const PRBool aIsDelegated, AccessInfoEntry** aEntry);
|
||||
nsresult CreateEntry(nsIDOMDocument* aDocument, const PRBool aIsDelegated, AccessInfoEntry** aAccessInfoEntry);
|
||||
nsresult CreateEntry(nsIDOMNodeList* aAllowList, AccessInfoEntry** aAccessInfoEntry);
|
||||
nsresult CreateEntry(const PRInt32 aFlags, AccessInfoEntry** aAccessInfoEntry);
|
||||
nsresult CreateEntry(const char* aKey, const PRBool aIsDelegated,
|
||||
AccessInfoEntry** aEntry);
|
||||
nsresult CreateEntry(nsIDOMDocument* aDocument, const PRBool aIsDelegated,
|
||||
AccessInfoEntry** aAccessInfoEntry);
|
||||
nsresult CreateEntry(nsIDOMNodeList* aAllowList,
|
||||
AccessInfoEntry** aAccessInfoEntry);
|
||||
nsresult CreateEntry(const PRInt32 aFlags,
|
||||
AccessInfoEntry** aAccessInfoEntry);
|
||||
nsresult CreateDelegatedEntry(AccessInfoEntry** aAccessInfoEntry);
|
||||
nsresult CheckAccess(AccessInfoEntry* aAccessInfoEntry, const nsAString& aRequestType, PRBool* aAccessGranted);
|
||||
nsresult CheckAccess(AccessInfoEntry* aAccessInfoEntry,
|
||||
const nsAString& aRequestType, PRBool* aAccessGranted);
|
||||
nsresult ValidateDocument(nsIDOMDocument* aDocument, PRBool* aIsValid);
|
||||
nsresult IsPublicService(const char* aHost, PRBool* aReturn);
|
||||
|
||||
|
|
|
@ -71,13 +71,12 @@ NS_IMPL_ISUPPORTS1_CI(nsHTTPSOAPTransport, nsISOAPTransport)
|
|||
#define DEBUG_DUMP_DOCUMENT(message,doc) \
|
||||
{ \
|
||||
nsresult rcc;\
|
||||
nsXPIDLString serial;\
|
||||
nsAutoString serial;\
|
||||
nsCOMPtr<nsIDOMSerializer> serializer(do_CreateInstance(NS_XMLSERIALIZER_CONTRACTID, &rcc));\
|
||||
if (NS_FAILED(rcc)) return rcc; \
|
||||
rcc = serializer->SerializeToString(doc, getter_Copies(serial));\
|
||||
rcc = serializer->SerializeToString(doc, serial);\
|
||||
if (NS_FAILED(rcc)) return rcc;\
|
||||
nsAutoString result(serial);\
|
||||
printf(message ":\n%s\n", NS_ConvertUCS2toUTF8(result).get());\
|
||||
printf(message ":\n%s\n", NS_ConvertUTF16toUTF8(serial).get());\
|
||||
}
|
||||
// Availble from the debugger...
|
||||
nsresult DebugPrintDOM(nsIDOMNode * node)
|
||||
|
@ -339,11 +338,14 @@ NS_IMETHODIMP nsHTTPSOAPTransport::SyncCall(nsISOAPCall * aCall, nsISOAPResponse
|
|||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = request->OverrideMimeType("text/xml");
|
||||
rv = request->OverrideMimeType(NS_LITERAL_CSTRING("text/xml"));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
rv = request->OpenRequest("POST", NS_ConvertUCS2toUTF8(uri).get(),
|
||||
PR_FALSE, nsnull, nsnull);
|
||||
|
||||
const nsAString& empty = EmptyString();
|
||||
rv = request->OpenRequest(NS_LITERAL_CSTRING("POST"),
|
||||
NS_ConvertUTF16toUTF8(uri), PR_FALSE, empty,
|
||||
empty);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
|
@ -360,8 +362,8 @@ NS_IMETHODIMP nsHTTPSOAPTransport::SyncCall(nsISOAPCall * aCall, nsISOAPResponse
|
|||
if (action.IsEmpty())
|
||||
action = NS_LITERAL_STRING(" ");
|
||||
|
||||
rv = request->SetRequestHeader("SOAPAction",
|
||||
NS_ConvertUCS2toUTF8(action).get());
|
||||
rv = request->SetRequestHeader(NS_LITERAL_CSTRING("SOAPAction"),
|
||||
NS_ConvertUTF16toUTF8(action));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
@ -547,11 +549,13 @@ NS_IMETHODIMP
|
|||
return SOAP_EXCEPTION(NS_ERROR_NOT_INITIALIZED,"SOAP_TRANSPORT_URI", "No transport URI was specified.");
|
||||
|
||||
DEBUG_DUMP_DOCUMENT("Asynchronous Request", messageDocument)
|
||||
rv = request->OverrideMimeType("text/xml");
|
||||
rv = request->OverrideMimeType(NS_LITERAL_CSTRING("text/xml"));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
rv = request->OpenRequest("POST", NS_ConvertUCS2toUTF8(uri).get(),
|
||||
PR_TRUE, nsnull, nsnull);
|
||||
|
||||
const nsAString& empty = EmptyString();
|
||||
rv = request->OpenRequest(NS_LITERAL_CSTRING("POST"),
|
||||
NS_ConvertUTF16toUTF8(uri), PR_TRUE, empty, empty);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
|
@ -569,8 +573,8 @@ NS_IMETHODIMP
|
|||
if (action.IsEmpty())
|
||||
action = NS_LITERAL_STRING(" ");
|
||||
|
||||
rv = request->SetRequestHeader("SOAPAction",
|
||||
NS_ConvertUCS2toUTF8(action).get());
|
||||
rv = request->SetRequestHeader(NS_LITERAL_CSTRING("SOAPAction"),
|
||||
NS_ConvertUTF16toUTF8(action));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -342,14 +342,16 @@ nsWSDLLoadRequest::LoadDefinition(const nsAString& aURI)
|
|||
return rv;
|
||||
}
|
||||
|
||||
rv = mRequest->OpenRequest("GET", NS_ConvertUCS2toUTF8(aURI).get(), !mIsSync,
|
||||
nsnull, nsnull);
|
||||
const nsAString& empty = EmptyString();
|
||||
rv = mRequest->OpenRequest(NS_LITERAL_CSTRING("GET"),
|
||||
NS_ConvertUTF16toUTF8(aURI), !mIsSync, empty,
|
||||
empty);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Force the mimetype of the returned stream to be xml.
|
||||
rv = mRequest->OverrideMimeType("text/xml");
|
||||
rv = mRequest->OverrideMimeType(NS_LITERAL_CSTRING("text/xml"));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,8 @@ interface nsIDOMNode;
|
|||
*/
|
||||
|
||||
[scriptable, uuid(a6cf9123-15b3-11d2-932e-00805f8add32)]
|
||||
interface nsIDOMSerializer : nsISupports {
|
||||
interface nsIDOMSerializer : nsISupports
|
||||
{
|
||||
/**
|
||||
* The subtree rooted by the specified element is serialized to
|
||||
* a string.
|
||||
|
@ -58,7 +59,7 @@ interface nsIDOMSerializer : nsISupports {
|
|||
* be any node, including a Document.
|
||||
* @returns The serialized subtree in the form of a Unicode string
|
||||
*/
|
||||
wstring serializeToString(in nsIDOMNode root);
|
||||
AString serializeToString(in nsIDOMNode root);
|
||||
|
||||
/**
|
||||
* The subtree rooted by the specified element is serialized to
|
||||
|
@ -69,7 +70,8 @@ interface nsIDOMSerializer : nsISupports {
|
|||
* @param charset The name of the character set to use for the encoding
|
||||
* to a byte stream.
|
||||
*/
|
||||
void serializeToStream(in nsIDOMNode root, in nsIOutputStream stream, in string charset);
|
||||
void serializeToStream(in nsIDOMNode root, in nsIOutputStream stream,
|
||||
in AUTF8String charset);
|
||||
};
|
||||
|
||||
%{ C++
|
||||
|
|
|
@ -73,14 +73,15 @@ interface nsIVariant;
|
|||
* target->AddEventListener(NS_LITERAL_STRING("load"), mylistener,
|
||||
* PR_FALSE)
|
||||
*
|
||||
* where mylistener is your event listener object that implements the
|
||||
* where mylistener is your event listener object that implements the
|
||||
* interface nsIDOMEventListener.
|
||||
*
|
||||
* The 'onload' and 'onerror' attributes moved to nsIJSXMLHttRequest,
|
||||
* but if you're coding in C++ you should avoid using those.
|
||||
*/
|
||||
[scriptable, uuid(b7215e70-4157-11d4-9a42-000064657374)]
|
||||
interface nsIXMLHttpRequest : nsISupports {
|
||||
interface nsIXMLHttpRequest : nsISupports
|
||||
{
|
||||
/**
|
||||
* The request uses a channel in order to perform the
|
||||
* request. This attribute represents the channel used
|
||||
|
@ -93,22 +94,22 @@ interface nsIXMLHttpRequest : nsISupports {
|
|||
|
||||
/**
|
||||
* The response to the request is parsed as if it were a
|
||||
* text/xml stream. This attributes represents the response as
|
||||
* text/xml stream. This attributes represents the response as
|
||||
* a DOM Document object. NULL if the request is unsuccessful or
|
||||
* has not yet been sent.
|
||||
*/
|
||||
readonly attribute nsIDOMDocument responseXML;
|
||||
|
||||
/**
|
||||
* The response to the request as text.
|
||||
* The response to the request as text.
|
||||
* NULL if the request is unsuccessful or
|
||||
* has not yet been sent.
|
||||
*/
|
||||
readonly attribute wstring responseText;
|
||||
readonly attribute AString responseText;
|
||||
|
||||
|
||||
/**
|
||||
* The status of the response to the request for HTTP requests.
|
||||
* The status of the response to the request for HTTP requests.
|
||||
*/
|
||||
readonly attribute unsigned long status;
|
||||
|
||||
|
@ -116,7 +117,7 @@ interface nsIXMLHttpRequest : nsISupports {
|
|||
* The string representing the status of the response for
|
||||
* HTTP requests.
|
||||
*/
|
||||
readonly attribute string statusText;
|
||||
readonly attribute AUTF8String statusText;
|
||||
|
||||
/**
|
||||
* If the request has been sent already, this method will
|
||||
|
@ -127,11 +128,11 @@ interface nsIXMLHttpRequest : nsISupports {
|
|||
/**
|
||||
* Returns all of the response headers as a string for HTTP
|
||||
* requests.
|
||||
*
|
||||
* @returns A string containing all of the response headers.
|
||||
*
|
||||
* @returns A string containing all of the response headers.
|
||||
* NULL if the response has not yet been received.
|
||||
*/
|
||||
string getAllResponseHeaders();
|
||||
string getAllResponseHeaders();
|
||||
|
||||
/**
|
||||
* Returns the text of the header with the specified name for
|
||||
|
@ -142,11 +143,11 @@ interface nsIXMLHttpRequest : nsISupports {
|
|||
* NULL if the response has not yet been received or the
|
||||
* header does not exist in the response.
|
||||
*/
|
||||
string getResponseHeader(in string header);
|
||||
ACString getResponseHeader(in AUTF8String header);
|
||||
|
||||
/**
|
||||
* Native (non-script) method to initialize a request. Note that
|
||||
* the request is not sent until the <code>send</code> method
|
||||
* the request is not sent until the <code>send</code> method
|
||||
* is invoked.
|
||||
*
|
||||
* Will abort currently active loads.
|
||||
|
@ -165,11 +166,11 @@ interface nsIXMLHttpRequest : nsISupports {
|
|||
* @param user A username for authentication if necessary.
|
||||
* @param password A password for authentication if necessary.
|
||||
*/
|
||||
[noscript] void openRequest(in string method,
|
||||
in string url,
|
||||
[noscript] void openRequest(in AUTF8String method,
|
||||
in AUTF8String url,
|
||||
in boolean async,
|
||||
in string user,
|
||||
in string password);
|
||||
in AString user,
|
||||
in AString password);
|
||||
|
||||
/**
|
||||
* Meant to be a script-only method for initializing a request.
|
||||
|
@ -185,18 +186,18 @@ interface nsIXMLHttpRequest : nsISupports {
|
|||
* @param method The HTTP method - either "POST" or "GET". Ignored
|
||||
* if the URL is not a HTTP URL.
|
||||
* @param url The URL to which to send the request.
|
||||
* @param async (optional) Whether the request is synchronous or
|
||||
* asynchronous i.e. whether send returns only after
|
||||
* @param async (optional) Whether the request is synchronous or
|
||||
* asynchronous i.e. whether send returns only after
|
||||
* the response is received or if it returns immediately after
|
||||
* sending the request. In the latter case, notification
|
||||
* of completion is sent through the event listeners.
|
||||
* The default value is true.
|
||||
* @param user (optional) A username for authentication if necessary.
|
||||
* @param user (optional) A username for authentication if necessary.
|
||||
* The default value is the empty string
|
||||
* @param password (optional) A password for authentication if necessary.
|
||||
* The default value is the empty string
|
||||
*/
|
||||
void open(in string method, in string url);
|
||||
void open(in AUTF8String method, in AUTF8String url);
|
||||
|
||||
/**
|
||||
* Sends the request. If the request is asynchronous, returns
|
||||
|
@ -224,7 +225,7 @@ interface nsIXMLHttpRequest : nsISupports {
|
|||
* @param header The name of the header to set in the request.
|
||||
* @param value The body of the header.
|
||||
*/
|
||||
void setRequestHeader(in string header, in string value);
|
||||
void setRequestHeader(in AUTF8String header, in AUTF8String value);
|
||||
|
||||
/**
|
||||
* The state of the request.
|
||||
|
@ -247,7 +248,7 @@ interface nsIXMLHttpRequest : nsISupports {
|
|||
* @param mimetype The type used to override that returned by the server
|
||||
* (if any).
|
||||
*/
|
||||
void overrideMimeType(in string mimetype);
|
||||
void overrideMimeType(in AUTF8String mimetype);
|
||||
};
|
||||
|
||||
|
||||
|
@ -265,7 +266,7 @@ interface nsIJSXMLHttpRequest : nsISupports {
|
|||
/**
|
||||
* Meant to be a script-only mechanism for setting a load event listener.
|
||||
* The attribute is expected to be JavaScript function object. When
|
||||
* the load event occurs, the function is invoked.
|
||||
* the load event occurs, the function is invoked.
|
||||
* This attribute should not be used from native code!!
|
||||
*
|
||||
* After the initial response, all event listeners will be cleared.
|
||||
|
@ -278,7 +279,7 @@ interface nsIJSXMLHttpRequest : nsISupports {
|
|||
/**
|
||||
* Meant to be a script-only mechanism for setting an error event listener.
|
||||
* The attribute is expected to be JavaScript function object. When
|
||||
* the error event occurs, the function is invoked.
|
||||
* the error event occurs, the function is invoked.
|
||||
* This attribute should not be used from native code!!
|
||||
*
|
||||
* After the initial response, all event listeners will be cleared.
|
||||
|
|
|
@ -73,12 +73,15 @@ NS_IMPL_ADDREF(nsDOMSerializer)
|
|||
NS_IMPL_RELEASE(nsDOMSerializer)
|
||||
|
||||
|
||||
static nsresult SetUpEncoder(nsIDOMNode *aRoot, const char* aCharset, nsIDocumentEncoder **aEncoder)
|
||||
static nsresult
|
||||
SetUpEncoder(nsIDOMNode *aRoot, const nsACString& aCharset,
|
||||
nsIDocumentEncoder **aEncoder)
|
||||
{
|
||||
*aEncoder = nsnull;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIDocumentEncoder> encoder(do_CreateInstance(NS_DOC_ENCODER_CONTRACTID_BASE "text/xml",&rv));
|
||||
nsCOMPtr<nsIDocumentEncoder> encoder =
|
||||
do_CreateInstance(NS_DOC_ENCODER_CONTRACTID_BASE "text/xml", &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
|
@ -94,21 +97,21 @@ static nsresult SetUpEncoder(nsIDOMNode *aRoot, const char* aCharset, nsIDocumen
|
|||
}
|
||||
|
||||
// This method will fail if no document
|
||||
rv = encoder->Init(document,NS_LITERAL_STRING("text/xml"),nsIDocumentEncoder::OutputEncodeBasicEntities);
|
||||
rv = encoder->Init(document, NS_LITERAL_STRING("text/xml"),
|
||||
nsIDocumentEncoder::OutputEncodeBasicEntities);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCAutoString charset;
|
||||
if (aCharset) {
|
||||
charset = aCharset;
|
||||
} else {
|
||||
nsCAutoString charset(aCharset);
|
||||
if (charset.IsEmpty()) {
|
||||
charset = document->GetDocumentCharacterSet();
|
||||
}
|
||||
rv = encoder->SetCharset(charset);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// If we are working on the entire document we do not need to specify which part to serialize
|
||||
// If we are working on the entire document we do not need to
|
||||
// specify which part to serialize
|
||||
if (!entireDocument) {
|
||||
rv = encoder->SetNode(aRoot);
|
||||
}
|
||||
|
@ -121,7 +124,8 @@ static nsresult SetUpEncoder(nsIDOMNode *aRoot, const char* aCharset, nsIDocumen
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsresult CheckSameOrigin(nsIDOMNode *aRoot)
|
||||
static nsresult
|
||||
CheckSameOrigin(nsIDOMNode *aRoot)
|
||||
{
|
||||
// Get JSContext from stack.
|
||||
nsCOMPtr<nsIJSContextStack> stack =
|
||||
|
@ -177,38 +181,28 @@ nsresult CheckSameOrigin(nsIDOMNode *aRoot)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMSerializer::SerializeToString(nsIDOMNode *aRoot, PRUnichar **_retval)
|
||||
nsDOMSerializer::SerializeToString(nsIDOMNode *aRoot, nsAString& _retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aRoot);
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
*_retval = nsnull;
|
||||
_retval.Truncate();
|
||||
|
||||
nsresult rv = CheckSameOrigin(aRoot);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIDocumentEncoder> encoder;
|
||||
rv = SetUpEncoder(aRoot, nsnull, getter_AddRefs(encoder));
|
||||
rv = SetUpEncoder(aRoot, EmptyCString(), getter_AddRefs(encoder));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsAutoString str;
|
||||
rv = encoder->EncodeToString(str);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
*_retval = ToNewUnicode(str);
|
||||
if (!*_retval)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return NS_OK;
|
||||
return encoder->EncodeToString(_retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMSerializer::SerializeToStream(nsIDOMNode *aRoot,
|
||||
nsIOutputStream *aStream,
|
||||
const char *aCharset)
|
||||
const nsACString& aCharset)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aRoot);
|
||||
NS_ENSURE_ARG_POINTER(aStream);
|
||||
|
|
|
@ -50,10 +50,7 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMSerializer
|
||||
NS_IMETHOD SerializeToString(nsIDOMNode *root, PRUnichar **_retval);
|
||||
NS_IMETHOD SerializeToStream(nsIDOMNode *root,
|
||||
nsIOutputStream *stream,
|
||||
const char *charset);
|
||||
NS_DECL_NSIDOMSERIALIZER
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -377,15 +377,13 @@ nsXMLHttpRequest::DetectCharset(nsACString& aCharset)
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsXMLHttpRequest::ConvertBodyToText(PRUnichar **aOutBuffer)
|
||||
nsXMLHttpRequest::ConvertBodyToText(nsAString& aOutBuffer)
|
||||
{
|
||||
// This code here is basically a copy of a similar thing in
|
||||
// nsScanner::Append(const char* aBuffer, PRUint32 aLen).
|
||||
// If we get illegal characters in the input we replace
|
||||
// them and don't just fail.
|
||||
|
||||
*aOutBuffer = nsnull;
|
||||
|
||||
PRInt32 dataLen = mResponseBody.Length();
|
||||
if (!dataLen)
|
||||
return NS_OK;
|
||||
|
@ -404,13 +402,13 @@ nsXMLHttpRequest::ConvertBodyToText(PRUnichar **aOutBuffer)
|
|||
}
|
||||
|
||||
if (dataCharset.Equals(NS_LITERAL_CSTRING("ASCII"))) {
|
||||
*aOutBuffer = ToNewUnicode(nsDependentCString(mResponseBody.get(),dataLen));
|
||||
if (!*aOutBuffer)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
CopyASCIItoUTF16(mResponseBody, aOutBuffer);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm(do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID,&rv));
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm =
|
||||
do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
|
@ -464,31 +462,24 @@ nsXMLHttpRequest::ConvertBodyToText(PRUnichar **aOutBuffer)
|
|||
}
|
||||
} while ( NS_FAILED(rv) && (dataLen > 0) );
|
||||
|
||||
outBuffer[totalChars] = '\0';
|
||||
*aOutBuffer = outBuffer;
|
||||
aOutBuffer.Assign(outBuffer, totalChars);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute wstring responseText; */
|
||||
NS_IMETHODIMP nsXMLHttpRequest::GetResponseText(PRUnichar **aResponseText)
|
||||
/* readonly attribute AString responseText; */
|
||||
NS_IMETHODIMP nsXMLHttpRequest::GetResponseText(nsAString& aResponseText)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResponseText);
|
||||
*aResponseText = nsnull;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
aResponseText.Truncate();
|
||||
|
||||
if (mState & (XML_HTTP_REQUEST_COMPLETED |
|
||||
XML_HTTP_REQUEST_INTERACTIVE)) {
|
||||
// First check if we can represent the data as a string - if it contains
|
||||
// nulls we won't try.
|
||||
if (mResponseBody.FindChar('\0') >= 0)
|
||||
return NS_OK;
|
||||
|
||||
nsresult rv = ConvertBodyToText(aResponseText);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
rv = ConvertBodyToText(aResponseText);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* readonly attribute unsigned long status; */
|
||||
|
@ -505,24 +496,21 @@ nsXMLHttpRequest::GetStatus(PRUint32 *aStatus)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute string statusText; */
|
||||
/* readonly attribute AUTF8String statusText; */
|
||||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::GetStatusText(char * *aStatusText)
|
||||
nsXMLHttpRequest::GetStatusText(nsACString& aStatusText)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aStatusText);
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(mChannel));
|
||||
|
||||
*aStatusText = nsnull;
|
||||
aStatusText.Truncate();
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (httpChannel) {
|
||||
nsCAutoString text;
|
||||
nsresult rv = httpChannel->GetResponseStatusText(text);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
*aStatusText = ToNewCString(text);
|
||||
return *aStatusText ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = httpChannel->GetResponseStatusText(aStatusText);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* void abort (); */
|
||||
|
@ -572,24 +560,21 @@ nsXMLHttpRequest::GetAllResponseHeaders(char **_retval)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* string getResponseHeader (in string header); */
|
||||
/* ACString getResponseHeader (in AUTF8String header); */
|
||||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::GetResponseHeader(const char *header, char **_retval)
|
||||
nsXMLHttpRequest::GetResponseHeader(const nsACString& header,
|
||||
nsACString& _retval)
|
||||
{
|
||||
NS_ENSURE_ARG(header);
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(mChannel));
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
_retval.Truncate();
|
||||
|
||||
*_retval = nsnull;
|
||||
if (httpChannel) {
|
||||
nsCAutoString buf;
|
||||
nsresult rv = httpChannel->GetResponseHeader(nsDependentCString(header), buf);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
*_retval = ToNewCString(buf);
|
||||
return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = httpChannel->GetResponseHeader(header, _retval);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -610,25 +595,22 @@ nsXMLHttpRequest::GetLoadGroup(nsILoadGroup **aLoadGroup)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXMLHttpRequest::GetBaseURI(nsIURI **aBaseURI)
|
||||
nsIURI *
|
||||
nsXMLHttpRequest::GetBaseURI()
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aBaseURI);
|
||||
*aBaseURI = nsnull;
|
||||
|
||||
if (!mScriptContext) {
|
||||
mScriptContext = GetCurrentContext();
|
||||
if (!mScriptContext) {
|
||||
return NS_OK;
|
||||
return nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = GetDocumentFromScriptContext(mScriptContext);
|
||||
if (doc) {
|
||||
NS_IF_ADDREF(*aBaseURI = doc->GetBaseURI());
|
||||
if (!doc) {
|
||||
nsnull;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return doc->GetBaseURI();
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -720,16 +702,16 @@ nsXMLHttpRequest::ClearEventListeners()
|
|||
mOnReadystatechangeListener = nsnull;
|
||||
}
|
||||
|
||||
/* noscript void openRequest (in string method, in string url, in boolean async, in string user, in string password); */
|
||||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::OpenRequest(const char *method,
|
||||
const char *url,
|
||||
/* noscript void openRequest (in AUTF8String method, in AUTF8String url, in boolean async, in AString user, in AString password); */
|
||||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::OpenRequest(const nsACString& method,
|
||||
const nsACString& url,
|
||||
PRBool async,
|
||||
const char *user,
|
||||
const char *password)
|
||||
const nsAString& user,
|
||||
const nsAString& password)
|
||||
{
|
||||
NS_ENSURE_ARG(method);
|
||||
NS_ENSURE_ARG(url);
|
||||
NS_ENSURE_ARG(!method.IsEmpty());
|
||||
NS_ENSURE_ARG(!url.IsEmpty());
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
|
@ -760,15 +742,15 @@ nsXMLHttpRequest::OpenRequest(const char *method,
|
|||
mState &= ~XML_HTTP_REQUEST_ASYNC;
|
||||
}
|
||||
|
||||
rv = NS_NewURI(getter_AddRefs(uri), url, mBaseURI);
|
||||
rv = NS_NewURI(getter_AddRefs(uri), url, nsnull, GetBaseURI());
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (user) {
|
||||
if (!user.IsEmpty()) {
|
||||
nsCAutoString userpass;
|
||||
userpass.Assign(user);
|
||||
if (password) {
|
||||
userpass.Append(":");
|
||||
userpass.Append(password);
|
||||
CopyUTF16toUTF8(user, userpass);
|
||||
if (!password.IsEmpty()) {
|
||||
userpass.Append(':');
|
||||
AppendUTF16toUTF8(password, userpass);
|
||||
}
|
||||
uri->SetUserPass(userpass);
|
||||
authp = PR_TRUE;
|
||||
|
@ -790,7 +772,7 @@ nsXMLHttpRequest::OpenRequest(const char *method,
|
|||
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(mChannel));
|
||||
if (httpChannel) {
|
||||
rv = httpChannel->SetRequestMethod(nsDependentCString(method));
|
||||
rv = httpChannel->SetRequestMethod(method);
|
||||
}
|
||||
|
||||
ChangeState(XML_HTTP_REQUEST_OPENED);
|
||||
|
@ -798,16 +780,13 @@ nsXMLHttpRequest::OpenRequest(const char *method,
|
|||
return rv;
|
||||
}
|
||||
|
||||
/* void open (in string method, in string url); */
|
||||
/* void open (in AUTF8String method, in AUTF8String url); */
|
||||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::Open(const char *method, const char *url)
|
||||
nsXMLHttpRequest::Open(const nsACString& method, const nsACString& url)
|
||||
{
|
||||
NS_ENSURE_ARG(url);
|
||||
|
||||
nsresult rv;
|
||||
PRBool async = PR_TRUE;
|
||||
char* user = nsnull;
|
||||
char* password = nsnull;
|
||||
nsAutoString user, password;
|
||||
|
||||
nsCOMPtr<nsIXPCNativeCallContext> cc;
|
||||
nsCOMPtr<nsIXPConnect> xpc(do_GetService(nsIXPConnect::GetCID(), &rv));
|
||||
|
@ -828,10 +807,8 @@ nsXMLHttpRequest::Open(const char *method, const char *url)
|
|||
rv = cc->GetJSContext(&cx);
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
|
||||
GetBaseURI(getter_AddRefs(mBaseURI));
|
||||
|
||||
nsCOMPtr<nsIURI> targetURI;
|
||||
rv = NS_NewURI(getter_AddRefs(targetURI), url, mBaseURI);
|
||||
rv = NS_NewURI(getter_AddRefs(targetURI), url, nsnull, GetBaseURI());
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIScriptSecurityManager> secMan =
|
||||
|
@ -859,23 +836,23 @@ nsXMLHttpRequest::Open(const char *method, const char *url)
|
|||
|
||||
if (argc > 2) {
|
||||
JSBool asyncBool;
|
||||
JS_ValueToBoolean(cx, argv[2], &asyncBool);
|
||||
::JS_ValueToBoolean(cx, argv[2], &asyncBool);
|
||||
async = (PRBool)asyncBool;
|
||||
|
||||
if (argc > 3) {
|
||||
JSString* userStr;
|
||||
JSString* userStr = ::JS_ValueToString(cx, argv[3]);
|
||||
|
||||
userStr = JS_ValueToString(cx, argv[3]);
|
||||
if (userStr) {
|
||||
user = JS_GetStringBytes(userStr);
|
||||
user.Assign((PRUnichar *)::JS_GetStringChars(userStr),
|
||||
::JS_GetStringLength(userStr));
|
||||
}
|
||||
|
||||
if (argc > 4) {
|
||||
JSString* passwordStr;
|
||||
JSString* passwordStr = JS_ValueToString(cx, argv[4]);
|
||||
|
||||
passwordStr = JS_ValueToString(cx, argv[4]);
|
||||
if (passwordStr) {
|
||||
password = JS_GetStringBytes(passwordStr);
|
||||
password.Assign((PRUnichar *)::JS_GetStringChars(passwordStr),
|
||||
::JS_GetStringLength(passwordStr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -968,11 +945,11 @@ nsXMLHttpRequest::GetStreamForWString(const PRUnichar* aStr,
|
|||
*/
|
||||
NS_METHOD
|
||||
nsXMLHttpRequest::StreamReaderFunc(nsIInputStream* in,
|
||||
void* closure,
|
||||
const char* fromRawSegment,
|
||||
PRUint32 toOffset,
|
||||
PRUint32 count,
|
||||
PRUint32 *writeCount)
|
||||
void* closure,
|
||||
const char* fromRawSegment,
|
||||
PRUint32 toOffset,
|
||||
PRUint32 count,
|
||||
PRUint32 *writeCount)
|
||||
{
|
||||
nsXMLHttpRequest* xmlHttpRequest = NS_STATIC_CAST(nsXMLHttpRequest*, closure);
|
||||
if (!xmlHttpRequest || !writeCount) {
|
||||
|
@ -1197,7 +1174,8 @@ nsXMLHttpRequest::Send(nsIVariant *aBody)
|
|||
// if there are no event listeners set and we are doing
|
||||
// an asynchronous call.
|
||||
|
||||
// Ignore argument if method is GET, there is no point in trying to upload anything
|
||||
// Ignore argument if method is GET, there is no point in trying to
|
||||
// upload anything
|
||||
nsCAutoString method;
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(mChannel));
|
||||
|
||||
|
@ -1212,7 +1190,7 @@ nsXMLHttpRequest::Send(nsIVariant *aBody)
|
|||
PRUint16 dataType;
|
||||
rv = aBody->GetDataType(&dataType);
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
return rv;
|
||||
|
||||
switch (dataType) {
|
||||
case nsIDataType::VTYPE_INTERFACE:
|
||||
|
@ -1222,19 +1200,19 @@ nsXMLHttpRequest::Send(nsIVariant *aBody)
|
|||
nsID *iid;
|
||||
rv = aBody->GetAsInterface(&iid, getter_AddRefs(supports));
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
if (iid)
|
||||
return rv;
|
||||
if (iid)
|
||||
nsMemory::Free(iid);
|
||||
|
||||
// document?
|
||||
nsCOMPtr<nsIDOMDocument> doc(do_QueryInterface(supports));
|
||||
if (doc) {
|
||||
nsCOMPtr<nsIDOMSerializer> serializer(do_CreateInstance(NS_XMLSERIALIZER_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
|
||||
rv = serializer->SerializeToString(doc, getter_Copies(serial));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = serializer->SerializeToString(doc, serial);
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
return rv;
|
||||
} else {
|
||||
// nsISupportsString?
|
||||
nsCOMPtr<nsISupportsString> wstr(do_QueryInterface(supports));
|
||||
|
@ -1282,20 +1260,20 @@ nsXMLHttpRequest::Send(nsIVariant *aBody)
|
|||
rv = uploadChannel->SetUploadStream(postDataStream, EmptyCString(), -1);
|
||||
// Reset the method to its original value
|
||||
if (httpChannel) {
|
||||
httpChannel->SetRequestMethod(method);
|
||||
httpChannel->SetRequestMethod(method);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get and initialize a DOMImplementation
|
||||
nsCOMPtr<nsIDOMDOMImplementation> implementation(do_CreateInstance(kIDOMDOMImplementationCID, &rv));
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
|
||||
if (mBaseURI) {
|
||||
nsCOMPtr<nsIPrivateDOMImplementation> privImpl(do_QueryInterface(implementation));
|
||||
if (privImpl) {
|
||||
privImpl->Init(mBaseURI);
|
||||
}
|
||||
nsCOMPtr<nsIDOMDOMImplementation> implementation =
|
||||
do_CreateInstance(kIDOMDOMImplementationCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIPrivateDOMImplementation> privImpl =
|
||||
do_QueryInterface(implementation);
|
||||
if (privImpl) {
|
||||
privImpl->Init(GetBaseURI());
|
||||
}
|
||||
|
||||
// Create an empty document from it (resets current document as well)
|
||||
|
@ -1356,7 +1334,7 @@ nsXMLHttpRequest::Send(nsIVariant *aBody)
|
|||
if (modalEventQueue) {
|
||||
mEventQService->PopThreadEventQueue(modalEventQueue);
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
return rv;
|
||||
}
|
||||
|
||||
// If we're synchronous, spin an event loop here and wait
|
||||
|
@ -1375,20 +1353,23 @@ nsXMLHttpRequest::Send(nsIVariant *aBody)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void setRequestHeader (in string header, in string value); */
|
||||
/* void setRequestHeader (in AUTF8String header, in AUTF8String value); */
|
||||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::SetRequestHeader(const char *header, const char *value)
|
||||
nsXMLHttpRequest::SetRequestHeader(const nsACString& header,
|
||||
const nsACString& value)
|
||||
{
|
||||
if (!mChannel) // open() initializes mChannel, and open()
|
||||
return NS_ERROR_FAILURE; // must be called before first setRequestHeader()
|
||||
|
||||
if (!IsASCII(header) || !IsASCII(value)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(mChannel));
|
||||
|
||||
if (httpChannel) {
|
||||
// We need to set, not add to, the header.
|
||||
return httpChannel->SetRequestHeader(nsDependentCString(header),
|
||||
nsDependentCString(value),
|
||||
PR_FALSE);
|
||||
return httpChannel->SetRequestHeader(header, value, PR_FALSE);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1417,9 +1398,9 @@ nsXMLHttpRequest::GetReadyState(PRInt32 *aState)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void overrideMimeType(in string mimetype); */
|
||||
/* void overrideMimeType(in AUTF8String mimetype); */
|
||||
NS_IMETHODIMP
|
||||
nsXMLHttpRequest::OverrideMimeType(const char* aMimeType)
|
||||
nsXMLHttpRequest::OverrideMimeType(const nsACString& aMimeType)
|
||||
{
|
||||
// XXX Should we do some validation here?
|
||||
mOverrideMimeType.Assign(aMimeType);
|
||||
|
|
Загрузка…
Ссылка в новой задаче