HTTP Response Validation is the process of checking whether a network request was successful or failed.
It is done using the status code returned by the server.
Request sent
↓
Response received
↓
Check status code
↓
Success or Failure
The response from a request must be cast to:
HTTPURLResponse
Example:
guard let httpResponse = response as? HTTPURLResponse else { return }
This provides access to:
statusCode
headers
Status codes indicate the result of a request.
200 → OK
201 → Created
204 → No Content