Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(699)

Side by Side Diff: Source/modules/websockets/WebSocketHandshake.cpp

Issue 298893008: Add WebSocket unittests. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/modules/websockets/WebSocket.cpp ('k') | Source/modules/websockets/WebSocketTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 if (serverWebSocketAccept != m_expectedAccept) { 526 if (serverWebSocketAccept != m_expectedAccept) {
527 m_failureReason = formatHandshakeFailureReason("Incorrect 'Sec-WebSocket -Accept' header value"); 527 m_failureReason = formatHandshakeFailureReason("Incorrect 'Sec-WebSocket -Accept' header value");
528 return false; 528 return false;
529 } 529 }
530 if (!serverWebSocketProtocol.isNull()) { 530 if (!serverWebSocketProtocol.isNull()) {
531 if (m_clientProtocol.isEmpty()) { 531 if (m_clientProtocol.isEmpty()) {
532 m_failureReason = formatHandshakeFailureReason("Response must not in clude 'Sec-WebSocket-Protocol' header if not present in request: " + serverWebSo cketProtocol); 532 m_failureReason = formatHandshakeFailureReason("Response must not in clude 'Sec-WebSocket-Protocol' header if not present in request: " + serverWebSo cketProtocol);
533 return false; 533 return false;
534 } 534 }
535 Vector<String> result; 535 Vector<String> result;
536 m_clientProtocol.split(String(WebSocket::subProtocolSeperator()), result ); 536 m_clientProtocol.split(String(WebSocket::subprotocolSeperator()), result );
537 if (!result.contains(serverWebSocketProtocol)) { 537 if (!result.contains(serverWebSocketProtocol)) {
538 m_failureReason = formatHandshakeFailureReason("'Sec-WebSocket-Proto col' header value '" + serverWebSocketProtocol + "' in response does not match a ny of sent values"); 538 m_failureReason = formatHandshakeFailureReason("'Sec-WebSocket-Proto col' header value '" + serverWebSocketProtocol + "' in response does not match a ny of sent values");
539 return false; 539 return false;
540 } 540 }
541 } else if (!m_clientProtocol.isEmpty()) { 541 } else if (!m_clientProtocol.isEmpty()) {
542 m_failureReason = formatHandshakeFailureReason("Sent non-empty 'Sec-WebS ocket-Protocol' header but no response was received"); 542 m_failureReason = formatHandshakeFailureReason("Sent non-empty 'Sec-WebS ocket-Protocol' header but no response was received");
543 return false; 543 return false;
544 } 544 }
545 return true; 545 return true;
546 } 546 }
547 547
548 } // namespace WebCore 548 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/websockets/WebSocket.cpp ('k') | Source/modules/websockets/WebSocketTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698