Skip to content

[3.0] Use stream_socket_client instead of fsocketopen if possible - #9861

Open
jdarwood007 wants to merge 1 commit into
SimpleMachines:release-3.0from
jdarwood007:3.0/fixes9803
Open

jdarwood007 wants to merge 1 commit into
SimpleMachines:release-3.0from
jdarwood007:3.0/fixes9803

Conversation

@jdarwood007

Copy link
Copy Markdown
Member

Fixes #9803

@jdarwood007 jdarwood007 added this to the 3.0 Alpha 5 milestone Nov 10, 2026
@github-actions github-actions Bot added the External data Fetching, processing, and using external data label Nov 10, 2026
@albertlast

Copy link
Copy Markdown
Collaborator

Connecting to the address from getIPs() fixes #9803 when that connection succeeds. Normal HTTP and HTTPS fetches behaved the same as release-3.0 in my tests. The fsockopen() fallback is the concern.

$this->host no longer carries ssl://, so for an HTTPS URL the fallback opens a plain TCP connection to port 443 and sends plain HTTP over it. To test this I put an address that does not answer on 443 (198.41.0.4) at the front of Url::$ips for example.com, with the real addresses after it, and fetched https://example.com/index.html with SocketFetcher:

time code
release-3.0 67 ms 404 (the page's own answer)
this PR 5042 ms 400 (plain HTTP sent to the HTTPS port)

The connected address is one of the real ones, so the "did we connect where we expected" check passes, and the 400 is returned as the response.

Two more things:

  • Only $ips[0] is tried. Trying each address from getIPs() in turn would cover an unreachable first address without the fallback. The fallback resolves the name again through the system resolver, which is the mismatch [2.1|3.0] url_resolves_to fails due to caching and low TTL #9803 is about.
  • isV6() and isV4() have @return bool with no description.

@jdarwood007

Copy link
Copy Markdown
Member Author

Good catch on the host fix. I dumped the protocol off host because we use it later in the host command we issue to the server, which would result in it being sent with the protocol and that isn't right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

External data Fetching, processing, and using external data

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[2.1|3.0] url_resolves_to fails due to caching and low TTL

2 participants