| 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 SecurityOrigin* XMLHttpRequest::securityOrigin() const | 208 SecurityOrigin* XMLHttpRequest::securityOrigin() const |
| 209 { | 209 { |
| 210 return m_securityOrigin ? m_securityOrigin.get() : executionContext()->secur
ityOrigin(); | 210 return m_securityOrigin ? m_securityOrigin.get() : executionContext()->secur
ityOrigin(); |
| 211 } | 211 } |
| 212 | 212 |
| 213 XMLHttpRequest::State XMLHttpRequest::readyState() const | 213 XMLHttpRequest::State XMLHttpRequest::readyState() const |
| 214 { | 214 { |
| 215 return m_state; | 215 return m_state; |
| 216 } | 216 } |
| 217 | 217 |
| 218 ScriptString XMLHttpRequest::responseText(ExceptionState& es) | 218 ScriptString XMLHttpRequest::responseText(ExceptionState& exceptionState) |
| 219 { | 219 { |
| 220 if (m_responseTypeCode != ResponseTypeDefault && m_responseTypeCode != Respo
nseTypeText) { | 220 if (m_responseTypeCode != ResponseTypeDefault && m_responseTypeCode != Respo
nseTypeText) { |
| 221 es.throwDOMException(InvalidStateError, ExceptionMessages::failedToGet("
responseText", "XMLHttpRequest", "the value is only accessible if the object's '
responseType' is '' or 'text' (was '" + responseType() + "').")); | 221 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f
ailedToGet("responseText", "XMLHttpRequest", "the value is only accessible if th
e object's 'responseType' is '' or 'text' (was '" + responseType() + "').")); |
| 222 return ScriptString(); | 222 return ScriptString(); |
| 223 } | 223 } |
| 224 if (m_error || (m_state != LOADING && m_state != DONE)) | 224 if (m_error || (m_state != LOADING && m_state != DONE)) |
| 225 return ScriptString(); | 225 return ScriptString(); |
| 226 return m_responseText; | 226 return m_responseText; |
| 227 } | 227 } |
| 228 | 228 |
| 229 ScriptString XMLHttpRequest::responseJSONSource() | 229 ScriptString XMLHttpRequest::responseJSONSource() |
| 230 { | 230 { |
| 231 ASSERT(m_responseTypeCode == ResponseTypeJSON); | 231 ASSERT(m_responseTypeCode == ResponseTypeJSON); |
| 232 | 232 |
| 233 if (m_error || m_state != DONE) | 233 if (m_error || m_state != DONE) |
| 234 return ScriptString(); | 234 return ScriptString(); |
| 235 return m_responseText; | 235 return m_responseText; |
| 236 } | 236 } |
| 237 | 237 |
| 238 Document* XMLHttpRequest::responseXML(ExceptionState& es) | 238 Document* XMLHttpRequest::responseXML(ExceptionState& exceptionState) |
| 239 { | 239 { |
| 240 if (m_responseTypeCode != ResponseTypeDefault && m_responseTypeCode != Respo
nseTypeDocument) { | 240 if (m_responseTypeCode != ResponseTypeDefault && m_responseTypeCode != Respo
nseTypeDocument) { |
| 241 es.throwDOMException(InvalidStateError, ExceptionMessages::failedToGet("
responseXML", "XMLHttpRequest", "the value is only accessible if the object's 'r
esponseType' is '' or 'document' (was '" + responseType() + "').")); | 241 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f
ailedToGet("responseXML", "XMLHttpRequest", "the value is only accessible if the
object's 'responseType' is '' or 'document' (was '" + responseType() + "').")); |
| 242 return 0; | 242 return 0; |
| 243 } | 243 } |
| 244 | 244 |
| 245 if (m_error || m_state != DONE) | 245 if (m_error || m_state != DONE) |
| 246 return 0; | 246 return 0; |
| 247 | 247 |
| 248 if (!m_createdDocument) { | 248 if (!m_createdDocument) { |
| 249 bool isHTML = equalIgnoringCase(responseMIMEType(), "text/html"); | 249 bool isHTML = equalIgnoringCase(responseMIMEType(), "text/html"); |
| 250 | 250 |
| 251 // The W3C spec requires the final MIME type to be some valid XML type,
or text/html. | 251 // The W3C spec requires the final MIME type to be some valid XML type,
or text/html. |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 Stream* XMLHttpRequest::responseStream() | 328 Stream* XMLHttpRequest::responseStream() |
| 329 { | 329 { |
| 330 ASSERT(m_responseTypeCode == ResponseTypeStream); | 330 ASSERT(m_responseTypeCode == ResponseTypeStream); |
| 331 | 331 |
| 332 if (m_error || (m_state != LOADING && m_state != DONE)) | 332 if (m_error || (m_state != LOADING && m_state != DONE)) |
| 333 return 0; | 333 return 0; |
| 334 | 334 |
| 335 return m_responseStream.get(); | 335 return m_responseStream.get(); |
| 336 } | 336 } |
| 337 | 337 |
| 338 void XMLHttpRequest::setTimeout(unsigned long timeout, ExceptionState& es) | 338 void XMLHttpRequest::setTimeout(unsigned long timeout, ExceptionState& exception
State) |
| 339 { | 339 { |
| 340 // FIXME: Need to trigger or update the timeout Timer here, if needed. http:
//webkit.org/b/98156 | 340 // FIXME: Need to trigger or update the timeout Timer here, if needed. http:
//webkit.org/b/98156 |
| 341 // XHR2 spec, 4.7.3. "This implies that the timeout attribute can be set whi
le fetching is in progress. If that occurs it will still be measured relative to
the start of fetching." | 341 // XHR2 spec, 4.7.3. "This implies that the timeout attribute can be set whi
le fetching is in progress. If that occurs it will still be measured relative to
the start of fetching." |
| 342 if (executionContext()->isDocument() && !m_async) { | 342 if (executionContext()->isDocument() && !m_async) { |
| 343 es.throwDOMException(InvalidAccessError, ExceptionMessages::failedToSet(
"timeout", "XMLHttpRequest", "timeouts cannot be set for synchronous requests ma
de from a document.")); | 343 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
failedToSet("timeout", "XMLHttpRequest", "timeouts cannot be set for synchronous
requests made from a document.")); |
| 344 return; | 344 return; |
| 345 } | 345 } |
| 346 m_timeoutMilliseconds = timeout; | 346 m_timeoutMilliseconds = timeout; |
| 347 } | 347 } |
| 348 | 348 |
| 349 void XMLHttpRequest::setResponseType(const String& responseType, ExceptionState&
es) | 349 void XMLHttpRequest::setResponseType(const String& responseType, ExceptionState&
exceptionState) |
| 350 { | 350 { |
| 351 if (m_state >= LOADING) { | 351 if (m_state >= LOADING) { |
| 352 es.throwDOMException(InvalidStateError, ExceptionMessages::failedToSet("
responseType", "XMLHttpRequest", "the response type cannot be set if the object'
s state is LOADING or DONE.")); | 352 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f
ailedToSet("responseType", "XMLHttpRequest", "the response type cannot be set if
the object's state is LOADING or DONE.")); |
| 353 return; | 353 return; |
| 354 } | 354 } |
| 355 | 355 |
| 356 // Newer functionality is not available to synchronous requests in window co
ntexts, as a spec-mandated | 356 // Newer functionality is not available to synchronous requests in window co
ntexts, as a spec-mandated |
| 357 // attempt to discourage synchronous XHR use. responseType is one such piece
of functionality. | 357 // attempt to discourage synchronous XHR use. responseType is one such piece
of functionality. |
| 358 // We'll only disable this functionality for HTTP(S) requests since sync req
uests for local protocols | 358 // We'll only disable this functionality for HTTP(S) requests since sync req
uests for local protocols |
| 359 // such as file: and data: still make sense to allow. | 359 // such as file: and data: still make sense to allow. |
| 360 if (!m_async && executionContext()->isDocument() && m_url.protocolIsInHTTPFa
mily()) { | 360 if (!m_async && executionContext()->isDocument() && m_url.protocolIsInHTTPFa
mily()) { |
| 361 es.throwDOMException(InvalidAccessError, ExceptionMessages::failedToSet(
"responseType", "XMLHttpRequest", "the response type can only be changed for asy
nchronous HTTP requests made from a document.")); | 361 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::
failedToSet("responseType", "XMLHttpRequest", "the response type can only be cha
nged for asynchronous HTTP requests made from a document.")); |
| 362 return; | 362 return; |
| 363 } | 363 } |
| 364 | 364 |
| 365 if (responseType == "") { | 365 if (responseType == "") { |
| 366 m_responseTypeCode = ResponseTypeDefault; | 366 m_responseTypeCode = ResponseTypeDefault; |
| 367 } else if (responseType == "text") { | 367 } else if (responseType == "text") { |
| 368 m_responseTypeCode = ResponseTypeText; | 368 m_responseTypeCode = ResponseTypeText; |
| 369 } else if (responseType == "json") { | 369 } else if (responseType == "json") { |
| 370 m_responseTypeCode = ResponseTypeJSON; | 370 m_responseTypeCode = ResponseTypeJSON; |
| 371 } else if (responseType == "document") { | 371 } else if (responseType == "document") { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 | 432 |
| 433 InspectorInstrumentation::didDispatchXHRReadyStateChangeEvent(cookie); | 433 InspectorInstrumentation::didDispatchXHRReadyStateChangeEvent(cookie); |
| 434 if (m_state == DONE && !m_error) { | 434 if (m_state == DONE && !m_error) { |
| 435 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willDi
spatchXHRLoadEvent(executionContext(), this); | 435 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willDi
spatchXHRLoadEvent(executionContext(), this); |
| 436 m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::creat
e(EventTypeNames::load)); | 436 m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::creat
e(EventTypeNames::load)); |
| 437 InspectorInstrumentation::didDispatchXHRLoadEvent(cookie); | 437 InspectorInstrumentation::didDispatchXHRLoadEvent(cookie); |
| 438 m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::creat
e(EventTypeNames::loadend)); | 438 m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::creat
e(EventTypeNames::loadend)); |
| 439 } | 439 } |
| 440 } | 440 } |
| 441 | 441 |
| 442 void XMLHttpRequest::setWithCredentials(bool value, ExceptionState& es) | 442 void XMLHttpRequest::setWithCredentials(bool value, ExceptionState& exceptionSta
te) |
| 443 { | 443 { |
| 444 if (m_state > OPENED || m_loader) { | 444 if (m_state > OPENED || m_loader) { |
| 445 es.throwDOMException(InvalidStateError, ExceptionMessages::failedToSet("
withCredentials", "XMLHttpRequest", "the value may only be set if the object's s
tate is UNSENT or OPENED.")); | 445 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f
ailedToSet("withCredentials", "XMLHttpRequest", "the value may only be set if th
e object's state is UNSENT or OPENED.")); |
| 446 return; | 446 return; |
| 447 } | 447 } |
| 448 | 448 |
| 449 m_includeCredentials = value; | 449 m_includeCredentials = value; |
| 450 } | 450 } |
| 451 | 451 |
| 452 bool XMLHttpRequest::isAllowedHTTPMethod(const String& method) | 452 bool XMLHttpRequest::isAllowedHTTPMethod(const String& method) |
| 453 { | 453 { |
| 454 return !equalIgnoringCase(method, "TRACE") | 454 return !equalIgnoringCase(method, "TRACE") |
| 455 && !equalIgnoringCase(method, "TRACK") | 455 && !equalIgnoringCase(method, "TRACK") |
| (...skipping 29 matching lines...) Expand all Loading... |
| 485 return method; | 485 return method; |
| 486 } | 486 } |
| 487 | 487 |
| 488 bool XMLHttpRequest::isAllowedHTTPHeader(const String& name) | 488 bool XMLHttpRequest::isAllowedHTTPHeader(const String& name) |
| 489 { | 489 { |
| 490 initializeXMLHttpRequestStaticData(); | 490 initializeXMLHttpRequestStaticData(); |
| 491 return !staticData->m_forbiddenRequestHeaders.contains(name) && !name.starts
With(staticData->m_proxyHeaderPrefix, false) | 491 return !staticData->m_forbiddenRequestHeaders.contains(name) && !name.starts
With(staticData->m_proxyHeaderPrefix, false) |
| 492 && !name.startsWith(staticData->m_secHeaderPrefix, false); | 492 && !name.startsWith(staticData->m_secHeaderPrefix, false); |
| 493 } | 493 } |
| 494 | 494 |
| 495 void XMLHttpRequest::open(const String& method, const KURL& url, ExceptionState&
es) | 495 void XMLHttpRequest::open(const String& method, const KURL& url, ExceptionState&
exceptionState) |
| 496 { | 496 { |
| 497 open(method, url, true, es); | 497 open(method, url, true, exceptionState); |
| 498 } | 498 } |
| 499 | 499 |
| 500 void XMLHttpRequest::open(const String& method, const KURL& url, bool async, Exc
eptionState& es) | 500 void XMLHttpRequest::open(const String& method, const KURL& url, bool async, Exc
eptionState& exceptionState) |
| 501 { | 501 { |
| 502 LOG(Network, "XMLHttpRequest %p open('%s', '%s', %d)", this, method.utf8().d
ata(), url.elidedString().utf8().data(), async); | 502 LOG(Network, "XMLHttpRequest %p open('%s', '%s', %d)", this, method.utf8().d
ata(), url.elidedString().utf8().data(), async); |
| 503 | 503 |
| 504 if (!internalAbort()) | 504 if (!internalAbort()) |
| 505 return; | 505 return; |
| 506 | 506 |
| 507 State previousState = m_state; | 507 State previousState = m_state; |
| 508 m_state = UNSENT; | 508 m_state = UNSENT; |
| 509 m_error = false; | 509 m_error = false; |
| 510 m_uploadComplete = false; | 510 m_uploadComplete = false; |
| 511 | 511 |
| 512 // clear stuff from possible previous load | 512 // clear stuff from possible previous load |
| 513 clearResponse(); | 513 clearResponse(); |
| 514 clearRequest(); | 514 clearRequest(); |
| 515 | 515 |
| 516 ASSERT(m_state == UNSENT); | 516 ASSERT(m_state == UNSENT); |
| 517 | 517 |
| 518 if (!isValidHTTPToken(method)) { | 518 if (!isValidHTTPToken(method)) { |
| 519 es.throwDOMException(SyntaxError, ExceptionMessages::failedToExecute("op
en", "XMLHttpRequest", "'" + method + "' is not a valid HTTP method.")); | 519 exceptionState.throwDOMException(SyntaxError, ExceptionMessages::failedT
oExecute("open", "XMLHttpRequest", "'" + method + "' is not a valid HTTP method.
")); |
| 520 return; | 520 return; |
| 521 } | 521 } |
| 522 | 522 |
| 523 if (!isAllowedHTTPMethod(method)) { | 523 if (!isAllowedHTTPMethod(method)) { |
| 524 es.throwSecurityError(ExceptionMessages::failedToExecute("open", "XMLHtt
pRequest", "'" + method + "' HTTP method is unsupported.")); | 524 exceptionState.throwSecurityError(ExceptionMessages::failedToExecute("op
en", "XMLHttpRequest", "'" + method + "' HTTP method is unsupported.")); |
| 525 return; | 525 return; |
| 526 } | 526 } |
| 527 | 527 |
| 528 if (!ContentSecurityPolicy::shouldBypassMainWorld(executionContext()) && !ex
ecutionContext()->contentSecurityPolicy()->allowConnectToSource(url)) { | 528 if (!ContentSecurityPolicy::shouldBypassMainWorld(executionContext()) && !ex
ecutionContext()->contentSecurityPolicy()->allowConnectToSource(url)) { |
| 529 // We can safely expose the URL to JavaScript, as these checks happen sy
nchronously before redirection. JavaScript receives no new information. | 529 // We can safely expose the URL to JavaScript, as these checks happen sy
nchronously before redirection. JavaScript receives no new information. |
| 530 es.throwSecurityError("Refused to connect to '" + url.elidedString() + "
' because it violates the document's Content Security Policy."); | 530 exceptionState.throwSecurityError("Refused to connect to '" + url.elided
String() + "' because it violates the document's Content Security Policy."); |
| 531 return; | 531 return; |
| 532 } | 532 } |
| 533 | 533 |
| 534 if (!async && executionContext()->isDocument()) { | 534 if (!async && executionContext()->isDocument()) { |
| 535 if (document()->settings() && !document()->settings()->syncXHRInDocument
sEnabled()) { | 535 if (document()->settings() && !document()->settings()->syncXHRInDocument
sEnabled()) { |
| 536 es.throwDOMException(InvalidAccessError, ExceptionMessages::failedTo
Execute("open", "XMLHttpRequest", "synchronous requests are disabled for this pa
ge.")); | 536 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessag
es::failedToExecute("open", "XMLHttpRequest", "synchronous requests are disabled
for this page.")); |
| 537 return; | 537 return; |
| 538 } | 538 } |
| 539 | 539 |
| 540 // Newer functionality is not available to synchronous requests in windo
w contexts, as a spec-mandated | 540 // Newer functionality is not available to synchronous requests in windo
w contexts, as a spec-mandated |
| 541 // attempt to discourage synchronous XHR use. responseType is one such p
iece of functionality. | 541 // attempt to discourage synchronous XHR use. responseType is one such p
iece of functionality. |
| 542 // We'll only disable this functionality for HTTP(S) requests since sync
requests for local protocols | 542 // We'll only disable this functionality for HTTP(S) requests since sync
requests for local protocols |
| 543 // such as file: and data: still make sense to allow. | 543 // such as file: and data: still make sense to allow. |
| 544 if (url.protocolIsInHTTPFamily() && m_responseTypeCode != ResponseTypeDe
fault) { | 544 if (url.protocolIsInHTTPFamily() && m_responseTypeCode != ResponseTypeDe
fault) { |
| 545 es.throwDOMException(InvalidAccessError, ExceptionMessages::failedTo
Execute("open", "XMLHttpRequest", "synchronous HTTP requests from a document mus
t not set a response type.")); | 545 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessag
es::failedToExecute("open", "XMLHttpRequest", "synchronous HTTP requests from a
document must not set a response type.")); |
| 546 return; | 546 return; |
| 547 } | 547 } |
| 548 | 548 |
| 549 // Similarly, timeouts are disabled for synchronous requests as well. | 549 // Similarly, timeouts are disabled for synchronous requests as well. |
| 550 if (m_timeoutMilliseconds > 0) { | 550 if (m_timeoutMilliseconds > 0) { |
| 551 es.throwDOMException(InvalidAccessError, ExceptionMessages::failedTo
Execute("open", "XMLHttpRequest", "synchronous requests must not set a timeout."
)); | 551 exceptionState.throwDOMException(InvalidAccessError, ExceptionMessag
es::failedToExecute("open", "XMLHttpRequest", "synchronous requests must not set
a timeout.")); |
| 552 return; | 552 return; |
| 553 } | 553 } |
| 554 } | 554 } |
| 555 | 555 |
| 556 m_method = uppercaseKnownHTTPMethod(method); | 556 m_method = uppercaseKnownHTTPMethod(method); |
| 557 | 557 |
| 558 m_url = url; | 558 m_url = url; |
| 559 | 559 |
| 560 m_async = async; | 560 m_async = async; |
| 561 | 561 |
| 562 ASSERT(!m_loader); | 562 ASSERT(!m_loader); |
| 563 | 563 |
| 564 // Check previous state to avoid dispatching readyState event | 564 // Check previous state to avoid dispatching readyState event |
| 565 // when calling open several times in a row. | 565 // when calling open several times in a row. |
| 566 if (previousState != OPENED) | 566 if (previousState != OPENED) |
| 567 changeState(OPENED); | 567 changeState(OPENED); |
| 568 else | 568 else |
| 569 m_state = OPENED; | 569 m_state = OPENED; |
| 570 } | 570 } |
| 571 | 571 |
| 572 void XMLHttpRequest::open(const String& method, const KURL& url, bool async, con
st String& user, ExceptionState& es) | 572 void XMLHttpRequest::open(const String& method, const KURL& url, bool async, con
st String& user, ExceptionState& exceptionState) |
| 573 { | 573 { |
| 574 KURL urlWithCredentials(url); | 574 KURL urlWithCredentials(url); |
| 575 urlWithCredentials.setUser(user); | 575 urlWithCredentials.setUser(user); |
| 576 | 576 |
| 577 open(method, urlWithCredentials, async, es); | 577 open(method, urlWithCredentials, async, exceptionState); |
| 578 } | 578 } |
| 579 | 579 |
| 580 void XMLHttpRequest::open(const String& method, const KURL& url, bool async, con
st String& user, const String& password, ExceptionState& es) | 580 void XMLHttpRequest::open(const String& method, const KURL& url, bool async, con
st String& user, const String& password, ExceptionState& exceptionState) |
| 581 { | 581 { |
| 582 KURL urlWithCredentials(url); | 582 KURL urlWithCredentials(url); |
| 583 urlWithCredentials.setUser(user); | 583 urlWithCredentials.setUser(user); |
| 584 urlWithCredentials.setPass(password); | 584 urlWithCredentials.setPass(password); |
| 585 | 585 |
| 586 open(method, urlWithCredentials, async, es); | 586 open(method, urlWithCredentials, async, exceptionState); |
| 587 } | 587 } |
| 588 | 588 |
| 589 bool XMLHttpRequest::initSend(ExceptionState& es) | 589 bool XMLHttpRequest::initSend(ExceptionState& exceptionState) |
| 590 { | 590 { |
| 591 if (!executionContext()) | 591 if (!executionContext()) |
| 592 return false; | 592 return false; |
| 593 | 593 |
| 594 if (m_state != OPENED || m_loader) { | 594 if (m_state != OPENED || m_loader) { |
| 595 es.throwDOMException(InvalidStateError, ExceptionMessages::failedToExecu
te("send", "XMLHttpRequest", "the object's state must be OPENED.")); | 595 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f
ailedToExecute("send", "XMLHttpRequest", "the object's state must be OPENED.")); |
| 596 return false; | 596 return false; |
| 597 } | 597 } |
| 598 | 598 |
| 599 m_error = false; | 599 m_error = false; |
| 600 return true; | 600 return true; |
| 601 } | 601 } |
| 602 | 602 |
| 603 void XMLHttpRequest::send(ExceptionState& es) | 603 void XMLHttpRequest::send(ExceptionState& exceptionState) |
| 604 { | 604 { |
| 605 send(String(), es); | 605 send(String(), exceptionState); |
| 606 } | 606 } |
| 607 | 607 |
| 608 bool XMLHttpRequest::areMethodAndURLValidForSend() | 608 bool XMLHttpRequest::areMethodAndURLValidForSend() |
| 609 { | 609 { |
| 610 return m_method != "GET" && m_method != "HEAD" && m_url.protocolIsInHTTPFami
ly(); | 610 return m_method != "GET" && m_method != "HEAD" && m_url.protocolIsInHTTPFami
ly(); |
| 611 } | 611 } |
| 612 | 612 |
| 613 void XMLHttpRequest::send(Document* document, ExceptionState& es) | 613 void XMLHttpRequest::send(Document* document, ExceptionState& exceptionState) |
| 614 { | 614 { |
| 615 LOG(Network, "XMLHttpRequest %p send() Document %p", this, document); | 615 LOG(Network, "XMLHttpRequest %p send() Document %p", this, document); |
| 616 | 616 |
| 617 ASSERT(document); | 617 ASSERT(document); |
| 618 | 618 |
| 619 if (!initSend(es)) | 619 if (!initSend(exceptionState)) |
| 620 return; | 620 return; |
| 621 | 621 |
| 622 if (areMethodAndURLValidForSend()) { | 622 if (areMethodAndURLValidForSend()) { |
| 623 String contentType = getRequestHeader("Content-Type"); | 623 String contentType = getRequestHeader("Content-Type"); |
| 624 if (contentType.isEmpty()) { | 624 if (contentType.isEmpty()) { |
| 625 // FIXME: this should include the charset used for encoding. | 625 // FIXME: this should include the charset used for encoding. |
| 626 setRequestHeaderInternal("Content-Type", "application/xml"); | 626 setRequestHeaderInternal("Content-Type", "application/xml"); |
| 627 } | 627 } |
| 628 | 628 |
| 629 // FIXME: According to XMLHttpRequest Level 2, this should use the Docum
ent.innerHTML algorithm | 629 // FIXME: According to XMLHttpRequest Level 2, this should use the Docum
ent.innerHTML algorithm |
| 630 // from the HTML5 specification to serialize the document. | 630 // from the HTML5 specification to serialize the document. |
| 631 String body = createMarkup(document); | 631 String body = createMarkup(document); |
| 632 | 632 |
| 633 // FIXME: This should use value of document.inputEncoding to determine t
he encoding to use. | 633 // FIXME: This should use value of document.inputEncoding to determine t
he encoding to use. |
| 634 m_requestEntityBody = FormData::create(UTF8Encoding().encode(body, WTF::
EntitiesForUnencodables)); | 634 m_requestEntityBody = FormData::create(UTF8Encoding().encode(body, WTF::
EntitiesForUnencodables)); |
| 635 if (m_upload) | 635 if (m_upload) |
| 636 m_requestEntityBody->setAlwaysStream(true); | 636 m_requestEntityBody->setAlwaysStream(true); |
| 637 } | 637 } |
| 638 | 638 |
| 639 createRequest(es); | 639 createRequest(exceptionState); |
| 640 } | 640 } |
| 641 | 641 |
| 642 void XMLHttpRequest::send(const String& body, ExceptionState& es) | 642 void XMLHttpRequest::send(const String& body, ExceptionState& exceptionState) |
| 643 { | 643 { |
| 644 LOG(Network, "XMLHttpRequest %p send() String '%s'", this, body.utf8().data(
)); | 644 LOG(Network, "XMLHttpRequest %p send() String '%s'", this, body.utf8().data(
)); |
| 645 | 645 |
| 646 if (!initSend(es)) | 646 if (!initSend(exceptionState)) |
| 647 return; | 647 return; |
| 648 | 648 |
| 649 if (!body.isNull() && areMethodAndURLValidForSend()) { | 649 if (!body.isNull() && areMethodAndURLValidForSend()) { |
| 650 String contentType = getRequestHeader("Content-Type"); | 650 String contentType = getRequestHeader("Content-Type"); |
| 651 if (contentType.isEmpty()) { | 651 if (contentType.isEmpty()) { |
| 652 setRequestHeaderInternal("Content-Type", "text/plain;charset=UTF-8")
; | 652 setRequestHeaderInternal("Content-Type", "text/plain;charset=UTF-8")
; |
| 653 } else { | 653 } else { |
| 654 replaceCharsetInMediaType(contentType, "UTF-8"); | 654 replaceCharsetInMediaType(contentType, "UTF-8"); |
| 655 m_requestHeaders.set("Content-Type", contentType); | 655 m_requestHeaders.set("Content-Type", contentType); |
| 656 } | 656 } |
| 657 | 657 |
| 658 m_requestEntityBody = FormData::create(UTF8Encoding().encode(body, WTF::
EntitiesForUnencodables)); | 658 m_requestEntityBody = FormData::create(UTF8Encoding().encode(body, WTF::
EntitiesForUnencodables)); |
| 659 if (m_upload) | 659 if (m_upload) |
| 660 m_requestEntityBody->setAlwaysStream(true); | 660 m_requestEntityBody->setAlwaysStream(true); |
| 661 } | 661 } |
| 662 | 662 |
| 663 createRequest(es); | 663 createRequest(exceptionState); |
| 664 } | 664 } |
| 665 | 665 |
| 666 void XMLHttpRequest::send(Blob* body, ExceptionState& es) | 666 void XMLHttpRequest::send(Blob* body, ExceptionState& exceptionState) |
| 667 { | 667 { |
| 668 LOG(Network, "XMLHttpRequest %p send() Blob '%s'", this, body->uuid().utf8()
.data()); | 668 LOG(Network, "XMLHttpRequest %p send() Blob '%s'", this, body->uuid().utf8()
.data()); |
| 669 | 669 |
| 670 if (!initSend(es)) | 670 if (!initSend(exceptionState)) |
| 671 return; | 671 return; |
| 672 | 672 |
| 673 if (areMethodAndURLValidForSend()) { | 673 if (areMethodAndURLValidForSend()) { |
| 674 const String& contentType = getRequestHeader("Content-Type"); | 674 const String& contentType = getRequestHeader("Content-Type"); |
| 675 if (contentType.isEmpty()) { | 675 if (contentType.isEmpty()) { |
| 676 const String& blobType = body->type(); | 676 const String& blobType = body->type(); |
| 677 if (!blobType.isEmpty() && isValidContentType(blobType)) | 677 if (!blobType.isEmpty() && isValidContentType(blobType)) |
| 678 setRequestHeaderInternal("Content-Type", blobType); | 678 setRequestHeaderInternal("Content-Type", blobType); |
| 679 else { | 679 else { |
| 680 // From FileAPI spec, whenever media type cannot be determined,
empty string must be returned. | 680 // From FileAPI spec, whenever media type cannot be determined,
empty string must be returned. |
| 681 setRequestHeaderInternal("Content-Type", ""); | 681 setRequestHeaderInternal("Content-Type", ""); |
| 682 } | 682 } |
| 683 } | 683 } |
| 684 | 684 |
| 685 // FIXME: add support for uploading bundles. | 685 // FIXME: add support for uploading bundles. |
| 686 m_requestEntityBody = FormData::create(); | 686 m_requestEntityBody = FormData::create(); |
| 687 if (body->isFile()) | 687 if (body->isFile()) |
| 688 m_requestEntityBody->appendFile(toFile(body)->path()); | 688 m_requestEntityBody->appendFile(toFile(body)->path()); |
| 689 else | 689 else |
| 690 m_requestEntityBody->appendBlob(body->uuid(), body->blobDataHandle()
); | 690 m_requestEntityBody->appendBlob(body->uuid(), body->blobDataHandle()
); |
| 691 } | 691 } |
| 692 | 692 |
| 693 createRequest(es); | 693 createRequest(exceptionState); |
| 694 } | 694 } |
| 695 | 695 |
| 696 void XMLHttpRequest::send(DOMFormData* body, ExceptionState& es) | 696 void XMLHttpRequest::send(DOMFormData* body, ExceptionState& exceptionState) |
| 697 { | 697 { |
| 698 LOG(Network, "XMLHttpRequest %p send() DOMFormData %p", this, body); | 698 LOG(Network, "XMLHttpRequest %p send() DOMFormData %p", this, body); |
| 699 | 699 |
| 700 if (!initSend(es)) | 700 if (!initSend(exceptionState)) |
| 701 return; | 701 return; |
| 702 | 702 |
| 703 if (areMethodAndURLValidForSend()) { | 703 if (areMethodAndURLValidForSend()) { |
| 704 m_requestEntityBody = body->createMultiPartFormData(body->encoding()); | 704 m_requestEntityBody = body->createMultiPartFormData(body->encoding()); |
| 705 | 705 |
| 706 String contentType = getRequestHeader("Content-Type"); | 706 String contentType = getRequestHeader("Content-Type"); |
| 707 if (contentType.isEmpty()) { | 707 if (contentType.isEmpty()) { |
| 708 contentType = String("multipart/form-data; boundary=") + m_requestEn
tityBody->boundary().data(); | 708 contentType = String("multipart/form-data; boundary=") + m_requestEn
tityBody->boundary().data(); |
| 709 setRequestHeaderInternal("Content-Type", contentType); | 709 setRequestHeaderInternal("Content-Type", contentType); |
| 710 } | 710 } |
| 711 } | 711 } |
| 712 | 712 |
| 713 createRequest(es); | 713 createRequest(exceptionState); |
| 714 } | 714 } |
| 715 | 715 |
| 716 void XMLHttpRequest::send(ArrayBuffer* body, ExceptionState& es) | 716 void XMLHttpRequest::send(ArrayBuffer* body, ExceptionState& exceptionState) |
| 717 { | 717 { |
| 718 LOG(Network, "XMLHttpRequest %p send() ArrayBuffer %p", this, body); | 718 LOG(Network, "XMLHttpRequest %p send() ArrayBuffer %p", this, body); |
| 719 | 719 |
| 720 String consoleMessage("ArrayBuffer is deprecated in XMLHttpRequest.send(). U
se ArrayBufferView instead."); | 720 String consoleMessage("ArrayBuffer is deprecated in XMLHttpRequest.send(). U
se ArrayBufferView instead."); |
| 721 executionContext()->addConsoleMessage(JSMessageSource, WarningMessageLevel,
consoleMessage); | 721 executionContext()->addConsoleMessage(JSMessageSource, WarningMessageLevel,
consoleMessage); |
| 722 | 722 |
| 723 blink::Platform::current()->histogramEnumeration("WebCore.XHR.send.ArrayBuff
erOrView", XMLHttpRequestSendArrayBuffer, XMLHttpRequestSendArrayBufferOrViewMax
); | 723 blink::Platform::current()->histogramEnumeration("WebCore.XHR.send.ArrayBuff
erOrView", XMLHttpRequestSendArrayBuffer, XMLHttpRequestSendArrayBufferOrViewMax
); |
| 724 | 724 |
| 725 sendBytesData(body->data(), body->byteLength(), es); | 725 sendBytesData(body->data(), body->byteLength(), exceptionState); |
| 726 } | 726 } |
| 727 | 727 |
| 728 void XMLHttpRequest::send(ArrayBufferView* body, ExceptionState& es) | 728 void XMLHttpRequest::send(ArrayBufferView* body, ExceptionState& exceptionState) |
| 729 { | 729 { |
| 730 LOG(Network, "XMLHttpRequest %p send() ArrayBufferView %p", this, body); | 730 LOG(Network, "XMLHttpRequest %p send() ArrayBufferView %p", this, body); |
| 731 | 731 |
| 732 blink::Platform::current()->histogramEnumeration("WebCore.XHR.send.ArrayBuff
erOrView", XMLHttpRequestSendArrayBufferView, XMLHttpRequestSendArrayBufferOrVie
wMax); | 732 blink::Platform::current()->histogramEnumeration("WebCore.XHR.send.ArrayBuff
erOrView", XMLHttpRequestSendArrayBufferView, XMLHttpRequestSendArrayBufferOrVie
wMax); |
| 733 | 733 |
| 734 sendBytesData(body->baseAddress(), body->byteLength(), es); | 734 sendBytesData(body->baseAddress(), body->byteLength(), exceptionState); |
| 735 } | 735 } |
| 736 | 736 |
| 737 void XMLHttpRequest::sendBytesData(const void* data, size_t length, ExceptionSta
te& es) | 737 void XMLHttpRequest::sendBytesData(const void* data, size_t length, ExceptionSta
te& exceptionState) |
| 738 { | 738 { |
| 739 if (!initSend(es)) | 739 if (!initSend(exceptionState)) |
| 740 return; | 740 return; |
| 741 | 741 |
| 742 if (areMethodAndURLValidForSend()) { | 742 if (areMethodAndURLValidForSend()) { |
| 743 m_requestEntityBody = FormData::create(data, length); | 743 m_requestEntityBody = FormData::create(data, length); |
| 744 if (m_upload) | 744 if (m_upload) |
| 745 m_requestEntityBody->setAlwaysStream(true); | 745 m_requestEntityBody->setAlwaysStream(true); |
| 746 } | 746 } |
| 747 | 747 |
| 748 createRequest(es); | 748 createRequest(exceptionState); |
| 749 } | 749 } |
| 750 | 750 |
| 751 void XMLHttpRequest::sendForInspectorXHRReplay(PassRefPtr<FormData> formData, Ex
ceptionState& es) | 751 void XMLHttpRequest::sendForInspectorXHRReplay(PassRefPtr<FormData> formData, Ex
ceptionState& exceptionState) |
| 752 { | 752 { |
| 753 m_requestEntityBody = formData ? formData->deepCopy() : 0; | 753 m_requestEntityBody = formData ? formData->deepCopy() : 0; |
| 754 createRequest(es); | 754 createRequest(exceptionState); |
| 755 m_exceptionCode = es.code(); | 755 m_exceptionCode = exceptionState.code(); |
| 756 } | 756 } |
| 757 | 757 |
| 758 void XMLHttpRequest::createRequest(ExceptionState& es) | 758 void XMLHttpRequest::createRequest(ExceptionState& exceptionState) |
| 759 { | 759 { |
| 760 // Only GET request is supported for blob URL. | 760 // Only GET request is supported for blob URL. |
| 761 if (m_url.protocolIs("blob") && m_method != "GET") { | 761 if (m_url.protocolIs("blob") && m_method != "GET") { |
| 762 es.throwDOMException(NetworkError, ExceptionMessages::failedToExecute("s
end", "XMLHttpRequest", "'GET' is the only method allowed for 'blob:' URLs.")); | 762 exceptionState.throwDOMException(NetworkError, ExceptionMessages::failed
ToExecute("send", "XMLHttpRequest", "'GET' is the only method allowed for 'blob:
' URLs.")); |
| 763 return; | 763 return; |
| 764 } | 764 } |
| 765 | 765 |
| 766 // The presence of upload event listeners forces us to use preflighting beca
use POSTing to an URL that does not | 766 // The presence of upload event listeners forces us to use preflighting beca
use POSTing to an URL that does not |
| 767 // permit cross origin requests should look exactly like POSTing to an URL t
hat does not respond at all. | 767 // permit cross origin requests should look exactly like POSTing to an URL t
hat does not respond at all. |
| 768 // Also, only async requests support upload progress events. | 768 // Also, only async requests support upload progress events. |
| 769 bool uploadEvents = false; | 769 bool uploadEvents = false; |
| 770 if (m_async) { | 770 if (m_async) { |
| 771 m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::creat
e(EventTypeNames::loadstart)); | 771 m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::creat
e(EventTypeNames::loadstart)); |
| 772 if (m_requestEntityBody && m_upload) { | 772 if (m_requestEntityBody && m_upload) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 // and they are referenced by the JavaScript wrapper. | 829 // and they are referenced by the JavaScript wrapper. |
| 830 setPendingActivity(this); | 830 setPendingActivity(this); |
| 831 } | 831 } |
| 832 } else { | 832 } else { |
| 833 ThreadableLoader::loadResourceSynchronously(executionContext(), request,
*this, options); | 833 ThreadableLoader::loadResourceSynchronously(executionContext(), request,
*this, options); |
| 834 } | 834 } |
| 835 | 835 |
| 836 if (!m_exceptionCode && m_error) | 836 if (!m_exceptionCode && m_error) |
| 837 m_exceptionCode = NetworkError; | 837 m_exceptionCode = NetworkError; |
| 838 if (m_exceptionCode) | 838 if (m_exceptionCode) |
| 839 es.throwUninformativeAndGenericDOMException(m_exceptionCode); | 839 exceptionState.throwUninformativeAndGenericDOMException(m_exceptionCode)
; |
| 840 } | 840 } |
| 841 | 841 |
| 842 void XMLHttpRequest::abort() | 842 void XMLHttpRequest::abort() |
| 843 { | 843 { |
| 844 LOG(Network, "XMLHttpRequest %p abort()", this); | 844 LOG(Network, "XMLHttpRequest %p abort()", this); |
| 845 | 845 |
| 846 // internalAbort() calls dropProtection(), which may release the last refere
nce. | 846 // internalAbort() calls dropProtection(), which may release the last refere
nce. |
| 847 RefPtr<XMLHttpRequest> protect(this); | 847 RefPtr<XMLHttpRequest> protect(this); |
| 848 | 848 |
| 849 bool sendFlag = m_loader; | 849 bool sendFlag = m_loader; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1008 void XMLHttpRequest::dropProtection() | 1008 void XMLHttpRequest::dropProtection() |
| 1009 { | 1009 { |
| 1010 unsetPendingActivity(this); | 1010 unsetPendingActivity(this); |
| 1011 } | 1011 } |
| 1012 | 1012 |
| 1013 void XMLHttpRequest::overrideMimeType(const String& override) | 1013 void XMLHttpRequest::overrideMimeType(const String& override) |
| 1014 { | 1014 { |
| 1015 m_mimeTypeOverride = override; | 1015 m_mimeTypeOverride = override; |
| 1016 } | 1016 } |
| 1017 | 1017 |
| 1018 void XMLHttpRequest::setRequestHeader(const AtomicString& name, const String& va
lue, ExceptionState& es) | 1018 void XMLHttpRequest::setRequestHeader(const AtomicString& name, const String& va
lue, ExceptionState& exceptionState) |
| 1019 { | 1019 { |
| 1020 if (m_state != OPENED || m_loader) { | 1020 if (m_state != OPENED || m_loader) { |
| 1021 es.throwDOMException(InvalidStateError, ExceptionMessages::failedToExecu
te("setRequestHeader", "XMLHttpRequest", "the object's state must be OPENED.")); | 1021 exceptionState.throwDOMException(InvalidStateError, ExceptionMessages::f
ailedToExecute("setRequestHeader", "XMLHttpRequest", "the object's state must be
OPENED.")); |
| 1022 return; | 1022 return; |
| 1023 } | 1023 } |
| 1024 | 1024 |
| 1025 if (!isValidHTTPToken(name)) { | 1025 if (!isValidHTTPToken(name)) { |
| 1026 es.throwDOMException(SyntaxError, ExceptionMessages::failedToExecute("se
tRequestHeader", "XMLHttpRequest", "'" + name + "' is not a valid HTTP header fi
eld name.")); | 1026 exceptionState.throwDOMException(SyntaxError, ExceptionMessages::failedT
oExecute("setRequestHeader", "XMLHttpRequest", "'" + name + "' is not a valid HT
TP header field name.")); |
| 1027 return; | 1027 return; |
| 1028 } | 1028 } |
| 1029 | 1029 |
| 1030 if (!isValidHTTPHeaderValue(value)) { | 1030 if (!isValidHTTPHeaderValue(value)) { |
| 1031 es.throwDOMException(SyntaxError, ExceptionMessages::failedToExecute("se
tRequestHeader", "XMLHttpRequest", "'" + value + "' is not a valid HTTP header f
ield value.")); | 1031 exceptionState.throwDOMException(SyntaxError, ExceptionMessages::failedT
oExecute("setRequestHeader", "XMLHttpRequest", "'" + value + "' is not a valid H
TTP header field value.")); |
| 1032 return; | 1032 return; |
| 1033 } | 1033 } |
| 1034 | 1034 |
| 1035 // No script (privileged or not) can set unsafe headers. | 1035 // No script (privileged or not) can set unsafe headers. |
| 1036 if (!isAllowedHTTPHeader(name)) { | 1036 if (!isAllowedHTTPHeader(name)) { |
| 1037 logConsoleError(executionContext(), "Refused to set unsafe header \"" +
name + "\""); | 1037 logConsoleError(executionContext(), "Refused to set unsafe header \"" +
name + "\""); |
| 1038 return; | 1038 return; |
| 1039 } | 1039 } |
| 1040 | 1040 |
| 1041 setRequestHeaderInternal(name, value); | 1041 setRequestHeaderInternal(name, value); |
| 1042 } | 1042 } |
| 1043 | 1043 |
| 1044 void XMLHttpRequest::setRequestHeaderInternal(const AtomicString& name, const St
ring& value) | 1044 void XMLHttpRequest::setRequestHeaderInternal(const AtomicString& name, const St
ring& value) |
| 1045 { | 1045 { |
| 1046 HTTPHeaderMap::AddResult result = m_requestHeaders.add(name, value); | 1046 HTTPHeaderMap::AddResult result = m_requestHeaders.add(name, value); |
| 1047 if (!result.isNewEntry) | 1047 if (!result.isNewEntry) |
| 1048 result.iterator->value = result.iterator->value + ", " + value; | 1048 result.iterator->value = result.iterator->value + ", " + value; |
| 1049 } | 1049 } |
| 1050 | 1050 |
| 1051 String XMLHttpRequest::getRequestHeader(const AtomicString& name) const | 1051 String XMLHttpRequest::getRequestHeader(const AtomicString& name) const |
| 1052 { | 1052 { |
| 1053 return m_requestHeaders.get(name); | 1053 return m_requestHeaders.get(name); |
| 1054 } | 1054 } |
| 1055 | 1055 |
| 1056 String XMLHttpRequest::getAllResponseHeaders(ExceptionState& es) const | 1056 String XMLHttpRequest::getAllResponseHeaders(ExceptionState& exceptionState) con
st |
| 1057 { | 1057 { |
| 1058 if (m_state < HEADERS_RECEIVED || m_error) | 1058 if (m_state < HEADERS_RECEIVED || m_error) |
| 1059 return ""; | 1059 return ""; |
| 1060 | 1060 |
| 1061 StringBuilder stringBuilder; | 1061 StringBuilder stringBuilder; |
| 1062 | 1062 |
| 1063 HTTPHeaderSet accessControlExposeHeaderSet; | 1063 HTTPHeaderSet accessControlExposeHeaderSet; |
| 1064 parseAccessControlExposeHeadersAllowList(m_response.httpHeaderField("Access-
Control-Expose-Headers"), accessControlExposeHeaderSet); | 1064 parseAccessControlExposeHeadersAllowList(m_response.httpHeaderField("Access-
Control-Expose-Headers"), accessControlExposeHeaderSet); |
| 1065 HTTPHeaderMap::const_iterator end = m_response.httpHeaderFields().end(); | 1065 HTTPHeaderMap::const_iterator end = m_response.httpHeaderFields().end(); |
| 1066 for (HTTPHeaderMap::const_iterator it = m_response.httpHeaderFields().begin(
); it!= end; ++it) { | 1066 for (HTTPHeaderMap::const_iterator it = m_response.httpHeaderFields().begin(
); it!= end; ++it) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1080 stringBuilder.append(':'); | 1080 stringBuilder.append(':'); |
| 1081 stringBuilder.append(' '); | 1081 stringBuilder.append(' '); |
| 1082 stringBuilder.append(it->value); | 1082 stringBuilder.append(it->value); |
| 1083 stringBuilder.append('\r'); | 1083 stringBuilder.append('\r'); |
| 1084 stringBuilder.append('\n'); | 1084 stringBuilder.append('\n'); |
| 1085 } | 1085 } |
| 1086 | 1086 |
| 1087 return stringBuilder.toString(); | 1087 return stringBuilder.toString(); |
| 1088 } | 1088 } |
| 1089 | 1089 |
| 1090 String XMLHttpRequest::getResponseHeader(const AtomicString& name, ExceptionStat
e& es) const | 1090 String XMLHttpRequest::getResponseHeader(const AtomicString& name, ExceptionStat
e& exceptionState) const |
| 1091 { | 1091 { |
| 1092 if (m_state < HEADERS_RECEIVED || m_error) | 1092 if (m_state < HEADERS_RECEIVED || m_error) |
| 1093 return String(); | 1093 return String(); |
| 1094 | 1094 |
| 1095 // See comment in getAllResponseHeaders above. | 1095 // See comment in getAllResponseHeaders above. |
| 1096 if (isSetCookieHeader(name) && !securityOrigin()->canLoadLocalResources()) { | 1096 if (isSetCookieHeader(name) && !securityOrigin()->canLoadLocalResources()) { |
| 1097 logConsoleError(executionContext(), "Refused to get unsafe header \"" +
name + "\""); | 1097 logConsoleError(executionContext(), "Refused to get unsafe header \"" +
name + "\""); |
| 1098 return String(); | 1098 return String(); |
| 1099 } | 1099 } |
| 1100 | 1100 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1123 return mimeType; | 1123 return mimeType; |
| 1124 } | 1124 } |
| 1125 | 1125 |
| 1126 bool XMLHttpRequest::responseIsXML() const | 1126 bool XMLHttpRequest::responseIsXML() const |
| 1127 { | 1127 { |
| 1128 // FIXME: Remove the lower() call when DOMImplementation.isXMLMIMEType() is
modified | 1128 // FIXME: Remove the lower() call when DOMImplementation.isXMLMIMEType() is
modified |
| 1129 // to do case insensitive MIME type matching. | 1129 // to do case insensitive MIME type matching. |
| 1130 return DOMImplementation::isXMLMIMEType(responseMIMEType().lower()); | 1130 return DOMImplementation::isXMLMIMEType(responseMIMEType().lower()); |
| 1131 } | 1131 } |
| 1132 | 1132 |
| 1133 int XMLHttpRequest::status(ExceptionState& es) const | 1133 int XMLHttpRequest::status(ExceptionState& exceptionState) const |
| 1134 { | 1134 { |
| 1135 if (m_state == UNSENT || m_state == OPENED || m_error) | 1135 if (m_state == UNSENT || m_state == OPENED || m_error) |
| 1136 return 0; | 1136 return 0; |
| 1137 | 1137 |
| 1138 if (m_response.httpStatusCode()) | 1138 if (m_response.httpStatusCode()) |
| 1139 return m_response.httpStatusCode(); | 1139 return m_response.httpStatusCode(); |
| 1140 | 1140 |
| 1141 return 0; | 1141 return 0; |
| 1142 } | 1142 } |
| 1143 | 1143 |
| 1144 String XMLHttpRequest::statusText(ExceptionState& es) const | 1144 String XMLHttpRequest::statusText(ExceptionState& exceptionState) const |
| 1145 { | 1145 { |
| 1146 if (m_state == UNSENT || m_state == OPENED || m_error) | 1146 if (m_state == UNSENT || m_state == OPENED || m_error) |
| 1147 return String(); | 1147 return String(); |
| 1148 | 1148 |
| 1149 if (!m_response.httpStatusText().isNull()) | 1149 if (!m_response.httpStatusText().isNull()) |
| 1150 return m_response.httpStatusText(); | 1150 return m_response.httpStatusText(); |
| 1151 | 1151 |
| 1152 return String(); | 1152 return String(); |
| 1153 } | 1153 } |
| 1154 | 1154 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1366 { | 1366 { |
| 1367 return EventTargetNames::XMLHttpRequest; | 1367 return EventTargetNames::XMLHttpRequest; |
| 1368 } | 1368 } |
| 1369 | 1369 |
| 1370 ExecutionContext* XMLHttpRequest::executionContext() const | 1370 ExecutionContext* XMLHttpRequest::executionContext() const |
| 1371 { | 1371 { |
| 1372 return ActiveDOMObject::executionContext(); | 1372 return ActiveDOMObject::executionContext(); |
| 1373 } | 1373 } |
| 1374 | 1374 |
| 1375 } // namespace WebCore | 1375 } // namespace WebCore |
| OLD | NEW |