1Z0-900 · Question #55
Which statement is true about the relationship between HTTP and WebSockets?
The correct answer is D. A WebSocket connection uses HTTP protocol to exchange data with the browser. Important note: The stated correct answer appears to be incorrect. Based on how WebSockets actually work, B is the true answer, not D. Why B is correct: A WebSocket connection begins with an HTTP GET request that includes an Upgrade: websocket header. The server responds with…
Question
Which statement is true about the relationship between HTTP and WebSockets?
Options
- AA WebSocket connection is a bi-directional HTTP session with message-handling support.
- BA WebSocket connection is initialized with an HTTP handshake.
- CA WebSocket connection can be initialized by either client or server.
- DA WebSocket connection uses HTTP protocol to exchange data with the browser.
How the community answered
(65 responses)- A2% (1)
- B2% (1)
- C3% (2)
- D94% (61)
Explanation
Important note: The stated correct answer appears to be incorrect. Based on how WebSockets actually work, B is the true answer, not D.
Why B is correct: A WebSocket connection begins with an HTTP GET request that includes an Upgrade: websocket header. The server responds with 101 Switching Protocols, completing the handshake and elevating the connection from HTTP to the WebSocket protocol. After that point, HTTP is no longer involved.
Why D is wrong: Once established, a WebSocket connection does not use HTTP to exchange data - it uses its own lightweight frame-based protocol over a persistent TCP connection. HTTP is only involved at initialization, not data exchange.
Why A is wrong: WebSocket is not an HTTP session at all; it replaces HTTP after the handshake with a distinct protocol.
Why C is wrong: WebSocket connections can only be initiated by the client (browser), not the server - that's a fundamental constraint of the protocol.
Memory tip: Think of WebSocket as a tenant who moves into an HTTP apartment (the handshake), then converts it into something completely different. HTTP gets it started; WebSocket takes over from there.
If this came from a practice exam or course material, I'd recommend flagging it - B is the industry-standard correct answer for this question. Answering D on a real exam would likely cost you the point.
Topics
Community Discussion
No community discussion yet for this question.