Add Requests::has_capability() which can be used to determine if SSL is available. - #492
Conversation
|
Having a way to test for a capability makes sense, but the We'll rework this in the following way:
|
|
While going through the code to make the changes I suggested above, I noticed an issue with the current implementation. The thing is that the way this is implemented, it always triggers the transport constructor if it has the capabilities, only to then discard that transport (the check returns a boolean only). While the I think this is extremely wasteful for such a simple check. Avoiding this will need a change to the |
095c819 to
09e07df
Compare
|
@jrfnl I can't set you as reviewer, as you've created the PR. Please review this latest change. |
7d50f66 to
9cf8068
Compare
jrfnl
left a comment
There was a problem hiding this comment.
Gone through it in detail and left some comments and questions. I look forward to the next iteration.
|
Oh and one more question: should this method and this new class be mentioned anywhere in the docs/are there docs which need updating for the changes which will now be made ? |
b4a6800 to
0fedc8f
Compare
|
@jrfnl This can be reviewed again. |
There may actually be good reason for this - I think this may be loosely related to #429. |
42c59ad to
5e93ef5
Compare
|
@jrfnl This should be ready for a new review. |
jrfnl
left a comment
There was a problem hiding this comment.
@schlessera Gone through it with a fine toothcomb. Hope I caught everything. Nearly there! Thanks for all your work on this.
3aeacc1 to
0c036e4
Compare
jrfnl
left a comment
There was a problem hiding this comment.
Nearly done, will fix up those last few things now.
0c036e4 to
c643985
Compare
|
Ready for merge IMO |
…is available.
_Note: this is a recreation of PR 251, which was closed due to the branch rename and the remote no longer existing._
Add `Requests::has_capability()` method which can be used to determine if SSL is available.
An example of it's usage: `Requests::has_capability( array( 'ssl' => true ) );`
---
After review of the original PR, the following additional changes have been made and are included in this commit:
* Add a `WpOrg\Requests\Capability` interface which holds constants for the queryable capabilities.
* Split the `Requests::get_transport()` method in two:
* `Requests::get_transport_class()` which will retrieve the fully qualified class name for a working transport and will cache the result.
* `Requests::get_transport()` to get an instantiated instance of a working transport, same as before.
* Adjusting the `Transport` interface and classes implementing it, to take a `$capabilities` parameter for the `test()` method and use the constants from the `Capability` interface internally.
* Add tests for the new `Requests::has_capabilities()` method.
* Update the `Transport` related tests and mocks.
* Add a usage example to the prose documentation.
Co-authored-by: Dion Hulse <contact@dd32.id.au>
Co-authored-by: Alain Schlesser <alain.schlesser@gmail.com>
c643985 to
0038704
Compare
Follow up on #492 Found another place where the `Capability::SSL` constant should be used.
Follow up on #492 Found another place where the `Capability::SSL` constant should be used.
Note: this is a recreation of PR #251, which was closed due to the branch rename and the remote no longer existing.
Please see PR #251 for the original discussion on the PR.
Add
Requests::has_capability()which can be used to determine if SSL is available.An example of it's usage:
Requests::has_capability( array( Capability::SSL => true ) );See #250 and #251
/cc @dd32
After review of the original PR, the following additional changes have been made and are included in this commit:
WpOrg\Requests\Capabilityinterface which holds constants for the queryable capabilities.Requests::get_transport()method in two:Requests::get_transport_class()which will retrieve the fully qualified class name for a working transport and will cache the result.Requests::get_transport()to get an instantiated instance of a working transport, same as before.Transportinterface and classes implementing it, to take a$capabilitiesparameter for thetest()method and use the constants from theCapabilityinterface internally.Requests::has_capabilities()method.Transportrelated tests and mocks.