Passed
Push — master ( 63eb61...20c591 )
by San
04:59
created

Goutte::getServer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Behatch\HttpCall\Request;
4
5
class Goutte extends BrowserKit
6
{
7
    /**
8
     * headers are no more stored on client, because client does not flush them when reset/restart session.
9
     * They are on Behat\Mink\Driver\BrowserKitDriver and there is no way to get them.
10
     *
11
     * @var array
12
     */
13
    private $requestHeaders = [];
14
15
    public function send($method, $url, $parameters = [], $files = [], $content = null, $headers = [])
16
    {
17
        $page = parent::send($method, $url, $parameters, $files, $content, array_merge($headers, $this->requestHeaders));
18
        $this->resetHttpHeaders();
19
20
        return $page;
21
    }
22
23
    public function setHttpHeader($name, $value)
24
    {
25
        $name = strtoupper("http_$name");
26
        $this->requestHeaders[$name] = $value;
27
    }
28
29
    protected function resetHttpHeaders()
30
    {
31
        $this->requestHeaders = [];
32
    }
33
}
34