当前位置: 首页>>代码示例>>PHP>>正文


PHP Client::setServerParameter方法代码示例

本文整理汇总了PHP中Symfony\Component\BrowserKit\Client::setServerParameter方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::setServerParameter方法的具体用法?PHP Client::setServerParameter怎么用?PHP Client::setServerParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\BrowserKit\Client的用法示例。


在下文中一共展示了Client::setServerParameter方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 protected function execute($method = 'GET', $url, $parameters = array(), $files = array())
 {
     foreach ($this->headers as $header => $val) {
         $header = str_replace('-', '_', strtoupper($header));
         $this->client->setServerParameter("HTTP_{$header}", $val);
         # Issue #827 - symfony foundation requires 'CONTENT_TYPE' without HTTP_
         if ($this->isFunctional and $header == 'CONTENT_TYPE') {
             $this->client->setServerParameter($header, $val);
         }
     }
     // allow full url to be requested
     $url = (strpos($url, '://') === false ? $this->config['url'] : '') . $url;
     $parameters = $this->encodeApplicationJson($method, $parameters);
     if (is_array($parameters) || $method == 'GET') {
         if (!empty($parameters) && $method == 'GET') {
             $url .= '?' . http_build_query($parameters);
         }
         if ($method == 'GET') {
             $this->debugSection("Request", "{$method} {$url}");
         } else {
             $this->debugSection("Request", "{$method} {$url} " . json_encode($parameters));
         }
         $this->client->request($method, $url, $parameters, $files);
     } else {
         $this->debugSection("Request", "{$method} {$url} " . $parameters);
         $this->client->request($method, $url, array(), $files, array(), $parameters);
     }
     $this->response = $this->client->getInternalResponse()->getContent();
     $this->debugSection("Response", $this->response);
     if (count($this->client->getInternalRequest()->getCookies())) {
         $this->debugSection('Cookies', $this->client->getInternalRequest()->getCookies());
     }
     $this->debugSection("Headers", $this->client->getInternalResponse()->getHeaders());
     $this->debugSection("Status", $this->client->getInternalResponse()->getStatus());
 }
开发者ID:huynt57,项目名称:bluebee-uet.com,代码行数:35,代码来源:REST.php

示例2: execute

 protected function execute($method = 'GET', $url, $parameters = array(), $files = array())
 {
     foreach ($this->headers as $header => $val) {
         $this->client->setServerParameter("HTTP_{$header}", $val);
     }
     // allow full url to be requested
     $url = (strpos($url, '://') === false ? $this->config['url'] : '') . $url;
     if (is_array($parameters) || $parameters instanceof \ArrayAccess) {
         $parameters = $this->scalarizeArray($parameters);
         if (array_key_exists('Content-Type', $this->headers) && $this->headers['Content-Type'] === 'application/json' && $method != 'GET') {
             $parameters = json_encode($parameters);
         }
     }
     if (is_array($parameters) || $method == 'GET') {
         if ($method == 'GET' && !empty($parameters)) {
             $url .= '?' . http_build_query($parameters);
             $this->debugSection("Request", "{$method} {$url}");
         } else {
             $this->debugSection("Request", "{$method} {$url}?" . http_build_query($parameters));
         }
         $this->client->request($method, $url, $parameters, $files);
     } else {
         $this->debugSection("Request", "{$method} {$url} " . $parameters);
         $this->client->request($method, $url, array(), $files, array(), $parameters);
     }
     $this->response = $this->client->getResponse()->getContent();
     $this->debugSection("Response", $this->response);
 }
开发者ID:pfz,项目名称:codeception,代码行数:28,代码来源:REST.php

示例3: __construct

 /**
  * Initializes BrowserKit driver.
  *
  * @param Client      $client  BrowserKit client instance
  * @param string|null $baseUrl Base URL for HttpKernel clients
  */
 public function __construct(Client $client, $baseUrl = null)
 {
     $this->client = $client;
     $this->client->followRedirects(true);
     if ($baseUrl !== null && $client instanceof HttpKernelClient) {
         $client->setServerParameter('SCRIPT_FILENAME', parse_url($baseUrl, PHP_URL_PATH));
     }
 }
开发者ID:penguinclub,项目名称:penguinweb_drupal8,代码行数:14,代码来源:BrowserKitDriver.php

示例4: amHttpAuthenticated

 /**
  * Adds HTTP authentication via username/password.
  *
  * @param $username
  * @param $password
  * @part json
  * @part xml
  */
 public function amHttpAuthenticated($username, $password)
 {
     if ($this->isFunctional) {
         $this->client->setServerParameter('PHP_AUTH_USER', $username);
         $this->client->setServerParameter('PHP_AUTH_PW', $password);
     } else {
         $this->client->setAuth($username, $password);
     }
 }
开发者ID:janhenkgerritsen,项目名称:Codeception,代码行数:17,代码来源:REST.php

示例5: execute

 protected function execute($method = 'GET', $url, $parameters = [], $files = [])
 {
     $this->debugSection("Request headers", $this->headers);
     foreach ($this->headers as $header => $val) {
         $header = str_replace('-', '_', strtoupper($header));
         $this->client->setServerParameter("HTTP_{$header}", $val);
         // Issue #1650 - Symfony BrowserKit changes HOST header to request URL
         if ($header === 'HOST') {
             $this->client->setServerParameter("HTTP_ HOST", $val);
         }
         // Issue #827 - symfony foundation requires 'CONTENT_TYPE' without HTTP_
         if ($this->isFunctional && $header === 'CONTENT_TYPE') {
             $this->client->setServerParameter($header, $val);
         }
     }
     // allow full url to be requested
     if (strpos($url, '://') === false) {
         $url = $this->config['url'] . $url;
     }
     $this->params = $parameters;
     $parameters = $this->encodeApplicationJson($method, $parameters);
     if (is_array($parameters) || $method === 'GET') {
         if (!empty($parameters) && $method === 'GET') {
             $url .= '?' . http_build_query($parameters);
         }
         if ($method == 'GET') {
             $this->debugSection("Request", "{$method} {$url}");
         } else {
             $this->debugSection("Request", "{$method} {$url} " . json_encode($parameters));
         }
         $this->client->request($method, $url, $parameters, $files);
     } else {
         $requestData = $parameters;
         if (!ctype_print($requestData) && false === mb_detect_encoding($requestData, mb_detect_order(), true)) {
             // if the request data has non-printable bytes and it is not a valid unicode string, reformat the
             // display string to signify the presence of request data
             $requestData = '[binary-data length:' . strlen($requestData) . ' md5:' . md5($requestData) . ']';
         }
         $this->debugSection("Request", "{$method} {$url} " . $requestData);
         $this->client->request($method, $url, [], $files, [], $parameters);
     }
     $this->response = (string) $this->connectionModule->_getResponseContent();
     $this->debugSection("Response", $this->response);
     if (count($this->client->getInternalRequest()->getCookies())) {
         $this->debugSection('Cookies', $this->client->getInternalRequest()->getCookies());
     }
     $this->debugSection("Headers", $this->client->getInternalResponse()->getHeaders());
     $this->debugSection("Status", $this->client->getInternalResponse()->getStatus());
 }
开发者ID:Marfuz,项目名称:c4t_test,代码行数:49,代码来源:REST.php

示例6: processInternalRequest

 protected function processInternalRequest($action, $body)
 {
     ob_start();
     try {
         $this->client->setServerParameter('HTTP_HOST', 'localhost');
         $this->processRequest($action, $body);
     } catch (\ErrorException $e) {
         // Zend_Soap outputs warning as an exception
         if (strpos($e->getMessage(), 'Warning: Cannot modify header information') === false) {
             ob_end_clean();
             throw $e;
         }
     }
     $response = ob_get_contents();
     ob_end_clean();
     return $response;
 }
开发者ID:NaszvadiG,项目名称:ImageCMS,代码行数:17,代码来源:SOAP.php

示例7: sendXMLRPCMethodCall

 /**
  * Sends a XMLRPC method call to remote XMLRPC-server.
  *
  * @param string $methodName
  * @param array $parameters
  */
 public function sendXMLRPCMethodCall($methodName, $parameters = array())
 {
     if (!array_key_exists('Content-Type', $this->headers)) {
         $this->headers['Content-Type'] = 'text/xml';
     }
     foreach ($this->headers as $header => $val) {
         $this->client->setServerParameter("HTTP_{$header}", $val);
     }
     $url = $this->config['url'];
     if (is_array($parameters)) {
         $parameters = $this->scalarizeArray($parameters);
     }
     $requestBody = xmlrpc_encode_request($methodName, array_values($parameters));
     $this->debugSection('Request', $url . PHP_EOL . $requestBody);
     $this->client->request('POST', $url, array(), array(), array(), $requestBody);
     $this->response = $this->client->getInternalResponse()->getContent();
     $this->debugSection('Response', $this->response);
 }
开发者ID:lenninsanchez,项目名称:donadores,代码行数:24,代码来源:XMLRPC.php

示例8: execute

 protected function execute($method = 'GET', $url, $parameters = [], $files = [])
 {
     $this->debugSection("Request headers", $this->headers);
     if ($parameters instanceof \JsonSerializable) {
         $parameters = $parameters->jsonSerialize();
     }
     foreach ($this->headers as $header => $val) {
         $header = str_replace('-', '_', strtoupper($header));
         $this->client->setServerParameter("HTTP_{$header}", $val);
         // Issue #1650 - Symfony BrowserKit changes HOST header to request URL
         if (strtolower($header) == 'host') {
             $this->client->setServerParameter("HTTP_ HOST", $val);
         }
         // Issue #827 - symfony foundation requires 'CONTENT_TYPE' without HTTP_
         if ($this->isFunctional and $header == 'CONTENT_TYPE') {
             $this->client->setServerParameter($header, $val);
         }
     }
     // allow full url to be requested
     $url = (strpos($url, '://') === false ? $this->config['url'] : '') . $url;
     $this->params = $parameters;
     $parameters = $this->encodeApplicationJson($method, $parameters);
     if (is_array($parameters) || $method == 'GET') {
         if (!empty($parameters) && $method == 'GET') {
             $url .= '?' . http_build_query($parameters);
         }
         if ($method == 'GET') {
             $this->debugSection("Request", "{$method} {$url}");
         } else {
             $this->debugSection("Request", "{$method} {$url} " . json_encode($parameters));
         }
         $this->client->request($method, $url, $parameters, $files);
     } else {
         $this->debugSection("Request", "{$method} {$url} " . $parameters);
         $this->client->request($method, $url, [], $files, [], $parameters);
     }
     $this->response = (string) $this->client->getInternalResponse()->getContent();
     $this->debugSection("Response", $this->response);
     if (count($this->client->getInternalRequest()->getCookies())) {
         $this->debugSection('Cookies', $this->client->getInternalRequest()->getCookies());
     }
     $this->debugSection("Headers", $this->client->getInternalResponse()->getHeaders());
     $this->debugSection("Status", $this->client->getInternalResponse()->getStatus());
 }
开发者ID:junichi11,项目名称:Codeception,代码行数:44,代码来源:REST.php


注:本文中的Symfony\Component\BrowserKit\Client::setServerParameter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。