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

Unix Domain Socket URLs are not idempotent

Open
#343 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

AHC has an interesting quirk with how it supports unix: URLs - if the URL has a baseURL, the path of that base URL is taken as the socket path, and the relative path on top is taken as the path "within" the socket.

Basically it's squishing 2 paths in to the same URL - but not the same URL string, just the URL object. It's just an extremely fragile artefact of Foundation's URL model, and is not idempotent with respect to serialization, the .absoluteURL property, or many of the other modifications people like to make to URLs.

In fact it's so fragile that I'd argue the only way to reliably use this feature is directly in the Request initializer. If that's the case, a new initializer on Request would fulfil that need better (of course, there are also http+unix: URLs if you need to encode the entire request as a URL, and they do not have any of these idempotence issues).

Would it be possible to deprecate and remove the UDS base-path quirk?

Offending code is here - note that the socket path and uri depend on the presence of a base URL.

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 in Sources/AsyncHTTPClient/HTTPHandler.swift around the linked code, where the socket path and URI depend on whether a base URL exists. Trace how Unix domain socket URLs behave through serialization and absoluteURL, then determine the deprecation/removal and Request-initializer changes needed. Done means the fragile base-path behavior is addressed without losing a reliable way to issue requests over Unix domain sockets.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
networking
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.