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

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

Issue 158453004: [ABANDONED] [WebSocket] Remove the trailing slash from the origin header. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 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 | « no previous file | net/websockets/websocket_stream_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_stream.h" 5 #include "net/websockets/websocket_stream.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "net/http/http_request_headers.h" 9 #include "net/http/http_request_headers.h"
10 #include "net/http/http_status_code.h" 10 #include "net/http/http_status_code.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 139
140 void Delegate::OnReadCompleted(URLRequest* request, int bytes_read) { 140 void Delegate::OnReadCompleted(URLRequest* request, int bytes_read) {
141 NOTREACHED(); 141 NOTREACHED();
142 } 142 }
143 143
144 // Internal implementation of CreateAndConnectStream and 144 // Internal implementation of CreateAndConnectStream and
145 // CreateAndConnectStreamForTesting. 145 // CreateAndConnectStreamForTesting.
146 scoped_ptr<WebSocketStreamRequest> CreateAndConnectStreamWithCreateHelper( 146 scoped_ptr<WebSocketStreamRequest> CreateAndConnectStreamWithCreateHelper(
147 const GURL& socket_url, 147 const GURL& socket_url,
148 scoped_ptr<WebSocketHandshakeStreamCreateHelper> create_helper, 148 scoped_ptr<WebSocketHandshakeStreamCreateHelper> create_helper,
149 const GURL& origin, 149 const GURL& origin_url,
150 URLRequestContext* url_request_context, 150 URLRequestContext* url_request_context,
151 const BoundNetLog& net_log, 151 const BoundNetLog& net_log,
152 scoped_ptr<WebSocketStream::ConnectDelegate> connect_delegate) { 152 scoped_ptr<WebSocketStream::ConnectDelegate> connect_delegate) {
153 scoped_ptr<StreamRequestImpl> request( 153 scoped_ptr<StreamRequestImpl> request(
154 new StreamRequestImpl(socket_url, 154 new StreamRequestImpl(socket_url,
155 url_request_context, 155 url_request_context,
156 connect_delegate.Pass(), 156 connect_delegate.Pass(),
157 create_helper.get())); 157 create_helper.get()));
158 HttpRequestHeaders headers; 158 HttpRequestHeaders headers;
159 std::string origin;
160 if (origin_url.is_valid()) {
161 // GURL::spec() adds a slash at the end of an origin,
162 // so we construct the origin string representation by hand.
163 origin = origin_url.scheme() + "://" + origin_url.host();
164 if (origin_url.has_port())
165 origin += ":" + origin_url.port();
166 } else {
167 origin = "null";
168 }
169
159 headers.SetHeader(websockets::kUpgrade, websockets::kWebSocketLowercase); 170 headers.SetHeader(websockets::kUpgrade, websockets::kWebSocketLowercase);
160 headers.SetHeader(HttpRequestHeaders::kConnection, websockets::kUpgrade); 171 headers.SetHeader(HttpRequestHeaders::kConnection, websockets::kUpgrade);
161 headers.SetHeader(HttpRequestHeaders::kOrigin, origin.spec()); 172 headers.SetHeader(HttpRequestHeaders::kOrigin, origin);
162 // TODO(ricea): Move the version number to websocket_handshake_constants.h 173 // TODO(ricea): Move the version number to websocket_handshake_constants.h
163 headers.SetHeader(websockets::kSecWebSocketVersion, 174 headers.SetHeader(websockets::kSecWebSocketVersion,
164 websockets::kSupportedVersion); 175 websockets::kSupportedVersion);
165 request->url_request()->SetExtraRequestHeaders(headers); 176 request->url_request()->SetExtraRequestHeaders(headers);
166 request->url_request()->SetUserData( 177 request->url_request()->SetUserData(
167 WebSocketHandshakeStreamBase::CreateHelper::DataKey(), 178 WebSocketHandshakeStreamBase::CreateHelper::DataKey(),
168 create_helper.release()); 179 create_helper.release());
169 request->url_request()->SetLoadFlags(LOAD_DISABLE_CACHE | 180 request->url_request()->SetLoadFlags(LOAD_DISABLE_CACHE |
170 LOAD_BYPASS_CACHE | 181 LOAD_BYPASS_CACHE |
171 LOAD_DO_NOT_PROMPT_FOR_LOGIN); 182 LOAD_DO_NOT_PROMPT_FOR_LOGIN);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 scoped_ptr<WebSocketStream::ConnectDelegate> connect_delegate) { 221 scoped_ptr<WebSocketStream::ConnectDelegate> connect_delegate) {
211 return CreateAndConnectStreamWithCreateHelper(socket_url, 222 return CreateAndConnectStreamWithCreateHelper(socket_url,
212 create_helper.Pass(), 223 create_helper.Pass(),
213 origin, 224 origin,
214 url_request_context, 225 url_request_context,
215 net_log, 226 net_log,
216 connect_delegate.Pass()); 227 connect_delegate.Pass());
217 } 228 }
218 229
219 } // namespace net 230 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/websockets/websocket_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698