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 } | 208 } |
209 | 209 |
210 XMLHttpRequest::State XMLHttpRequest::readyState() const | 210 XMLHttpRequest::State XMLHttpRequest::readyState() const |
211 { | 211 { |
212 return m_state; | 212 return m_state; |
213 } | 213 } |
214 | 214 |
215 ScriptString XMLHttpRequest::responseText(ExceptionCode& ec) | 215 ScriptString XMLHttpRequest::responseText(ExceptionCode& ec) |
216 { | 216 { |
217 if (m_responseTypeCode != ResponseTypeDefault && m_responseTypeCode != Respo
nseTypeText) { | 217 if (m_responseTypeCode != ResponseTypeDefault && m_responseTypeCode != Respo
nseTypeText) { |
218 ec = INVALID_STATE_ERR; | 218 ec = InvalidStateError; |
219 return ScriptString(); | 219 return ScriptString(); |
220 } | 220 } |
221 if (m_error || (m_state != LOADING && m_state != DONE)) | 221 if (m_error || (m_state != LOADING && m_state != DONE)) |
222 return ScriptString(); | 222 return ScriptString(); |
223 return m_responseText; | 223 return m_responseText; |
224 } | 224 } |
225 | 225 |
226 Document* XMLHttpRequest::responseXML(ExceptionCode& ec) | 226 Document* XMLHttpRequest::responseXML(ExceptionCode& ec) |
227 { | 227 { |
228 if (m_responseTypeCode != ResponseTypeDefault && m_responseTypeCode != Respo
nseTypeDocument) { | 228 if (m_responseTypeCode != ResponseTypeDefault && m_responseTypeCode != Respo
nseTypeDocument) { |
229 ec = INVALID_STATE_ERR; | 229 ec = InvalidStateError; |
230 return 0; | 230 return 0; |
231 } | 231 } |
232 | 232 |
233 if (m_error || m_state != DONE) | 233 if (m_error || m_state != DONE) |
234 return 0; | 234 return 0; |
235 | 235 |
236 if (!m_createdDocument) { | 236 if (!m_createdDocument) { |
237 bool isHTML = equalIgnoringCase(responseMIMEType(), "text/html"); | 237 bool isHTML = equalIgnoringCase(responseMIMEType(), "text/html"); |
238 | 238 |
239 // The W3C spec requires the final MIME type to be some valid XML type,
or text/html. | 239 // The W3C spec requires the final MIME type to be some valid XML type,
or text/html. |
(...skipping 16 matching lines...) Expand all Loading... |
256 } | 256 } |
257 m_createdDocument = true; | 257 m_createdDocument = true; |
258 } | 258 } |
259 | 259 |
260 return m_responseDocument.get(); | 260 return m_responseDocument.get(); |
261 } | 261 } |
262 | 262 |
263 Blob* XMLHttpRequest::responseBlob(ExceptionCode& ec) | 263 Blob* XMLHttpRequest::responseBlob(ExceptionCode& ec) |
264 { | 264 { |
265 if (m_responseTypeCode != ResponseTypeBlob) { | 265 if (m_responseTypeCode != ResponseTypeBlob) { |
266 ec = INVALID_STATE_ERR; | 266 ec = InvalidStateError; |
267 return 0; | 267 return 0; |
268 } | 268 } |
269 // We always return null before DONE. | 269 // We always return null before DONE. |
270 if (m_error || m_state != DONE) | 270 if (m_error || m_state != DONE) |
271 return 0; | 271 return 0; |
272 | 272 |
273 if (!m_responseBlob) { | 273 if (!m_responseBlob) { |
274 // FIXME: This causes two (or more) unnecessary copies of the data. | 274 // FIXME: This causes two (or more) unnecessary copies of the data. |
275 // Chromium stores blob data in the browser process, so we're pulling th
e data | 275 // Chromium stores blob data in the browser process, so we're pulling th
e data |
276 // from the network only to copy it into the renderer to copy it back to
the browser. | 276 // from the network only to copy it into the renderer to copy it back to
the browser. |
(...skipping 14 matching lines...) Expand all Loading... |
291 } | 291 } |
292 m_responseBlob = Blob::create(blobData.release(), size); | 292 m_responseBlob = Blob::create(blobData.release(), size); |
293 } | 293 } |
294 | 294 |
295 return m_responseBlob.get(); | 295 return m_responseBlob.get(); |
296 } | 296 } |
297 | 297 |
298 ArrayBuffer* XMLHttpRequest::responseArrayBuffer(ExceptionCode& ec) | 298 ArrayBuffer* XMLHttpRequest::responseArrayBuffer(ExceptionCode& ec) |
299 { | 299 { |
300 if (m_responseTypeCode != ResponseTypeArrayBuffer) { | 300 if (m_responseTypeCode != ResponseTypeArrayBuffer) { |
301 ec = INVALID_STATE_ERR; | 301 ec = InvalidStateError; |
302 return 0; | 302 return 0; |
303 } | 303 } |
304 | 304 |
305 if (m_error || m_state != DONE) | 305 if (m_error || m_state != DONE) |
306 return 0; | 306 return 0; |
307 | 307 |
308 if (!m_responseArrayBuffer.get() && m_binaryResponseBuilder.get() && m_binar
yResponseBuilder->size() > 0) { | 308 if (!m_responseArrayBuffer.get() && m_binaryResponseBuilder.get() && m_binar
yResponseBuilder->size() > 0) { |
309 m_responseArrayBuffer = m_binaryResponseBuilder->getAsArrayBuffer(); | 309 m_responseArrayBuffer = m_binaryResponseBuilder->getAsArrayBuffer(); |
310 m_binaryResponseBuilder.clear(); | 310 m_binaryResponseBuilder.clear(); |
311 } | 311 } |
312 | 312 |
313 return m_responseArrayBuffer.get(); | 313 return m_responseArrayBuffer.get(); |
314 } | 314 } |
315 | 315 |
316 void XMLHttpRequest::setTimeout(unsigned long timeout, ExceptionCode& ec) | 316 void XMLHttpRequest::setTimeout(unsigned long timeout, ExceptionCode& ec) |
317 { | 317 { |
318 // FIXME: Need to trigger or update the timeout Timer here, if needed. http:
//webkit.org/b/98156 | 318 // FIXME: Need to trigger or update the timeout Timer here, if needed. http:
//webkit.org/b/98156 |
319 // 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." | 319 // 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." |
320 if (scriptExecutionContext()->isDocument() && !m_async) { | 320 if (scriptExecutionContext()->isDocument() && !m_async) { |
321 logConsoleError(scriptExecutionContext(), "XMLHttpRequest.timeout cannot
be set for synchronous HTTP(S) requests made from the window context."); | 321 logConsoleError(scriptExecutionContext(), "XMLHttpRequest.timeout cannot
be set for synchronous HTTP(S) requests made from the window context."); |
322 ec = INVALID_ACCESS_ERR; | 322 ec = InvalidAccessError; |
323 return; | 323 return; |
324 } | 324 } |
325 m_timeoutMilliseconds = timeout; | 325 m_timeoutMilliseconds = timeout; |
326 } | 326 } |
327 | 327 |
328 void XMLHttpRequest::setResponseType(const String& responseType, ExceptionCode&
ec) | 328 void XMLHttpRequest::setResponseType(const String& responseType, ExceptionCode&
ec) |
329 { | 329 { |
330 if (m_state >= LOADING) { | 330 if (m_state >= LOADING) { |
331 ec = INVALID_STATE_ERR; | 331 ec = InvalidStateError; |
332 return; | 332 return; |
333 } | 333 } |
334 | 334 |
335 // Newer functionality is not available to synchronous requests in window co
ntexts, as a spec-mandated | 335 // Newer functionality is not available to synchronous requests in window co
ntexts, as a spec-mandated |
336 // attempt to discourage synchronous XHR use. responseType is one such piece
of functionality. | 336 // attempt to discourage synchronous XHR use. responseType is one such piece
of functionality. |
337 // We'll only disable this functionality for HTTP(S) requests since sync req
uests for local protocols | 337 // We'll only disable this functionality for HTTP(S) requests since sync req
uests for local protocols |
338 // such as file: and data: still make sense to allow. | 338 // such as file: and data: still make sense to allow. |
339 if (!m_async && scriptExecutionContext()->isDocument() && m_url.protocolIsIn
HTTPFamily()) { | 339 if (!m_async && scriptExecutionContext()->isDocument() && m_url.protocolIsIn
HTTPFamily()) { |
340 logConsoleError(scriptExecutionContext(), "XMLHttpRequest.responseType c
annot be changed for synchronous HTTP(S) requests made from the window context."
); | 340 logConsoleError(scriptExecutionContext(), "XMLHttpRequest.responseType c
annot be changed for synchronous HTTP(S) requests made from the window context."
); |
341 ec = INVALID_ACCESS_ERR; | 341 ec = InvalidAccessError; |
342 return; | 342 return; |
343 } | 343 } |
344 | 344 |
345 if (responseType == "") | 345 if (responseType == "") |
346 m_responseTypeCode = ResponseTypeDefault; | 346 m_responseTypeCode = ResponseTypeDefault; |
347 else if (responseType == "text") | 347 else if (responseType == "text") |
348 m_responseTypeCode = ResponseTypeText; | 348 m_responseTypeCode = ResponseTypeText; |
349 else if (responseType == "document") | 349 else if (responseType == "document") |
350 m_responseTypeCode = ResponseTypeDocument; | 350 m_responseTypeCode = ResponseTypeDocument; |
351 else if (responseType == "blob") | 351 else if (responseType == "blob") |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willDi
spatchXHRLoadEvent(scriptExecutionContext(), this); | 403 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willDi
spatchXHRLoadEvent(scriptExecutionContext(), this); |
404 m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::creat
e(eventNames().loadEvent)); | 404 m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::creat
e(eventNames().loadEvent)); |
405 InspectorInstrumentation::didDispatchXHRLoadEvent(cookie); | 405 InspectorInstrumentation::didDispatchXHRLoadEvent(cookie); |
406 m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::creat
e(eventNames().loadendEvent)); | 406 m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::creat
e(eventNames().loadendEvent)); |
407 } | 407 } |
408 } | 408 } |
409 | 409 |
410 void XMLHttpRequest::setWithCredentials(bool value, ExceptionCode& ec) | 410 void XMLHttpRequest::setWithCredentials(bool value, ExceptionCode& ec) |
411 { | 411 { |
412 if (m_state > OPENED || m_loader) { | 412 if (m_state > OPENED || m_loader) { |
413 ec = INVALID_STATE_ERR; | 413 ec = InvalidStateError; |
414 return; | 414 return; |
415 } | 415 } |
416 | 416 |
417 m_includeCredentials = value; | 417 m_includeCredentials = value; |
418 } | 418 } |
419 | 419 |
420 bool XMLHttpRequest::isAllowedHTTPMethod(const String& method) | 420 bool XMLHttpRequest::isAllowedHTTPMethod(const String& method) |
421 { | 421 { |
422 return !equalIgnoringCase(method, "TRACE") | 422 return !equalIgnoringCase(method, "TRACE") |
423 && !equalIgnoringCase(method, "TRACK") | 423 && !equalIgnoringCase(method, "TRACK") |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 m_error = false; | 456 m_error = false; |
457 m_uploadComplete = false; | 457 m_uploadComplete = false; |
458 | 458 |
459 // clear stuff from possible previous load | 459 // clear stuff from possible previous load |
460 clearResponse(); | 460 clearResponse(); |
461 clearRequest(); | 461 clearRequest(); |
462 | 462 |
463 ASSERT(m_state == UNSENT); | 463 ASSERT(m_state == UNSENT); |
464 | 464 |
465 if (!isValidHTTPToken(method)) { | 465 if (!isValidHTTPToken(method)) { |
466 ec = SYNTAX_ERR; | 466 ec = SyntaxError; |
467 return; | 467 return; |
468 } | 468 } |
469 | 469 |
470 if (!isAllowedHTTPMethod(method)) { | 470 if (!isAllowedHTTPMethod(method)) { |
471 ec = SECURITY_ERR; | 471 ec = SecurityError; |
472 return; | 472 return; |
473 } | 473 } |
474 | 474 |
475 if (!ContentSecurityPolicy::shouldBypassMainWorld(scriptExecutionContext())
&& !scriptExecutionContext()->contentSecurityPolicy()->allowConnectToSource(url)
) { | 475 if (!ContentSecurityPolicy::shouldBypassMainWorld(scriptExecutionContext())
&& !scriptExecutionContext()->contentSecurityPolicy()->allowConnectToSource(url)
) { |
476 // FIXME: Should this be throwing an exception? | 476 // FIXME: Should this be throwing an exception? |
477 ec = SECURITY_ERR; | 477 ec = SecurityError; |
478 return; | 478 return; |
479 } | 479 } |
480 | 480 |
481 if (!async && scriptExecutionContext()->isDocument()) { | 481 if (!async && scriptExecutionContext()->isDocument()) { |
482 if (document()->settings() && !document()->settings()->syncXHRInDocument
sEnabled()) { | 482 if (document()->settings() && !document()->settings()->syncXHRInDocument
sEnabled()) { |
483 logConsoleError(scriptExecutionContext(), "Synchronous XMLHttpReques
ts are disabled for this page."); | 483 logConsoleError(scriptExecutionContext(), "Synchronous XMLHttpReques
ts are disabled for this page."); |
484 ec = INVALID_ACCESS_ERR; | 484 ec = InvalidAccessError; |
485 return; | 485 return; |
486 } | 486 } |
487 | 487 |
488 // Newer functionality is not available to synchronous requests in windo
w contexts, as a spec-mandated | 488 // Newer functionality is not available to synchronous requests in windo
w contexts, as a spec-mandated |
489 // attempt to discourage synchronous XHR use. responseType is one such p
iece of functionality. | 489 // attempt to discourage synchronous XHR use. responseType is one such p
iece of functionality. |
490 // We'll only disable this functionality for HTTP(S) requests since sync
requests for local protocols | 490 // We'll only disable this functionality for HTTP(S) requests since sync
requests for local protocols |
491 // such as file: and data: still make sense to allow. | 491 // such as file: and data: still make sense to allow. |
492 if (url.protocolIsInHTTPFamily() && m_responseTypeCode != ResponseTypeDe
fault) { | 492 if (url.protocolIsInHTTPFamily() && m_responseTypeCode != ResponseTypeDe
fault) { |
493 logConsoleError(scriptExecutionContext(), "Synchronous HTTP(S) reque
sts made from the window context cannot have XMLHttpRequest.responseType set."); | 493 logConsoleError(scriptExecutionContext(), "Synchronous HTTP(S) reque
sts made from the window context cannot have XMLHttpRequest.responseType set."); |
494 ec = INVALID_ACCESS_ERR; | 494 ec = InvalidAccessError; |
495 return; | 495 return; |
496 } | 496 } |
497 | 497 |
498 // Similarly, timeouts are disabled for synchronous requests as well. | 498 // Similarly, timeouts are disabled for synchronous requests as well. |
499 if (m_timeoutMilliseconds > 0) { | 499 if (m_timeoutMilliseconds > 0) { |
500 logConsoleError(scriptExecutionContext(), "Synchronous XMLHttpReques
ts must not have a timeout value set."); | 500 logConsoleError(scriptExecutionContext(), "Synchronous XMLHttpReques
ts must not have a timeout value set."); |
501 ec = INVALID_ACCESS_ERR; | 501 ec = InvalidAccessError; |
502 return; | 502 return; |
503 } | 503 } |
504 } | 504 } |
505 | 505 |
506 m_method = uppercaseKnownHTTPMethod(method); | 506 m_method = uppercaseKnownHTTPMethod(method); |
507 | 507 |
508 m_url = url; | 508 m_url = url; |
509 | 509 |
510 m_async = async; | 510 m_async = async; |
511 | 511 |
(...skipping 23 matching lines...) Expand all Loading... |
535 | 535 |
536 open(method, urlWithCredentials, async, ec); | 536 open(method, urlWithCredentials, async, ec); |
537 } | 537 } |
538 | 538 |
539 bool XMLHttpRequest::initSend(ExceptionCode& ec) | 539 bool XMLHttpRequest::initSend(ExceptionCode& ec) |
540 { | 540 { |
541 if (!scriptExecutionContext()) | 541 if (!scriptExecutionContext()) |
542 return false; | 542 return false; |
543 | 543 |
544 if (m_state != OPENED || m_loader) { | 544 if (m_state != OPENED || m_loader) { |
545 ec = INVALID_STATE_ERR; | 545 ec = InvalidStateError; |
546 return false; | 546 return false; |
547 } | 547 } |
548 | 548 |
549 m_error = false; | 549 m_error = false; |
550 return true; | 550 return true; |
551 } | 551 } |
552 | 552 |
553 void XMLHttpRequest::send(ExceptionCode& ec) | 553 void XMLHttpRequest::send(ExceptionCode& ec) |
554 { | 554 { |
555 send(String(), ec); | 555 send(String(), ec); |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 } | 897 } |
898 | 898 |
899 void XMLHttpRequest::overrideMimeType(const String& override) | 899 void XMLHttpRequest::overrideMimeType(const String& override) |
900 { | 900 { |
901 m_mimeTypeOverride = override; | 901 m_mimeTypeOverride = override; |
902 } | 902 } |
903 | 903 |
904 void XMLHttpRequest::setRequestHeader(const AtomicString& name, const String& va
lue, ExceptionCode& ec) | 904 void XMLHttpRequest::setRequestHeader(const AtomicString& name, const String& va
lue, ExceptionCode& ec) |
905 { | 905 { |
906 if (m_state != OPENED || m_loader) { | 906 if (m_state != OPENED || m_loader) { |
907 ec = INVALID_STATE_ERR; | 907 ec = InvalidStateError; |
908 return; | 908 return; |
909 } | 909 } |
910 | 910 |
911 if (!isValidHTTPToken(name) || !isValidHTTPHeaderValue(value)) { | 911 if (!isValidHTTPToken(name) || !isValidHTTPHeaderValue(value)) { |
912 ec = SYNTAX_ERR; | 912 ec = SyntaxError; |
913 return; | 913 return; |
914 } | 914 } |
915 | 915 |
916 // No script (privileged or not) can set unsafe headers. | 916 // No script (privileged or not) can set unsafe headers. |
917 if (!isAllowedHTTPHeader(name)) { | 917 if (!isAllowedHTTPHeader(name)) { |
918 logConsoleError(scriptExecutionContext(), "Refused to set unsafe header
\"" + name + "\""); | 918 logConsoleError(scriptExecutionContext(), "Refused to set unsafe header
\"" + name + "\""); |
919 return; | 919 return; |
920 } | 920 } |
921 | 921 |
922 setRequestHeaderInternal(name, value); | 922 setRequestHeaderInternal(name, value); |
923 } | 923 } |
924 | 924 |
925 void XMLHttpRequest::setRequestHeaderInternal(const AtomicString& name, const St
ring& value) | 925 void XMLHttpRequest::setRequestHeaderInternal(const AtomicString& name, const St
ring& value) |
926 { | 926 { |
927 HTTPHeaderMap::AddResult result = m_requestHeaders.add(name, value); | 927 HTTPHeaderMap::AddResult result = m_requestHeaders.add(name, value); |
928 if (!result.isNewEntry) | 928 if (!result.isNewEntry) |
929 result.iterator->value = result.iterator->value + ", " + value; | 929 result.iterator->value = result.iterator->value + ", " + value; |
930 } | 930 } |
931 | 931 |
932 String XMLHttpRequest::getRequestHeader(const AtomicString& name) const | 932 String XMLHttpRequest::getRequestHeader(const AtomicString& name) const |
933 { | 933 { |
934 return m_requestHeaders.get(name); | 934 return m_requestHeaders.get(name); |
935 } | 935 } |
936 | 936 |
937 String XMLHttpRequest::getAllResponseHeaders(ExceptionCode& ec) const | 937 String XMLHttpRequest::getAllResponseHeaders(ExceptionCode& ec) const |
938 { | 938 { |
939 if (m_state < HEADERS_RECEIVED) { | 939 if (m_state < HEADERS_RECEIVED) { |
940 ec = INVALID_STATE_ERR; | 940 ec = InvalidStateError; |
941 return ""; | 941 return ""; |
942 } | 942 } |
943 | 943 |
944 StringBuilder stringBuilder; | 944 StringBuilder stringBuilder; |
945 | 945 |
946 HTTPHeaderSet accessControlExposeHeaderSet; | 946 HTTPHeaderSet accessControlExposeHeaderSet; |
947 parseAccessControlExposeHeadersAllowList(m_response.httpHeaderField("Access-
Control-Expose-Headers"), accessControlExposeHeaderSet); | 947 parseAccessControlExposeHeadersAllowList(m_response.httpHeaderField("Access-
Control-Expose-Headers"), accessControlExposeHeaderSet); |
948 HTTPHeaderMap::const_iterator end = m_response.httpHeaderFields().end(); | 948 HTTPHeaderMap::const_iterator end = m_response.httpHeaderFields().end(); |
949 for (HTTPHeaderMap::const_iterator it = m_response.httpHeaderFields().begin(
); it!= end; ++it) { | 949 for (HTTPHeaderMap::const_iterator it = m_response.httpHeaderFields().begin(
); it!= end; ++it) { |
950 // Hide Set-Cookie header fields from the XMLHttpRequest client for thes
e reasons: | 950 // Hide Set-Cookie header fields from the XMLHttpRequest client for thes
e reasons: |
(...skipping 15 matching lines...) Expand all Loading... |
966 stringBuilder.append('\r'); | 966 stringBuilder.append('\r'); |
967 stringBuilder.append('\n'); | 967 stringBuilder.append('\n'); |
968 } | 968 } |
969 | 969 |
970 return stringBuilder.toString(); | 970 return stringBuilder.toString(); |
971 } | 971 } |
972 | 972 |
973 String XMLHttpRequest::getResponseHeader(const AtomicString& name, ExceptionCode
& ec) const | 973 String XMLHttpRequest::getResponseHeader(const AtomicString& name, ExceptionCode
& ec) const |
974 { | 974 { |
975 if (m_state < HEADERS_RECEIVED) { | 975 if (m_state < HEADERS_RECEIVED) { |
976 ec = INVALID_STATE_ERR; | 976 ec = InvalidStateError; |
977 return String(); | 977 return String(); |
978 } | 978 } |
979 | 979 |
980 // See comment in getAllResponseHeaders above. | 980 // See comment in getAllResponseHeaders above. |
981 if (isSetCookieHeader(name) && !securityOrigin()->canLoadLocalResources()) { | 981 if (isSetCookieHeader(name) && !securityOrigin()->canLoadLocalResources()) { |
982 logConsoleError(scriptExecutionContext(), "Refused to get unsafe header
\"" + name + "\""); | 982 logConsoleError(scriptExecutionContext(), "Refused to get unsafe header
\"" + name + "\""); |
983 return String(); | 983 return String(); |
984 } | 984 } |
985 | 985 |
986 HTTPHeaderSet accessControlExposeHeaderSet; | 986 HTTPHeaderSet accessControlExposeHeaderSet; |
(...skipping 29 matching lines...) Expand all Loading... |
1016 } | 1016 } |
1017 | 1017 |
1018 int XMLHttpRequest::status(ExceptionCode& ec) const | 1018 int XMLHttpRequest::status(ExceptionCode& ec) const |
1019 { | 1019 { |
1020 if (m_response.httpStatusCode()) | 1020 if (m_response.httpStatusCode()) |
1021 return m_response.httpStatusCode(); | 1021 return m_response.httpStatusCode(); |
1022 | 1022 |
1023 if (m_state == OPENED) { | 1023 if (m_state == OPENED) { |
1024 // Firefox only raises an exception in this state; we match it. | 1024 // Firefox only raises an exception in this state; we match it. |
1025 // Note the case of local file requests, where we have no HTTP response
code! Firefox never raises an exception for those, but we match HTTP case for co
nsistency. | 1025 // Note the case of local file requests, where we have no HTTP response
code! Firefox never raises an exception for those, but we match HTTP case for co
nsistency. |
1026 ec = INVALID_STATE_ERR; | 1026 ec = InvalidStateError; |
1027 } | 1027 } |
1028 | 1028 |
1029 return 0; | 1029 return 0; |
1030 } | 1030 } |
1031 | 1031 |
1032 String XMLHttpRequest::statusText(ExceptionCode& ec) const | 1032 String XMLHttpRequest::statusText(ExceptionCode& ec) const |
1033 { | 1033 { |
1034 if (!m_response.httpStatusText().isNull()) | 1034 if (!m_response.httpStatusText().isNull()) |
1035 return m_response.httpStatusText(); | 1035 return m_response.httpStatusText(); |
1036 | 1036 |
1037 if (m_state == OPENED) { | 1037 if (m_state == OPENED) { |
1038 // See comments in status() above. | 1038 // See comments in status() above. |
1039 ec = INVALID_STATE_ERR; | 1039 ec = InvalidStateError; |
1040 } | 1040 } |
1041 | 1041 |
1042 return String(); | 1042 return String(); |
1043 } | 1043 } |
1044 | 1044 |
1045 void XMLHttpRequest::didFail(const ResourceError& error) | 1045 void XMLHttpRequest::didFail(const ResourceError& error) |
1046 { | 1046 { |
1047 | 1047 |
1048 // If we are already in an error state, for instance we called abort(), bail
out early. | 1048 // If we are already in an error state, for instance we called abort(), bail
out early. |
1049 if (m_error) | 1049 if (m_error) |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1276 info.addMember(m_responseDocument, "responseDocument"); | 1276 info.addMember(m_responseDocument, "responseDocument"); |
1277 info.addMember(m_binaryResponseBuilder, "binaryResponseBuilder"); | 1277 info.addMember(m_binaryResponseBuilder, "binaryResponseBuilder"); |
1278 info.addMember(m_responseArrayBuffer, "responseArrayBuffer"); | 1278 info.addMember(m_responseArrayBuffer, "responseArrayBuffer"); |
1279 info.addMember(m_lastSendURL, "lastSendURL"); | 1279 info.addMember(m_lastSendURL, "lastSendURL"); |
1280 info.addMember(m_eventTargetData, "eventTargetData"); | 1280 info.addMember(m_eventTargetData, "eventTargetData"); |
1281 info.addMember(m_progressEventThrottle, "progressEventThrottle"); | 1281 info.addMember(m_progressEventThrottle, "progressEventThrottle"); |
1282 info.addMember(m_securityOrigin, "securityOrigin"); | 1282 info.addMember(m_securityOrigin, "securityOrigin"); |
1283 } | 1283 } |
1284 | 1284 |
1285 } // namespace WebCore | 1285 } // namespace WebCore |
OLD | NEW |