Symfony\Component\BrowserKit\Client::setServerParameter PHP Method

setServerParameter() public method

Sets single server parameter.
public setServerParameter ( string $key, string $value )
$key string A key of the parameter
$value string A value of the parameter
    public function setServerParameter($key, $value)
    {
        $this->server[$key] = $value;
    }

Usage Example

Ejemplo n.º 1
0
 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());
 }
All Usage Examples Of Symfony\Component\BrowserKit\Client::setServerParameter