Adds switchable http clients with configuration options #290
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 for #59, dating back to late 2014. It addresses the issue that not everyone can use the same transport layer to power the sdk. For example curl may not be available (or discouraged) over an alternative implementation. One such case would be the http api on wordpress. In a general sense environments where the user does not have control over their php installation should be given a variety of http clients to choose from.
This introduces pluggable transport layers, where the underlying http client may be changed using either one of the provided clients or even a custom user implementation. This PR provides two such clients,
ParseCurlHttpClient
andParseStreamHttpClient
, where the former is the default.Setting a client can be achieved via the newly added
ParseClient::setHttpClient
as follows:This is closely related to facebook's implementation in their php graph sdk. To that end there is a
ParseHttpable
interface which can be implemented to provide additional transport layers. Http clients can implement this to provide additional choices, such as in the case of wordpress (but not included in this PR).Additionally in some shared hosting implementations it may be required to provide an alternative CA bundle, which if not present could lead to an inability to verify peer's certificates. To account for this I have added
ParseClient::setCAFile
and updated the README with an appropriate usage (including a brief explanation of where to obtain a bundle). I have seen some instances of individuals attempting to disable peer verification to bypass such issues. This should incentivize trying to set an alternative CA bundle instead over disabling verification altogether.The README and tests have been updated to document and cover this newly added functionality.