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

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

Issue 314083002: parseHTTPHeaders should return the number of consumed bytes. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@async-initializer
Patch Set: 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
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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 445
446 const char* WebSocketHandshake::readHTTPHeaders(const char* start, const char* e nd) 446 const char* WebSocketHandshake::readHTTPHeaders(const char* start, const char* e nd)
447 { 447 {
448 m_response.clearHeaderFields(); 448 m_response.clearHeaderFields();
449 449
450 AtomicString name; 450 AtomicString name;
451 AtomicString value; 451 AtomicString value;
452 bool sawSecWebSocketAcceptHeaderField = false; 452 bool sawSecWebSocketAcceptHeaderField = false;
453 bool sawSecWebSocketProtocolHeaderField = false; 453 bool sawSecWebSocketProtocolHeaderField = false;
454 const char* p = start; 454 const char* p = start;
455 for (; p < end; p++) { 455 while (p < end) {
456 size_t consumedLength = parseHTTPHeader(p, end - p, m_failureReason, nam e, value); 456 size_t consumedLength = parseHTTPHeader(p, end - p, m_failureReason, nam e, value);
457 if (!consumedLength) 457 if (!consumedLength)
458 return 0; 458 return 0;
459 p += consumedLength; 459 p += consumedLength;
460 460
461 // Stop once we consumed an empty line. 461 // Stop once we consumed an empty line.
462 if (name.isEmpty()) 462 if (name.isEmpty())
463 break; 463 break;
464 464
465 // Sec-WebSocket-Extensions may be split. We parse and check the 465 // Sec-WebSocket-Extensions may be split. We parse and check the
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 | « no previous file | Source/platform/network/HTTPParsers.cpp » ('j') | Source/platform/network/HTTPRequest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698