Repository navigation
feat: use TLS for https URLs and send Host - #546
Merged
Mzack9999 merged 2 commits intoOct 14, 2026
Merged
Conversation
PipelineClient.do() parsed the request URL but kept only the path and query, and NewPipelineClient() never set IsTLS on the underlying clientpipeline.PipelineClient. Every request went out in plaintext, even for https URLs, and TLS servers answered 400 "Client sent an HTTP request to an HTTPS server". PipelineOptions.AutomaticHostHeader, true by default, was never read either, so requests had no Host header and net/http servers answered 400 "missing required Host header". Use the URL scheme and host, as Client.do() already does. Keep one clientpipeline.PipelineClient per scheme and pick it by the URL scheme. Both dial lazily, so the unused one opens no connections. As in Client, TLS skips certificate verification. When AutomaticHostHeader is set, send the URL host as the first header unless the caller already set Host (any case) or the URL has no host. Unlike Client, keep a caller-supplied Host, so existing pipeline callers send the same Host as before. Also set WriteTimeout to Timeout. Without it, the TLS handshake runs on the first write. A request larger than the 4 KiB write buffer is flushed before the reader sets a read deadline, so a server that never answers the handshake blocks the request forever. With WriteTimeout set, dialAddr() runs the handshake up front under that deadline. Plaintext writes get the same deadline, as in Client. Fixes #545 Signed-off-by: Dwi Siswanto <git@dw1.io>
Signed-off-by: Dwi Siswanto <git@dw1.io>
Mzack9999
approved these changes
Oct 14, 2026
Mzack9999
deleted the
dwisiswant0/feat/use-TLS-for-https-URLs-and-send-Host
branch
October 14, 2026 21:02
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.
PipelineClient.do() parsed the request URL but kept only the path and
query, and NewPipelineClient() never set IsTLS on the underlying
clientpipeline.PipelineClient. Every request went out in plaintext,
even for https URLs, and TLS servers answered
400 "Client sent an HTTP request to an HTTPS server".
PipelineOptions.AutomaticHostHeader, true by default, was never read
either, so requests had no Host header and net/http servers answered
400 "missing required Host header".
Use the URL scheme and host, as Client.do() already does. Keep one
clientpipeline.PipelineClient per scheme and pick it by the URL scheme.
Both dial lazily, so the unused one opens no connections. As in Client,
TLS skips certificate verification.
When AutomaticHostHeader is set, send the URL host as the first header
unless the caller already set Host (any case) or the URL has no host.
Unlike Client, keep a caller-supplied Host, so existing pipeline callers
send the same Host as before.
Also set WriteTimeout to Timeout. Without it, the TLS handshake runs on
the first write. A request larger than the 4 KiB write buffer is flushed
before the reader sets a read deadline, so a server that never answers
the handshake blocks the request forever. With WriteTimeout set,
dialAddr() runs the handshake up front under that deadline. Plaintext
writes get the same deadline, as in Client.
Fixes #545