12.4 · WebSockets, multipart and large transfers, and network path monitoring

Beyond request and response: a connection that stays open, bodies too large for memory, and a network that comes and goes.

Mental model. Three different shapes of traffic: a conversation (WebSocket), a parcel (upload or download) and the road itself (path monitoring).

Connections that stay open

WebSockets with <code>URLSessionWebSocketTask</code>.

  1. How does URLSessionWebSocketTask work, and what do you have to handle yourself? 12.4.1 · L3
    A WebSocket is a long-lived, bidirectional connection that starts as an HTTP request (an upgrade) and then carries framed text or binary messages both ways…

Big bodies and bad networks

Multipart uploads, progress, and <code>NWPathMonitor</code>.

  1. How do you do multipart uploads, large uploads and downloads, and show progress? 12.4.2 · L3
    Multipart form data sends several parts (fields and files) in one request with Content-Type: multipart/form-data; boundary=B. The body is plain text framing…
  2. Why use NWPathMonitor instead of reachability, and how do you use connectivity information correctly? 12.4.3 · L3
    Old reachability (SCNetworkReachability and third-party wrappers) answered “is there a route to a host?” and encouraged a bad pattern: check, then decide…

More in Networking