HttpRequestTask and https
Is it possible to perfo开发者_运维知识库rm request to https
using http-request
phing task?
If no - what workaround could you propose? wget
?
Yes, you are not limited to HTTP only - HTTPS works fine.
Examples are shown in the phing documentation:
<http-request url="https://accounts.google.com/"/>
Alternatively, you can use the curl adapter:
<http-request url="https://accounts.google.com/" verbose="true">
<config name="adapter" value="HTTP_Request2_Adapter_Curl"/>
</http-request>
It seems that by default you won't be able to connect using https. This is because the Phing http task uses the PEAR HTTP_Request2 libraries to make the connection. That in turn uses either PHP curl or sockets to make the connection. When connecting to https it needs to verify the CA certificate. That can be switched off so any certificate is supported but the Phing task doesn't support passing the option over to HTTP_Request2.
So if you otherwise like the Phing http task I suggest you either copy and modify the task or write your own that extends the original one so it supports the ssl_verify_peer
option.
Or you can always default to the exec
task and fetch whatever you need using curl of wget which however might not work on multiple platforms.
Here are links where you find more info:
- PEAR HTTP_Request2 configuration options
- Source code of the Phing http task
- HTTP_Request2 info about https and proxy servers (Search for https)
- How to write your own Phing task
精彩评论