Reputation: 147
I am using Websocket protocol, but when I check the request and response content, I find there is no "Content-Type" in the header, which exists in the HTTP protocol.
Here is what I get from Google Developer Tools:
General
Request URL:ws://127.0.0.1:8080/websocket/websocket2
Request Method:GET
Status Code:101 Switching Protocols
Request Headers
Cache-Control:no-cache
Connection:Upgrade
Host:127.0.0.1:8080
Origin:http://127.0.0.1
Pragma:no-cache
Sec-WebSocket-Extensions:permessage-deflate; client_max_window_bits
Sec-WebSocket-Key:6iABBFrV7sdwS4Dz9rqkXw==
Sec-WebSocket-Version:13
Upgrade:websocket
User-Agent: ... Chrome/32.0.1700.102 Safari/537.36
Response Headers
Connection:Upgrade
Sec-WebSocket-Accept:L6wqtsHk6dzD+kd9NCYT6Wt7OCU=
Sec-WebSocket-Extensions:permessage-deflate;client_max_window_bits=15
Server:Apache-Coyote/1.1
Upgrade:WebSocket
In the Request headers and Response Headers sections, there is no "Content-Type".
Is this normal in Websocket protocol?
Thanks.
Upvotes: 5
Views: 6392
Reputation: 4110
HTTP Content-Type
header is meaningless for WebSocket connection.
WebSockets use HTTP only for initial handshake and after WebSocket connection is initialized WebSockets transfers binary or text messages which content type is application defined.
So yes, this is normal behavior for WebSocket protocol.
Upvotes: 7