apple / apple/swift-http-api-proposal

[HTTPClient] RequestBody can not be declared without knowing about the specific implementation

Open
#56 0 comments 0 reactions 0 assignees View on GitHub
http-client kind/usability
Dominant language
Swift
Stars
66
Forks
21
Avg merge
7h 39m
Merged PRs (30d)
2

Description

This code does not compile:

```swift
@available(macOS 26.2, *)
struct WhateverAPI2 {

func doPost() async throws -> String {
let request = HTTPRequest(method: .get, scheme: "https", authority: "www.example.com", path: "/foo")

// This doesn't have sufficient type info and therefore fails to compile
let body = HTTPClientRequestBody.restartable { writer in

}
}
}
```

Users would need to specify the writers, if they use a generic type:
```swift
let body = HTTPClientRequestBody.restartable { writer in

}
```

I don't think, this is a beginner friendly API.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.