Skip to content

Make HTTPClient.perform mutating#140

Open
guoye-zhang wants to merge 1 commit intoapple:mainfrom
guoye-zhang:client-mutating
Open

Make HTTPClient.perform mutating#140
guoye-zhang wants to merge 1 commit intoapple:mainfrom
guoye-zhang:client-mutating

Conversation

@guoye-zhang
Copy link
Copy Markdown
Contributor

Opening this to start a discussion. Unsure if this is the right change since we needed var client = client in quite a few places. Also needed to change all convenience methods for the concrete client on HTTP to be concrete since an inout argument cannot have a default value.

Resolves #45

fatalError("Waiting for a concrete HTTP server implementation")
}

static func proxy(server: some HTTPServer, client: some HTTPClient) async throws {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make the client inout here instead of the var further down?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not possible since inout cannot be captured in an escaping closure. We do have to make a copy of the client each time to maintain exclusive access in the serve closure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⚠️ semver/major Breaks existing public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[HTTPAPIs] Should HTTPClient.perform be mutating?

2 participants