зеркало из https://github.com/mozilla/gecko-dev.git
Bug 88327, XMLHttpRequest.responseText did not support HTTP charset header. r=harishd, sr=jst.
This commit is contained in:
Родитель
bcbbc6ef58
Коммит
0d748850da
|
@ -54,6 +54,7 @@
|
||||||
#include "nsIInterfaceRequestor.h"
|
#include "nsIInterfaceRequestor.h"
|
||||||
#endif
|
#endif
|
||||||
#include "nsIDOMClassInfo.h"
|
#include "nsIDOMClassInfo.h"
|
||||||
|
#include "nsIDOMElement.h"
|
||||||
|
|
||||||
static const char* kLoadAsData = "loadAsData";
|
static const char* kLoadAsData = "loadAsData";
|
||||||
#define LOADSTR NS_LITERAL_STRING("load")
|
#define LOADSTR NS_LITERAL_STRING("load")
|
||||||
|
@ -405,7 +406,7 @@ nsXMLHttpRequest::DetectCharset(nsAWritableString& aCharset)
|
||||||
nsAutoString contentType;
|
nsAutoString contentType;
|
||||||
contentType.AssignWithConversion( contenttypeheader.get() );
|
contentType.AssignWithConversion( contenttypeheader.get() );
|
||||||
PRInt32 start = contentType.RFind("charset=", PR_TRUE ) ;
|
PRInt32 start = contentType.RFind("charset=", PR_TRUE ) ;
|
||||||
if(start<0) {
|
if(start>=0) {
|
||||||
start += 8; // 8 = "charset=".length
|
start += 8; // 8 = "charset=".length
|
||||||
PRInt32 end = 0;
|
PRInt32 end = 0;
|
||||||
if(PRUnichar('"') == contentType.CharAt(start)) {
|
if(PRUnichar('"') == contentType.CharAt(start)) {
|
||||||
|
@ -1147,6 +1148,19 @@ nsresult
|
||||||
nsXMLHttpRequest::Load(nsIDOMEvent* aEvent)
|
nsXMLHttpRequest::Load(nsIDOMEvent* aEvent)
|
||||||
{
|
{
|
||||||
mStatus = XML_HTTP_REQUEST_COMPLETED;
|
mStatus = XML_HTTP_REQUEST_COMPLETED;
|
||||||
|
|
||||||
|
// We might have been sent non-XML data. If that was the case,
|
||||||
|
// we should null out the document member. The idea in this
|
||||||
|
// check here is that if there is no document element it is not
|
||||||
|
// an XML document. We might need a fancier check...
|
||||||
|
if (mDocument) {
|
||||||
|
nsCOMPtr<nsIDOMElement> root;
|
||||||
|
mDocument->GetDocumentElement(getter_AddRefs(root));
|
||||||
|
if (!root) {
|
||||||
|
mDocument = nsnull;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef IMPLEMENT_SYNC_LOAD
|
#ifdef IMPLEMENT_SYNC_LOAD
|
||||||
if (mChromeWindow) {
|
if (mChromeWindow) {
|
||||||
mChromeWindow->ExitModalEventLoop(NS_OK);
|
mChromeWindow->ExitModalEventLoop(NS_OK);
|
||||||
|
@ -1207,6 +1221,7 @@ nsresult
|
||||||
nsXMLHttpRequest::Abort(nsIDOMEvent* aEvent)
|
nsXMLHttpRequest::Abort(nsIDOMEvent* aEvent)
|
||||||
{
|
{
|
||||||
mStatus = XML_HTTP_REQUEST_ABORTED;
|
mStatus = XML_HTTP_REQUEST_ABORTED;
|
||||||
|
mDocument = nsnull;
|
||||||
#ifdef IMPLEMENT_SYNC_LOAD
|
#ifdef IMPLEMENT_SYNC_LOAD
|
||||||
if (mChromeWindow) {
|
if (mChromeWindow) {
|
||||||
mChromeWindow->ExitModalEventLoop(NS_OK);
|
mChromeWindow->ExitModalEventLoop(NS_OK);
|
||||||
|
@ -1221,6 +1236,7 @@ nsresult
|
||||||
nsXMLHttpRequest::Error(nsIDOMEvent* aEvent)
|
nsXMLHttpRequest::Error(nsIDOMEvent* aEvent)
|
||||||
{
|
{
|
||||||
mStatus = XML_HTTP_REQUEST_ABORTED;
|
mStatus = XML_HTTP_REQUEST_ABORTED;
|
||||||
|
mDocument = nsnull;
|
||||||
#ifdef IMPLEMENT_SYNC_LOAD
|
#ifdef IMPLEMENT_SYNC_LOAD
|
||||||
if (mChromeWindow) {
|
if (mChromeWindow) {
|
||||||
mChromeWindow->ExitModalEventLoop(NS_OK);
|
mChromeWindow->ExitModalEventLoop(NS_OK);
|
||||||
|
|
|
@ -94,6 +94,14 @@ protected:
|
||||||
nsresult GetStreamForWString(const PRUnichar* aStr,
|
nsresult GetStreamForWString(const PRUnichar* aStr,
|
||||||
PRInt32 aLength,
|
PRInt32 aLength,
|
||||||
nsIInputStream** aStream);
|
nsIInputStream** aStream);
|
||||||
|
nsresult DetectCharset(nsAWritableString& aCharset);
|
||||||
|
nsresult ConvertBodyToText(PRUnichar **aOutBuffer);
|
||||||
|
static NS_METHOD StreamReaderFunc(nsIInputStream* in,
|
||||||
|
void* closure,
|
||||||
|
const char* fromRawSegment,
|
||||||
|
PRUint32 toOffset,
|
||||||
|
PRUint32 count,
|
||||||
|
PRUint32 *writeCount);
|
||||||
|
|
||||||
nsCOMPtr<nsISupports> mContext;
|
nsCOMPtr<nsISupports> mContext;
|
||||||
nsCOMPtr<nsIHttpChannel> mChannel;
|
nsCOMPtr<nsIHttpChannel> mChannel;
|
||||||
|
@ -111,15 +119,6 @@ protected:
|
||||||
nsCOMPtr<nsIDOMEventListener> mOnLoadListener;
|
nsCOMPtr<nsIDOMEventListener> mOnLoadListener;
|
||||||
nsCOMPtr<nsIDOMEventListener> mOnErrorListener;
|
nsCOMPtr<nsIDOMEventListener> mOnErrorListener;
|
||||||
|
|
||||||
nsresult DetectCharset(nsAWritableString& aCharset);
|
|
||||||
nsresult ConvertBodyToText(PRUnichar **aOutBuffer);
|
|
||||||
static NS_METHOD StreamReaderFunc(nsIInputStream* in,
|
|
||||||
void* closure,
|
|
||||||
const char* fromRawSegment,
|
|
||||||
PRUint32 toOffset,
|
|
||||||
PRUint32 count,
|
|
||||||
PRUint32 *writeCount);
|
|
||||||
|
|
||||||
// used to implement getAllResponseHeaders()
|
// used to implement getAllResponseHeaders()
|
||||||
class nsHeaderVisitor : public nsIHttpHeaderVisitor {
|
class nsHeaderVisitor : public nsIHttpHeaderVisitor {
|
||||||
public:
|
public:
|
||||||
|
|
Загрузка…
Ссылка в новой задаче