Skip to content

[4.x] Use the same proxy options in the cURL and stream transports - #87

Open
Hackwar wants to merge 1 commit into
joomla-framework:4.x-devfrom
Hackwar:4.x-proxy-options
Open

Hackwar wants to merge 1 commit into
joomla-framework:4.x-devfrom
Hackwar:4.x-proxy-options

Conversation

@Hackwar

@Hackwar Hackwar commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary of Changes

The proxy support backported from the CMS (b05ab82) made the transports disagree about the proxy options:

  • cURL read the password from proxy.pass, the stream transport from proxy.password; a configuration that worked with one transport sent no proxy credentials with the other, silently. The stream transport also sent no credentials when the password was empty, cURL did.
  • cURL built host:port even when either was missing (:8080, proxy:); the stream transport then silently connected without the proxy (while still sending the full URI in the request line).
  • The socket transport ignores proxy.* entirely, so with that transport selected requests bypassed the configured proxy without any notice.
  • The new cURL code used unqualified CURLOPT_PROXY/CURLOPT_PROXYUSERPWD, unlike the rest of the file.

Now both cURL and stream:

  • accept proxy.pass (canonical, as in the CMS) and proxy.password (alias);
  • send credentials whenever proxy.user is set;
  • throw an InvalidArgumentException when proxy.enabled is set without proxy.host or proxy.port, instead of sending a broken or proxy-less request.

The stream transport passes the proxy as tcp://host:port, the form PHP documents. The socket transport raises an E_USER_WARNING when proxy.enabled is set and still connects directly, which keeps 4.x behaviour apart from the notice. Throwing instead would be the stricter choice (for 5.x, if the socket transport stays).

Testing Instructions

Tests/Transport/ProxyOptionsTest.php (new). The stub server doubles as the proxy: PHP's built-in server answers a request with an absolute URI in the request line, and the stub reports the URI and the Proxy-Authorization header it received (jhttp_stub.php now echoes the request headers, the same line as in #86).

  • cURL and stream, each with proxy.pass and with proxy.password: the request goes through the proxy with the right credentials (before: cURL with proxy.password and stream with proxy.pass sent none);
  • cURL and stream without host or without port: InvalidArgumentException;
  • socket with proxy.enabled: one E_USER_WARNING, request still served.

Documentation Changes Required

docs/classes/TransportInterface.md: the proxy.* options are added to the options table, and the socket note says that it cannot use a proxy.

🤖 Generated with Claude Code

The cURL transport read the proxy password from proxy.pass and the stream
transport from proxy.password, so a configuration that worked with one
transport silently sent no proxy credentials with the other. cURL built
"host:port" even when either was missing, while the stream transport then
silently connected without the proxy. The socket transport ignored the
proxy options without any notice.

Accept both password option names in both transports, require proxy.host
and proxy.port when proxy.enabled is set, and raise a warning in the socket
transport, which cannot use a proxy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant