Repository navigation
Accept Unix domain socket addresses in the connection URI - #94
Open
vegardkrogh wants to merge 1 commit into
Open
vegardkrogh wants to merge 1 commit into
vegardkrogh wants to merge 1 commit into
Conversation
Mint and OTP's local address family already support connecting to
`{:local, path}` with port 0, but Slipstream rejected such a URI during
configuration validation and passed the URI host and port to Mint
unchanged.
- `Slipstream.Configuration` accepts port 0 when the URI host is
`{:local, path}`.
- `Slipstream.Connection.Impl.http_connect/1` connects to `{:local, path}`
with port 0 and sets the `:hostname` option Mint requires for a
non-binary address (default "localhost").
- The WebSocket upgrade request sends `Host: <hostname>` for such an
address unless a Host header is given, since Mint would otherwise send
`Host: localhost:0`, which Cowboy rejects with a 400.
Usage:
uri: %URI{scheme: "ws", host: {:local, "/path/to.sock"}, port: 0,
path: "/socket/websocket"}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This lets a client connect to a server listening on a Unix domain socket.
Mint and OTP already support the address
{:local, path}with port 0. Slipstream's URI validation and its connect call were the only blockers.Changes
Slipstream.Configurationaccepts port 0 when the URI host is{:local, path}. Port 0 with a binary host is still rejected.Slipstream.Connection.Impl.http_connect/1gets a new first clause for such a URI. It hands Mint{:local, path}with port 0 and sets the:hostnameoption that Mint requires for a non-binary address, defaulting to"localhost".Host: <hostname>for such a URI unless the caller gives a Host header. Without it, Mint sendsHost: localhost:0, which Cowboy rejects with a 400.@dialyzernowarn, the same waypath/1does. Mint's success typing narrows the address to a binary, although its spec and code accept any:inet.socket_address().:urioption docs describe the new form.Usage
Tests
Plug.Cowboyand connect with and without a given Host header.mix test --warnings-as-errorspasses with 96 tests, andmix format --check-formattedandmix dialyzerpass.mix coverallsreports 100% for both changed files. The total is 99.3%, the same asmainlocally, because of existing gaps inslipstream.ex,pipeline.exandevents.ex.I left the changelog alone because entries are added at release time.