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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/websockets/websocket_stream_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/websockets/websocket_stream.cc
diff --git a/net/websockets/websocket_stream.cc b/net/websockets/websocket_stream.cc
index 507ed9dadde4237a5b549e32bc16dcf851b0c756..794aca4a3d5160c8bb7173700f428ea6d9988c7c 100644
--- a/net/websockets/websocket_stream.cc
+++ b/net/websockets/websocket_stream.cc
@@ -146,7 +146,7 @@ void Delegate::OnReadCompleted(URLRequest* request, int bytes_read) {
scoped_ptr<WebSocketStreamRequest> CreateAndConnectStreamWithCreateHelper(
const GURL& socket_url,
scoped_ptr<WebSocketHandshakeStreamCreateHelper> create_helper,
- const GURL& origin,
+ const GURL& origin_url,
URLRequestContext* url_request_context,
const BoundNetLog& net_log,
scoped_ptr<WebSocketStream::ConnectDelegate> connect_delegate) {
@@ -156,9 +156,20 @@ scoped_ptr<WebSocketStreamRequest> CreateAndConnectStreamWithCreateHelper(
connect_delegate.Pass(),
create_helper.get()));
HttpRequestHeaders headers;
+ std::string origin;
+ if (origin_url.is_valid()) {
+ // GURL::spec() adds a slash at the end of an origin,
+ // so we construct the origin string representation by hand.
+ origin = origin_url.scheme() + "://" + origin_url.host();
+ if (origin_url.has_port())
+ origin += ":" + origin_url.port();
+ } else {
+ origin = "null";
+ }
+
headers.SetHeader(websockets::kUpgrade, websockets::kWebSocketLowercase);
headers.SetHeader(HttpRequestHeaders::kConnection, websockets::kUpgrade);
- headers.SetHeader(HttpRequestHeaders::kOrigin, origin.spec());
+ headers.SetHeader(HttpRequestHeaders::kOrigin, origin);
// TODO(ricea): Move the version number to websocket_handshake_constants.h
headers.SetHeader(websockets::kSecWebSocketVersion,
websockets::kSupportedVersion);
« 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