當前位置: 首頁>>代碼示例>>PHP>>正文


PHP HTTP_Request2::getConfig方法代碼示例

本文整理匯總了PHP中HTTP_Request2::getConfig方法的典型用法代碼示例。如果您正苦於以下問題:PHP HTTP_Request2::getConfig方法的具體用法?PHP HTTP_Request2::getConfig怎麽用?PHP HTTP_Request2::getConfig使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在HTTP_Request2的用法示例。


在下文中一共展示了HTTP_Request2::getConfig方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: buildEnvironment

 /**
  * Builds an array of post, get and server settings.
  * 
  * @return array
  */
 public function buildEnvironment(HTTP_Request2 $request)
 {
     $environment = array('_POST' => array(), '_GET' => array(), '_SERVER' => array());
     if ($request->getPostParams()) {
         $environment['_POST'] = $request->getPostParams();
     }
     $query = $request->getUrl()->getQuery();
     if (!empty($query)) {
         parse_str($query, $environment['_GET']);
     }
     $environment['_SERVER'] = $this->getServerGlobal($request->getConfig('host'), dirname($request->getConfig('index_file')), $request->getUrl(), $request->getMethod());
     return $environment;
 }
開發者ID:runekaagaard,項目名稱:php-cli-http,代碼行數:18,代碼來源:CliAdapter.php

示例2: testConfigurationViaProperties

 public function testConfigurationViaProperties()
 {
     $trace = new TraceHttpAdapter();
     $this->copyTasksAddingCustomRequest('config-properties', 'recipient', $this->createRequest($trace));
     $this->executeTarget('recipient');
     $request = new HTTP_Request2(null, 'GET', array('proxy' => 'http://localhost:8080/', 'max_redirects' => 9));
     $this->assertEquals($request->getConfig(), $trace->requests[0]['config']);
 }
開發者ID:dracony,項目名稱:forked-php-orm-benchmark,代碼行數:8,代碼來源:HttpRequestTaskTest.php

示例3: handleRedirect

 /**
  * Handles HTTP redirection
  *
  * This method will throw an Exception if redirect to a non-HTTP(S) location
  * is attempted, also if number of redirects performed already is equal to
  * 'max_redirects' configuration parameter.
  *
  * @param    HTTP_Request2               Original request
  * @param    HTTP_Request2_Response      Response containing redirect
  * @return   HTTP_Request2_Response      Response from a new location
  * @throws   HTTP_Request2_Exception
  */
 protected function handleRedirect(HTTP_Request2 $request, HTTP_Request2_Response $response)
 {
     if (is_null($this->redirectCountdown)) {
         $this->redirectCountdown = $request->getConfig('max_redirects');
     }
     if (0 == $this->redirectCountdown) {
         $this->redirectCountdown = null;
         // Copying cURL behaviour
         throw new HTTP_Request2_MessageException('Maximum (' . $request->getConfig('max_redirects') . ') redirects followed', HTTP_Request2_Exception::TOO_MANY_REDIRECTS);
     }
     $redirectUrl = new Net_URL2($response->getHeader('location'), array(Net_URL2::OPTION_USE_BRACKETS => $request->getConfig('use_brackets')));
     // refuse non-HTTP redirect
     if ($redirectUrl->isAbsolute() && !in_array($redirectUrl->getScheme(), array('http', 'https'))) {
         $this->redirectCountdown = null;
         throw new HTTP_Request2_MessageException('Refusing to redirect to a non-HTTP URL ' . $redirectUrl->__toString(), HTTP_Request2_Exception::NON_HTTP_REDIRECT);
     }
     // Theoretically URL should be absolute (see http://tools.ietf.org/html/rfc2616#section-14.30),
     // but in practice it is often not
     if (!$redirectUrl->isAbsolute()) {
         $redirectUrl = $request->getUrl()->resolve($redirectUrl);
     }
     $redirect = clone $request;
     $redirect->setUrl($redirectUrl);
     if (303 == $response->getStatus() || !$request->getConfig('strict_redirects') && in_array($response->getStatus(), array(301, 302))) {
         $redirect->setMethod(HTTP_Request2::METHOD_GET);
         $redirect->setBody('');
     }
     if (0 < $this->redirectCountdown) {
         $this->redirectCountdown--;
     }
     return $this->sendRequest($redirect);
 }
開發者ID:verbazend,項目名稱:AWFA,代碼行數:44,代碼來源:Socket.php

示例4: testSetAndGetConfig

 public function testSetAndGetConfig()
 {
     $req = new HTTP_Request2();
     $this->assertArrayHasKey('connect_timeout', $req->getConfig());
     $req->setConfig(array('connect_timeout' => 123));
     $this->assertEquals(123, $req->getConfig('connect_timeout'));
     try {
         $req->setConfig(array('foo' => 'unknown parameter'));
     } catch (HTTP_Request2_Exception $e) {
         try {
             $req->getConfig('bar');
         } catch (HTTP_Request2_Exception $e) {
             return;
         }
     }
     $this->fail('Expected HTTP_Request2_Exception was not thrown');
 }
開發者ID:brucewu16899,項目名稱:1.6.x,代碼行數:17,代碼來源:Request2Test.php

示例5: getConfig

 /**
  * Gets value for configuration parameter.
  * 
  * @param string $name configuration parameter name.
  * 
  * @return string
  */
 public function getConfig($name)
 {
     return $this->_request->getConfig($name);
 }
開發者ID:southworkscom,項目名稱:azure-sdk-for-php,代碼行數:11,代碼來源:HttpClient.php

示例6: testSetProxyAsUrl

 public function testSetProxyAsUrl()
 {
     $req = new HTTP_Request2();
     $req->setConfig('proxy', 'socks5://foo:bar%25baz@localhost:1080/');
     $this->assertEquals('socks5', $req->getConfig('proxy_type'));
     $this->assertEquals('localhost', $req->getConfig('proxy_host'));
     $this->assertEquals(1080, $req->getConfig('proxy_port'));
     $this->assertEquals('foo', $req->getConfig('proxy_user'));
     $this->assertEquals('bar%baz', $req->getConfig('proxy_password'));
 }
開發者ID:SuhitNarayan,項目名稱:SuhitNarayan-SEMANTICTECH,代碼行數:10,代碼來源:Request2Test.php

示例7: sendRequest

 /**
  * Sends request to the remote server and returns its response
  *
  * @param    HTTP_Request2
  * @return   HTTP_Request2_Response
  * @throws   HTTP_Request2_Exception
  */
 public function sendRequest(HTTP_Request2 $request)
 {
     $this->request = $request;
     $keepAlive = $this->connect();
     $headers = $this->prepareHeaders();
     // Use global request timeout if given, see feature requests #5735, #8964
     if ($timeout = $request->getConfig('timeout')) {
         $this->timeout = time() + $timeout;
     } else {
         $this->timeout = null;
     }
     try {
         if (false === @fwrite($this->socket, $headers, strlen($headers))) {
             throw new HTTP_Request2_Exception('Error writing request');
         }
         // provide request headers to the observer, see request #7633
         $this->request->setLastEvent('sentHeaders', $headers);
         $this->writeBody();
         if ($this->timeout && time() > $this->timeout) {
             throw new HTTP_Request2_Exception('Request timed out after ' . $request->getConfig('timeout') . ' second(s)');
         }
         $response = $this->readResponse();
         if (!$this->canKeepAlive($keepAlive, $response)) {
             $this->disconnect();
         }
         if ($this->shouldUseProxyDigestAuth($response)) {
             return $this->sendRequest($request);
         }
         if ($this->shouldUseServerDigestAuth($response)) {
             return $this->sendRequest($request);
         }
         if ($authInfo = $response->getHeader('authentication-info')) {
             $this->updateChallenge($this->serverChallenge, $authInfo);
         }
         if ($proxyInfo = $response->getHeader('proxy-authentication-info')) {
             $this->updateChallenge($this->proxyChallenge, $proxyInfo);
         }
     } catch (Exception $e) {
         $this->disconnect();
         throw $e;
     }
     return $response;
 }
開發者ID:microcosmx,項目名稱:experiments,代碼行數:50,代碼來源:Socket.php

示例8: sendRequest

 public function sendRequest(HTTP_Request2 $request)
 {
     $this->requests[] = array('config' => $request->getConfig(), 'url' => $request->getUrl(), 'method' => $request->getMethod(), 'headers' => $request->getHeaders(), 'auth' => $request->getAuth(), 'body' => (string) $request->getBody());
     return parent::sendRequest($request);
 }
開發者ID:dracony,項目名稱:forked-php-orm-benchmark,代碼行數:5,代碼來源:TraceHttpAdapter.php

示例9: testConfigurationViaProperties

 public function testConfigurationViaProperties()
 {
     $trace = new TraceHttpAdapter();
     $this->copyTasksAddingCustomRequest('config-properties', 'recipient', $this->createRequest($trace));
     try {
         $this->executeTarget('recipient');
     } catch (BuildException $e) {
         // the request returns error 400, but we don't really care
     }
     $request = new HTTP_Request2(null, 'GET', array('proxy' => 'http://localhost:8080/', 'timeout' => 20, 'max_redirects' => 9));
     $this->assertEquals($request->getConfig(), $trace->requests[0]['config']);
 }
開發者ID:dracony,項目名稱:forked-php-orm-benchmark,代碼行數:12,代碼來源:HttpGetTaskTest.php


注:本文中的HTTP_Request2::getConfig方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。