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

Side by Side Diff: net/websockets/websocket_job.cc

Issue 6823075: Accept new WebSocket handshake format (hybi-04 and later). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Replace DCHECKs with DVLOG. Created 9 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « net/websockets/websocket_handshake_handler_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/websockets/websocket_job.h" 5 #include "net/websockets/websocket_job.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/string_tokenizer.h" 10 #include "base/string_tokenizer.h"
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 if (delegate_) 264 if (delegate_)
265 delegate_->OnError(socket, error); 265 delegate_->OnError(socket, error);
266 } 266 }
267 267
268 bool WebSocketJob::SendHandshakeRequest(const char* data, int len) { 268 bool WebSocketJob::SendHandshakeRequest(const char* data, int len) {
269 DCHECK_EQ(state_, CONNECTING); 269 DCHECK_EQ(state_, CONNECTING);
270 if (!handshake_request_->ParseRequest(data, len)) 270 if (!handshake_request_->ParseRequest(data, len))
271 return false; 271 return false;
272 272
273 // handshake message is completed. 273 // handshake message is completed.
274 handshake_response_->set_protocol_version(
275 handshake_request_->protocol_version());
274 AddCookieHeaderAndSend(); 276 AddCookieHeaderAndSend();
275 // Just buffered in |handshake_request_|. 277 // Just buffered in |handshake_request_|.
276 return true; 278 return true;
277 } 279 }
278 280
279 void WebSocketJob::AddCookieHeaderAndSend() { 281 void WebSocketJob::AddCookieHeaderAndSend() {
280 int policy = OK; 282 int policy = OK;
281 if (socket_->context()->cookie_policy()) { 283 if (socket_->context()->cookie_policy()) {
282 GURL url_for_cookies = GetURLForCookies(); 284 GURL url_for_cookies = GetURLForCookies();
283 policy = socket_->context()->cookie_policy()->CanGetCookies( 285 policy = socket_->context()->cookie_policy()->CanGetCookies(
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 socket_->Close(); 491 socket_->Close();
490 return; 492 return;
491 } 493 }
492 current_buffer_ = new DrainableIOBuffer( 494 current_buffer_ = new DrainableIOBuffer(
493 send_frame_handler_->GetCurrentBuffer(), 495 send_frame_handler_->GetCurrentBuffer(),
494 send_frame_handler_->GetCurrentBufferSize()); 496 send_frame_handler_->GetCurrentBufferSize());
495 socket_->SendData(current_buffer_->data(), current_buffer_->BytesRemaining()); 497 socket_->SendData(current_buffer_->data(), current_buffer_->BytesRemaining());
496 } 498 }
497 499
498 } // namespace net 500 } // namespace net
OLDNEW
« no previous file with comments | « net/websockets/websocket_handshake_handler_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698