Designing an HTTP Client API for Swift

Why do we return a tuple here with the response and data separate as opposed to the data being a property on the response?

The HTTPResponse type is used for both the streaming API where the body is delivered as a stream and the convenience API where the body is collected, so it does not contain the body as a property. Though it is possible to define a new struct that contains the response and the data instead of using a tuple.

Is Data the right type to use here or can be configure that?

Data is the currently the best type for the convenience APIs but we are working with the standard library team to explore new bag-of-bytes abstractions that are more efficient.

3 Likes