swift-server / swift-server/async-http-client

HTTPClient.Configuration.init parameter `redirectConfiguration` inconsistently named and suboptimal type

Open
#197 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/enhancement
Dominant language
Swift
Stars
1.1k
Forks
156
PR merge metrics
No merged PRs in 30d

Description

This is quite a minor issue but redirectConfiguration sticks out:

public init(tlsConfiguration: TLSConfiguration? = nil,
            redirectConfiguration: RedirectConfiguration? = nil,
            timeout: Timeout = Timeout(),
            proxy: Proxy? = nil,
            ignoreUncleanSSLShutdown: Bool = false,
            decompression: Decompression = .disabled) {

When I'm initialising a Configuration, I know that I'd be configuring the redirect configuration. I think it should be called redirects: or something similar.

Also, the type isn't great. It shouldn't be optional.

See Xcode's completion (which is accurate):

Screenshot 2020-04-05 at 20 46 56

You'd expect that .none and .disallow are the same but .none secretly means "default" (which is not .disallow). The parameter should be non-optional and default to a new value .default.

We should deprecate this init and also fix the other optional ones.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the HTTPClient.Configuration.init entry point and the RedirectConfiguration definition, then inspect call sites and existing tests for the current optional parameter behavior. Done means the redirect parameter naming and default value are corrected, the initializer is deprecated as requested, and the other optional initializers are addressed with coverage for the public API.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
api
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.