diff options
author | yhirano@chromium.org <yhirano@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-21 09:47:07 +0000 |
---|---|---|
committer | yhirano@chromium.org <yhirano@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-21 09:47:07 +0000 |
commit | 4678ae5f82502379568e39cb2de605bc4cbd60dc (patch) | |
tree | 7664ac93844466f8fde0d97eb1dc00907502f411 | |
parent | 22ac03beb9b78123576eca8ef265250b686fdca6 (diff) | |
download | chromium_src-4678ae5f82502379568e39cb2de605bc4cbd60dc.zip chromium_src-4678ae5f82502379568e39cb2de605bc4cbd60dc.tar.gz chromium_src-4678ae5f82502379568e39cb2de605bc4cbd60dc.tar.bz2 |
[WebSocket] Send (request|response)_headers_text to the inspector.
BUG=327581
Review URL: https://codereview.chromium.org/153843004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@252526 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/browser/renderer_host/websocket_host.cc | 9 | ||||
-rw-r--r-- | content/child/websocket_bridge.cc | 2 | ||||
-rw-r--r-- | content/common/websocket.h | 4 | ||||
-rw-r--r-- | content/common/websocket_messages.h | 2 |
4 files changed, 17 insertions, 0 deletions
diff --git a/content/browser/renderer_host/websocket_host.cc b/content/browser/renderer_host/websocket_host.cc index 48b04b0..b4a7cee 100644 --- a/content/browser/renderer_host/websocket_host.cc +++ b/content/browser/renderer_host/websocket_host.cc @@ -11,6 +11,7 @@ #include "ipc/ipc_message_macros.h" #include "net/http/http_request_headers.h" #include "net/http/http_response_headers.h" +#include "net/http/http_util.h" #include "net/websockets/websocket_channel.h" #include "net/websockets/websocket_event_interface.h" #include "net/websockets/websocket_frame.h" // for WebSocketFrameHeader::OpCode @@ -178,6 +179,11 @@ ChannelState WebSocketEventHandler::OnStartOpeningHandshake( net::HttpRequestHeaders::Iterator it(request->headers); while (it.GetNext()) request_to_pass.headers.push_back(std::make_pair(it.name(), it.value())); + request_to_pass.headers_text = + base::StringPrintf("GET %s HTTP/1.1\r\n", + request_to_pass.url.spec().c_str()) + + request->headers.ToString(); + request_to_pass.request_time = request->request_time; return StateCast(dispatcher_->SendStartOpeningHandshake(routing_id_, request_to_pass)); @@ -195,6 +201,9 @@ ChannelState WebSocketEventHandler::OnFinishOpeningHandshake( std::string name, value; while (response->headers->EnumerateHeaderLines(&iter, &name, &value)) response_to_pass.headers.push_back(std::make_pair(name, value)); + response_to_pass.headers_text = + net::HttpUtil::ConvertHeadersBackToHTTPResponse( + response->headers->raw_headers()); response_to_pass.response_time = response->response_time; return StateCast(dispatcher_->SendFinishOpeningHandshake(routing_id_, response_to_pass)); diff --git a/content/child/websocket_bridge.cc b/content/child/websocket_bridge.cc index e61ba87..15a92dc 100644 --- a/content/child/websocket_bridge.cc +++ b/content/child/websocket_bridge.cc @@ -106,6 +106,7 @@ void WebSocketBridge::DidStartOpeningHandshake( request_to_pass.addHeaderField(WebString::fromLatin1(header.first), WebString::fromLatin1(header.second)); } + request_to_pass.setHeadersText(WebString::fromLatin1(request.headers_text)); client_->didStartOpeningHandshake(this, request_to_pass); } @@ -122,6 +123,7 @@ void WebSocketBridge::DidFinishOpeningHandshake( response_to_pass.addHeaderField(WebString::fromLatin1(header.first), WebString::fromLatin1(header.second)); } + response_to_pass.setHeadersText(WebString::fromLatin1(response.headers_text)); client_->didFinishOpeningHandshake(this, response_to_pass); } diff --git a/content/common/websocket.h b/content/common/websocket.h index f6f8ddb..1081318 100644 --- a/content/common/websocket.h +++ b/content/common/websocket.h @@ -32,6 +32,8 @@ struct WebSocketHandshakeRequest { GURL url; // Additional HTTP request headers std::vector<std::pair<std::string, std::string> > headers; + // HTTP request headers raw string + std::string headers_text; // The time that this request is sent base::Time request_time; }; @@ -50,6 +52,8 @@ struct WebSocketHandshakeResponse { std::string status_text; // Additional HTTP response headers std::vector<std::pair<std::string, std::string> > headers; + // HTTP response headers raw string + std::string headers_text; // The time that this response arrives base::Time response_time; }; diff --git a/content/common/websocket_messages.h b/content/common/websocket_messages.h index b158f48..20fef1e 100644 --- a/content/common/websocket_messages.h +++ b/content/common/websocket_messages.h @@ -32,6 +32,7 @@ IPC_ENUM_TRAITS_MAX_VALUE(content::WebSocketMessageType, IPC_STRUCT_TRAITS_BEGIN(content::WebSocketHandshakeRequest) IPC_STRUCT_TRAITS_MEMBER(url) IPC_STRUCT_TRAITS_MEMBER(headers) + IPC_STRUCT_TRAITS_MEMBER(headers_text) IPC_STRUCT_TRAITS_MEMBER(request_time) IPC_STRUCT_TRAITS_END() @@ -40,6 +41,7 @@ IPC_STRUCT_TRAITS_BEGIN(content::WebSocketHandshakeResponse) IPC_STRUCT_TRAITS_MEMBER(status_code) IPC_STRUCT_TRAITS_MEMBER(status_text) IPC_STRUCT_TRAITS_MEMBER(headers) + IPC_STRUCT_TRAITS_MEMBER(headers_text) IPC_STRUCT_TRAITS_MEMBER(response_time) IPC_STRUCT_TRAITS_END() |