fix: infer ssl option from host protocol in PostHog::init#111
Merged
Conversation
marandaneto
reviewed
Mar 28, 2026
marandaneto
approved these changes
Mar 28, 2026
cleanHost() strips the protocol before QueueConsumer sees the host, so QueueConsumer never detects http:// and defaults ssl to true. This causes requests to http:// hosts (e.g. localhost) to fail silently with curl error 0 as the SDK tries to connect via HTTPS. Now PostHog::init() infers ssl from the host protocol before stripping it, unless the user has explicitly set the ssl option.
3642c24 to
94188f8
Compare
Member
|
@cat-ph https://github.com/PostHog/posthog-php#release-process |
Contributor
Author
|
ah woops, good spot, thanks! |
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.
ran into this small issue when testing against localhost (on http vs https)
Summary
PostHog::cleanHost()strips the protocol from the host beforeQueueConsumersees itQueueConsumerchecks forhttp://prefix to setssl=false, but the protocol is already gone, so it defaults tossl=truehttp://hosts (e.g.localhostfor local dev) to silently fail with curl error 0, as the SDK tries HTTPS against an HTTP serverPostHog::init()inferssslfrom the host protocol before stripping it, unless the user has explicitly set thessloptionChanges
lib/PostHog.php- detect protocol and setssloption beforecleanHost()strips ittest/PostHogTest.php- three new tests: http:// host, https:// host, and http:// via env varTest plan
testInitWithHttpHostSetsSslFalse,testInitWithHttpsHostSetsSslTrue,testInitWithEnvHttpHostSetsSslFalse)