OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org> | 3 * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org> |
4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org> | 4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org> |
5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved. | 5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved. |
6 * Copyright (C) 2012 Intel Corporation | 6 * Copyright (C) 2012 Intel Corporation |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Lesser General Public | 9 * modify it under the terms of the GNU Lesser General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 { | 235 { |
236 if (m_responseTypeCode != ResponseTypeDefault && m_responseTypeCode != Respo
nseTypeDocument) { | 236 if (m_responseTypeCode != ResponseTypeDefault && m_responseTypeCode != Respo
nseTypeDocument) { |
237 exceptionState.throwDOMException(InvalidStateError, "The value is only a
ccessible if the object's 'responseType' is '' or 'document' (was '" + responseT
ype() + "')."); | 237 exceptionState.throwDOMException(InvalidStateError, "The value is only a
ccessible if the object's 'responseType' is '' or 'document' (was '" + responseT
ype() + "')."); |
238 return 0; | 238 return 0; |
239 } | 239 } |
240 | 240 |
241 if (m_error || m_state != DONE) | 241 if (m_error || m_state != DONE) |
242 return 0; | 242 return 0; |
243 | 243 |
244 if (!m_createdDocument) { | 244 if (!m_createdDocument) { |
245 bool isHTML = equalIgnoringCase(responseMIMEType(), "text/html"); | 245 AtomicString mimeType = responseMIMEType(); |
| 246 bool isHTML = equalIgnoringCase(mimeType, "text/html"); |
246 | 247 |
247 // The W3C spec requires the final MIME type to be some valid XML type,
or text/html. | 248 // The W3C spec requires the final MIME type to be some valid XML type,
or text/html. |
248 // If it is text/html, then the responseType of "document" must have bee
n supplied explicitly. | 249 // If it is text/html, then the responseType of "document" must have bee
n supplied explicitly. |
249 if ((m_response.isHTTP() && !responseIsXML() && !isHTML) | 250 if ((m_response.isHTTP() && !responseIsXML() && !isHTML) |
250 || (isHTML && m_responseTypeCode == ResponseTypeDefault) | 251 || (isHTML && m_responseTypeCode == ResponseTypeDefault) |
251 || executionContext()->isWorkerGlobalScope()) { | 252 || executionContext()->isWorkerGlobalScope()) { |
252 m_responseDocument = nullptr; | 253 m_responseDocument = nullptr; |
253 } else { | 254 } else { |
254 DocumentInit init = DocumentInit::fromContext(document()->contextDoc
ument(), m_url); | 255 DocumentInit init = DocumentInit::fromContext(document()->contextDoc
ument(), m_url); |
255 if (isHTML) | 256 if (isHTML) |
256 m_responseDocument = HTMLDocument::create(init); | 257 m_responseDocument = HTMLDocument::create(init); |
257 else | 258 else |
258 m_responseDocument = XMLDocument::create(init); | 259 m_responseDocument = XMLDocument::create(init); |
259 // FIXME: Set Last-Modified. | 260 // FIXME: Set Last-Modified. |
260 m_responseDocument->setContent(m_responseText.flattenToString()); | 261 m_responseDocument->setContent(m_responseText.flattenToString()); |
261 m_responseDocument->setSecurityOrigin(securityOrigin()); | 262 m_responseDocument->setSecurityOrigin(securityOrigin()); |
262 m_responseDocument->setContextFeatures(document()->contextFeatures()
); | 263 m_responseDocument->setContextFeatures(document()->contextFeatures()
); |
| 264 m_responseDocument->setMimeType(mimeType); |
263 if (!m_responseDocument->wellFormed()) | 265 if (!m_responseDocument->wellFormed()) |
264 m_responseDocument = nullptr; | 266 m_responseDocument = nullptr; |
265 } | 267 } |
266 m_createdDocument = true; | 268 m_createdDocument = true; |
267 } | 269 } |
268 | 270 |
269 return m_responseDocument.get(); | 271 return m_responseDocument.get(); |
270 } | 272 } |
271 | 273 |
272 Blob* XMLHttpRequest::responseBlob() | 274 Blob* XMLHttpRequest::responseBlob() |
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1389 return ActiveDOMObject::executionContext(); | 1391 return ActiveDOMObject::executionContext(); |
1390 } | 1392 } |
1391 | 1393 |
1392 void XMLHttpRequest::trace(Visitor* visitor) | 1394 void XMLHttpRequest::trace(Visitor* visitor) |
1393 { | 1395 { |
1394 visitor->trace(m_responseBlob); | 1396 visitor->trace(m_responseBlob); |
1395 visitor->trace(m_responseStream); | 1397 visitor->trace(m_responseStream); |
1396 } | 1398 } |
1397 | 1399 |
1398 } // namespace WebCore | 1400 } // namespace WebCore |
OLD | NEW |