| 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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 | 339 |
| 340 void XMLHttpRequest::setResponseType(const String& responseType, ExceptionState&
exceptionState) | 340 void XMLHttpRequest::setResponseType(const String& responseType, ExceptionState&
exceptionState) |
| 341 { | 341 { |
| 342 if (m_state >= LOADING) { | 342 if (m_state >= LOADING) { |
| 343 exceptionState.throwDOMException(InvalidStateError, "The response type c
annot be set if the object's state is LOADING or DONE."); | 343 exceptionState.throwDOMException(InvalidStateError, "The response type c
annot be set if the object's state is LOADING or DONE."); |
| 344 return; | 344 return; |
| 345 } | 345 } |
| 346 | 346 |
| 347 // Newer functionality is not available to synchronous requests in window co
ntexts, as a spec-mandated | 347 // Newer functionality is not available to synchronous requests in window co
ntexts, as a spec-mandated |
| 348 // attempt to discourage synchronous XHR use. responseType is one such piece
of functionality. | 348 // attempt to discourage synchronous XHR use. responseType is one such piece
of functionality. |
| 349 // We'll only disable this functionality for HTTP(S) requests since sync req
uests for local protocols | 349 if (!m_async && executionContext()->isDocument()) { |
| 350 // such as file: and data: still make sense to allow. | |
| 351 if (!m_async && executionContext()->isDocument() && m_url.protocolIsInHTTPFa
mily()) { | |
| 352 exceptionState.throwDOMException(InvalidAccessError, "The response type
can only be changed for asynchronous HTTP requests made from a document."); | 350 exceptionState.throwDOMException(InvalidAccessError, "The response type
can only be changed for asynchronous HTTP requests made from a document."); |
| 353 return; | 351 return; |
| 354 } | 352 } |
| 355 | 353 |
| 356 if (responseType == "") { | 354 if (responseType == "") { |
| 357 m_responseTypeCode = ResponseTypeDefault; | 355 m_responseTypeCode = ResponseTypeDefault; |
| 358 } else if (responseType == "text") { | 356 } else if (responseType == "text") { |
| 359 m_responseTypeCode = ResponseTypeText; | 357 m_responseTypeCode = ResponseTypeText; |
| 360 } else if (responseType == "json") { | 358 } else if (responseType == "json") { |
| 361 m_responseTypeCode = ResponseTypeJSON; | 359 m_responseTypeCode = ResponseTypeJSON; |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 } | 548 } |
| 551 | 549 |
| 552 if (!async && executionContext()->isDocument()) { | 550 if (!async && executionContext()->isDocument()) { |
| 553 if (document()->settings() && !document()->settings()->syncXHRInDocument
sEnabled()) { | 551 if (document()->settings() && !document()->settings()->syncXHRInDocument
sEnabled()) { |
| 554 exceptionState.throwDOMException(InvalidAccessError, "Synchronous re
quests are disabled for this page."); | 552 exceptionState.throwDOMException(InvalidAccessError, "Synchronous re
quests are disabled for this page."); |
| 555 return; | 553 return; |
| 556 } | 554 } |
| 557 | 555 |
| 558 // Newer functionality is not available to synchronous requests in windo
w contexts, as a spec-mandated | 556 // Newer functionality is not available to synchronous requests in windo
w contexts, as a spec-mandated |
| 559 // attempt to discourage synchronous XHR use. responseType is one such p
iece of functionality. | 557 // attempt to discourage synchronous XHR use. responseType is one such p
iece of functionality. |
| 560 // We'll only disable this functionality for HTTP(S) requests since sync
requests for local protocols | 558 if (m_responseTypeCode != ResponseTypeDefault) { |
| 561 // such as file: and data: still make sense to allow. | 559 exceptionState.throwDOMException(InvalidAccessError, "Synchronous re
quests from a document must not set a response type."); |
| 562 if (url.protocolIsInHTTPFamily() && m_responseTypeCode != ResponseTypeDe
fault) { | |
| 563 exceptionState.throwDOMException(InvalidAccessError, "Synchronous HT
TP requests from a document must not set a response type."); | |
| 564 return; | 560 return; |
| 565 } | 561 } |
| 566 | 562 |
| 567 // Similarly, timeouts are disabled for synchronous requests as well. | 563 // Similarly, timeouts are disabled for synchronous requests as well. |
| 568 if (m_timeoutMilliseconds > 0) { | 564 if (m_timeoutMilliseconds > 0) { |
| 569 exceptionState.throwDOMException(InvalidAccessError, "Synchronous re
quests must not set a timeout."); | 565 exceptionState.throwDOMException(InvalidAccessError, "Synchronous re
quests must not set a timeout."); |
| 570 return; | 566 return; |
| 571 } | 567 } |
| 572 } | 568 } |
| 573 | 569 |
| (...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1393 return ActiveDOMObject::executionContext(); | 1389 return ActiveDOMObject::executionContext(); |
| 1394 } | 1390 } |
| 1395 | 1391 |
| 1396 void XMLHttpRequest::trace(Visitor* visitor) | 1392 void XMLHttpRequest::trace(Visitor* visitor) |
| 1397 { | 1393 { |
| 1398 visitor->trace(m_responseBlob); | 1394 visitor->trace(m_responseBlob); |
| 1399 visitor->trace(m_responseStream); | 1395 visitor->trace(m_responseStream); |
| 1400 } | 1396 } |
| 1401 | 1397 |
| 1402 } // namespace WebCore | 1398 } // namespace WebCore |
| OLD | NEW |