WebSockets vs REST API (HTTP): Which One Should You Use?

Поделиться
HTML-код
  • Опубликовано: 24 окт 2024

Комментарии • 5

  • @TheCodingGopher
    @TheCodingGopher  8 дней назад +3

    1:27
    In WebSockets, header negotiation happens during the initial HTTP handshake where the client and server exchange headers to agree on upgrading the connection from HTTP to WebSocket. This process ensures that both parties support the WebSocket protocol before the connection is upgraded.
    2:47
    A 101 Switching Protocols message is an HTTP status code that indicates that the server has agreed to switch protocols as requested by the client. This message is commonly seen during the WebSocket handshake process.
    In the context of WebSockets, the client first sends a standard HTTP request with a special header (Upgrade: websocket) requesting to switch to the WebSocket protocol. If the server supports WebSockets, it replies with a 101 Switching Protocols response, signaling that it is switching from HTTP to the WebSocket protocol for that connection.
    Example server response:
    ```
    HTTP/1.1 101 Switching Protocols
    Upgrade: websocket
    Connection: Upgrade
    ```
    3:22
    A frame-based protocol structures data into small, discrete packets called "frames" that are sent between the client and server. Frames are units of data transmission and can carry different types of data, including text, binary, control information, etc. In WebSocket, after the connection is established, messages are sent in frames rather than traditional HTTP messages. A WebSocket message is typically composed of one or more frames. Each frame contains a small piece of the message, allowing for efficient and continuous data streaming.
    5:04
    Control frames can signal things like connection closure, while data frames can carry actual message content. WebSocket frames are smaller than HTTP messages because they omit headers and other overhead, making communication more efficient for real-time data.

  • @ThingsUploadedbyMe33
    @ThingsUploadedbyMe33 8 дней назад +3

    Kudos for the blue key highlighting the connection lifecycle at 0:40, subtle but makes it much clearer
    my issue with the audio is just the loudness, if possible to increase it a bit post editing (watched on 150% vol)
    Thanks for the clear video, top notch

  • @abi69169
    @abi69169 7 дней назад +2

    110 sub but giving 1 million sub content