Allow HTTP transports to have adapter options injected #7261
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.
This is a backport of joomla-framework/http#12 which enables developers to inject additional adapter specific options into our
JHttpTransport
interface implementations. This enables developers to set additional options for the transport that are otherwise unable to be set through the API and potentially override some settings depending on how the transport config is assembled.Also changed with this PR is adding an option to the stream transport to override the path for the cacert.pam file (similar to the curl adapter).
Developer Info
For developers using
JHttp
there are three new "reserved" keys for the options array;transport.curl
,transport.socket
, andtransport.stream
. If usingJHttpFactory::getHttp()
to build your objects (the preferred method), simply add an array for each of these keys with the transport specific options to inject (examples can be found in theJHttpTransportTest::$options
).Testing Instructions
You can place the below text snippet anywhere which will build a
JHttp
object with the extra context options added.Since the transport connection options aren't retrievable via a public API, you'll need to do a
var_dump()
on the object the options are being added to before the connection is initiated (this is going to be environment dependent, usually it will beJHttpTransportCurl
if your environment supports it). You should verify the extra option is included in the options array. Note for curl that the options array's keys will be integers that match the constant's value,CURLOPT_SSL_VERIFYPEER
has a value of 64.