Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow HTTP transports to have adapter options injected #7261

Closed
wants to merge 1 commit into from
Closed

Allow HTTP transports to have adapter options injected #7261

wants to merge 1 commit into from

Conversation

mbabker
Copy link
Contributor

@mbabker mbabker commented Jun 24, 2015

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, and transport.stream. If using JHttpFactory::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 the JHttpTransportTest::$options).

Testing Instructions

You can place the below text snippet anywhere which will build a JHttp object with the extra context options added.

$extraOptions = array(
    'transport.curl'   => array(CURLOPT_SSL_VERIFYPEER => false),
    'transport.socket' => array('X-Joomla-Test: true'),
    'transport.stream' => array('ignore_errors' => true)
);

$transportOptions = new \Joomla\Registry\Registry($extraOptions);
$transport = JHttpFactory::getHttp($transportOptions);
$transport->get('http://localhost');

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 be JHttpTransportCurl 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.

@Kubik-Rubik
Copy link
Member

Thanks @mbabker! Travis timed out, I've restarted the process.

@wilsonge
Copy link
Contributor

All of the code (unit tests not included) are part of #6692 which is already RTC for 3.5

@mbabker
Copy link
Contributor Author

mbabker commented Jun 24, 2015

Well then merge the darn tests in there and stop making PRs that do a bajillion things (and I actually commented there, geeze) 😛

@mbabker mbabker closed this Jun 24, 2015
@wilsonge
Copy link
Contributor

Only because you told me to use the framework code there because I needed to inject a CURL var :P

@mbabker mbabker deleted the HttpOptions branch October 1, 2015 18:22
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.

None yet

4 participants