From 6aa16bbc02a5897200ab70316e0d2a01664afc51 Mon Sep 17 00:00:00 2001 From: Anthon Pang Date: Sun, 5 Apr 2015 15:52:55 -0400 Subject: [PATCH] Update doc/README Add curl service example and remove outdated link to upstream wiki page. --- doc/README.md | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/doc/README.md b/doc/README.md index 48554005..edeff433 100644 --- a/doc/README.md +++ b/doc/README.md @@ -164,4 +164,39 @@ The function's return value is exactly what is returned from the server as part // DELETE /session/:sessionId/window $session->deleteWindow(); -### See also [wiki page of examples](https://github.com/facebook/php-webdriver/wiki/Example-command-reference). +## More esoteric examples + +* To set curl options (e.g., timeout and proxy settings) + +``` +use WebDriver\Service\CurlService; +use WebDriver\ServiceFactory; + +class MyCurlService extends CurlService +{ + const PROXY = 'http://proxyHost:8080'; + const AUTH = 'proxyUser:proxyPassword'; + + /** + * {@inheritdoc} + */ + public function execute($requestMethod, $url, $parameters = null, $extraOptions = null) + { + $extraOptions = array_replace( + $extraOptions, + array( + CURLOPT_CONNECTTIMEOUT => 30, + CURLOPT_TIMEOUT => 300, + CURLOPT_PROXY => self::PROXY, + CURLOPT_PROXYUSERPWD => self::AUTH, + ) + ); + + return parent::execute($requestMethod, $url, $parameters, $extraOptions); + } +} + +ServiceFactory::setServiceClass('service.curl', 'MyCurlService'); +``` + +