| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 3 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 WebSocketHandshake::Mode WebSocketHandshake::mode() const | 342 WebSocketHandshake::Mode WebSocketHandshake::mode() const |
| 343 { | 343 { |
| 344 return m_mode; | 344 return m_mode; |
| 345 } | 345 } |
| 346 | 346 |
| 347 String WebSocketHandshake::failureReason() const | 347 String WebSocketHandshake::failureReason() const |
| 348 { | 348 { |
| 349 return m_failureReason; | 349 return m_failureReason; |
| 350 } | 350 } |
| 351 | 351 |
| 352 String WebSocketHandshake::serverWebSocketProtocol() const | 352 const AtomicString& WebSocketHandshake::serverWebSocketProtocol() const |
| 353 { | 353 { |
| 354 return m_response.headerFields().get("sec-websocket-protocol"); | 354 return m_response.headerFields().get("sec-websocket-protocol"); |
| 355 } | 355 } |
| 356 | 356 |
| 357 String WebSocketHandshake::serverSetCookie() const | 357 const AtomicString& WebSocketHandshake::serverSetCookie() const |
| 358 { | 358 { |
| 359 return m_response.headerFields().get("set-cookie"); | 359 return m_response.headerFields().get("set-cookie"); |
| 360 } | 360 } |
| 361 | 361 |
| 362 String WebSocketHandshake::serverSetCookie2() const | 362 const AtomicString& WebSocketHandshake::serverSetCookie2() const |
| 363 { | 363 { |
| 364 return m_response.headerFields().get("set-cookie2"); | 364 return m_response.headerFields().get("set-cookie2"); |
| 365 } | 365 } |
| 366 | 366 |
| 367 String WebSocketHandshake::serverUpgrade() const | 367 const AtomicString& WebSocketHandshake::serverUpgrade() const |
| 368 { | 368 { |
| 369 return m_response.headerFields().get("upgrade"); | 369 return m_response.headerFields().get("upgrade"); |
| 370 } | 370 } |
| 371 | 371 |
| 372 String WebSocketHandshake::serverConnection() const | 372 const AtomicString& WebSocketHandshake::serverConnection() const |
| 373 { | 373 { |
| 374 return m_response.headerFields().get("connection"); | 374 return m_response.headerFields().get("connection"); |
| 375 } | 375 } |
| 376 | 376 |
| 377 String WebSocketHandshake::serverWebSocketAccept() const | 377 const AtomicString& WebSocketHandshake::serverWebSocketAccept() const |
| 378 { | 378 { |
| 379 return m_response.headerFields().get("sec-websocket-accept"); | 379 return m_response.headerFields().get("sec-websocket-accept"); |
| 380 } | 380 } |
| 381 | 381 |
| 382 String WebSocketHandshake::acceptedExtensions() const | 382 String WebSocketHandshake::acceptedExtensions() const |
| 383 { | 383 { |
| 384 return m_extensionDispatcher.acceptedExtensions(); | 384 return m_extensionDispatcher.acceptedExtensions(); |
| 385 } | 385 } |
| 386 | 386 |
| 387 const WebSocketHandshakeResponse& WebSocketHandshake::serverHandshakeResponse()
const | 387 const WebSocketHandshakeResponse& WebSocketHandshake::serverHandshakeResponse()
const |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 | 472 |
| 473 statusText = String(space2 + 1, end - space2 - 3); // Exclude "\r\n". | 473 statusText = String(space2 + 1, end - space2 - 3); // Exclude "\r\n". |
| 474 return lineLength; | 474 return lineLength; |
| 475 } | 475 } |
| 476 | 476 |
| 477 const char* WebSocketHandshake::readHTTPHeaders(const char* start, const char* e
nd) | 477 const char* WebSocketHandshake::readHTTPHeaders(const char* start, const char* e
nd) |
| 478 { | 478 { |
| 479 m_response.clearHeaderFields(); | 479 m_response.clearHeaderFields(); |
| 480 | 480 |
| 481 AtomicString name; | 481 AtomicString name; |
| 482 String value; | 482 AtomicString value; |
| 483 bool sawSecWebSocketAcceptHeaderField = false; | 483 bool sawSecWebSocketAcceptHeaderField = false; |
| 484 bool sawSecWebSocketProtocolHeaderField = false; | 484 bool sawSecWebSocketProtocolHeaderField = false; |
| 485 const char* p = start; | 485 const char* p = start; |
| 486 for (; p < end; p++) { | 486 for (; p < end; p++) { |
| 487 size_t consumedLength = parseHTTPHeader(p, end - p, m_failureReason, nam
e, value); | 487 size_t consumedLength = parseHTTPHeader(p, end - p, m_failureReason, nam
e, value); |
| 488 if (!consumedLength) | 488 if (!consumedLength) |
| 489 return 0; | 489 return 0; |
| 490 p += consumedLength; | 490 p += consumedLength; |
| 491 | 491 |
| 492 // Stop once we consumed an empty line. | 492 // Stop once we consumed an empty line. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 520 } | 520 } |
| 521 | 521 |
| 522 String extensions = m_extensionDispatcher.acceptedExtensions(); | 522 String extensions = m_extensionDispatcher.acceptedExtensions(); |
| 523 if (!extensions.isEmpty()) | 523 if (!extensions.isEmpty()) |
| 524 m_response.addHeaderField("Sec-WebSocket-Extensions", extensions); | 524 m_response.addHeaderField("Sec-WebSocket-Extensions", extensions); |
| 525 return p; | 525 return p; |
| 526 } | 526 } |
| 527 | 527 |
| 528 bool WebSocketHandshake::checkResponseHeaders() | 528 bool WebSocketHandshake::checkResponseHeaders() |
| 529 { | 529 { |
| 530 const String& serverWebSocketProtocol = this->serverWebSocketProtocol(); | 530 const AtomicString& serverWebSocketProtocol = this->serverWebSocketProtocol(
); |
| 531 const String& serverUpgrade = this->serverUpgrade(); | 531 const AtomicString& serverUpgrade = this->serverUpgrade(); |
| 532 const String& serverConnection = this->serverConnection(); | 532 const AtomicString& serverConnection = this->serverConnection(); |
| 533 const String& serverWebSocketAccept = this->serverWebSocketAccept(); | 533 const AtomicString& serverWebSocketAccept = this->serverWebSocketAccept(); |
| 534 | 534 |
| 535 if (serverUpgrade.isNull()) { | 535 if (serverUpgrade.isNull()) { |
| 536 m_failureReason = formatHandshakeFailureReason("'Upgrade' header is miss
ing"); | 536 m_failureReason = formatHandshakeFailureReason("'Upgrade' header is miss
ing"); |
| 537 return false; | 537 return false; |
| 538 } | 538 } |
| 539 if (serverConnection.isNull()) { | 539 if (serverConnection.isNull()) { |
| 540 m_failureReason = formatHandshakeFailureReason("'Connection' header is m
issing"); | 540 m_failureReason = formatHandshakeFailureReason("'Connection' header is m
issing"); |
| 541 return false; | 541 return false; |
| 542 } | 542 } |
| 543 if (serverWebSocketAccept.isNull()) { | 543 if (serverWebSocketAccept.isNull()) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 } | 582 } |
| 583 if (!match) { | 583 if (!match) { |
| 584 m_failureReason = formatHandshakeFailureReason("Sent non-empty 'Sec-
WebSocket-Protocol' header but no response is received"); | 584 m_failureReason = formatHandshakeFailureReason("Sent non-empty 'Sec-
WebSocket-Protocol' header but no response is received"); |
| 585 return false; | 585 return false; |
| 586 } | 586 } |
| 587 } | 587 } |
| 588 return true; | 588 return true; |
| 589 } | 589 } |
| 590 | 590 |
| 591 } // namespace WebCore | 591 } // namespace WebCore |
| OLD | NEW |