Skip to content

feat: use TLS for https URLs and send Host - #546

Merged
Mzack9999 merged 2 commits into
mainfrom
dwisiswant0/feat/use-TLS-for-https-URLs-and-send-Host
Oct 14, 2026
Merged

Mzack9999 merged 2 commits into
mainfrom
dwisiswant0/feat/use-TLS-for-https-URLs-and-send-Host

Conversation

@dwisiswant0

Copy link
Copy Markdown
Member

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

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>
@dwisiswant0
dwisiswant0 requested a review from Mzack9999 October 14, 2026 20:30
Signed-off-by: Dwi Siswanto <git@dw1.io>
Comment thread pipelineclient.go Dismissed
@Mzack9999
Mzack9999 merged commit 60180f0 into main Oct 14, 2026
7 checks passed
@Mzack9999
Mzack9999 deleted the dwisiswant0/feat/use-TLS-for-https-URLs-and-send-Host branch October 14, 2026 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pipeline client sends https:// requests in plaintext

3 participants