当前位置: 首页>>代码示例>>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;未经允许,请勿转载。