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

Unified Diff: third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.cpp

Issue 2003253002: [Devtools] Allow User-Agent header override for Websockets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.cpp
diff --git a/third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.cpp b/third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.cpp
index ca91d4b9367fc35e544d558094b396e5dba52f12..8d1bef3f859fef9618e34708ef1ed143ceda51f4 100644
--- a/third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.cpp
+++ b/third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.cpp
@@ -182,7 +182,8 @@ bool DocumentWebSocketChannel::connect(const KURL& url, const String& protocol)
if (document()->frame())
document()->frame()->loader().client()->dispatchWillOpenWebSocket(m_handle.get());
- m_handle->connect(url, webProtocols, WebSecurityOrigin(getExecutionContext()->getSecurityOrigin()), this);
+
+ m_handle->connect(url, webProtocols, WebSecurityOrigin(getExecutionContext()->getSecurityOrigin()), additionalHeaders(), this);
flowControlIfNecessary();
TRACE_EVENT_INSTANT1("devtools.timeline", "WebSocketCreate", TRACE_EVENT_SCOPE_THREAD, "data", InspectorWebSocketCreateEvent::data(document(), m_identifier, url, protocol));
@@ -576,6 +577,15 @@ void DocumentWebSocketChannel::didFailLoadingBlob(FileError::ErrorCode errorCode
// |this| can be deleted here.
}
+const WebString DocumentWebSocketChannel::additionalHeaders()
+{
+ StringBuilder headers;
+ headers.append(HTTPNames::User_Agent);
+ headers.append(':');
+ headers.append(document()->userAgent());
+ return headers.toString();
+}
+
DEFINE_TRACE(DocumentWebSocketChannel)
{
visitor->trace(m_blobLoader);

Powered by Google App Engine
This is Rietveld 408576698