Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 26... Línea 26...
26
    private $uri;
26
    private $uri;
Línea 27... Línea 27...
27
 
27
 
28
    /**
28
    /**
29
     * @param string                               $method  HTTP method
29
     * @param string                               $method  HTTP method
30
     * @param string|UriInterface                  $uri     URI
30
     * @param string|UriInterface                  $uri     URI
31
     * @param array<string, string|string[]>       $headers Request headers
31
     * @param (string|string[])[]                  $headers Request headers
32
     * @param string|resource|StreamInterface|null $body    Request body
32
     * @param string|resource|StreamInterface|null $body    Request body
33
     * @param string                               $version Protocol version
33
     * @param string                               $version Protocol version
34
     */
34
     */
35
    public function __construct(
35
    public function __construct(
Línea 67... Línea 67...
67
        $target = $this->uri->getPath();
67
        $target = $this->uri->getPath();
68
        if ($target === '') {
68
        if ($target === '') {
69
            $target = '/';
69
            $target = '/';
70
        }
70
        }
71
        if ($this->uri->getQuery() != '') {
71
        if ($this->uri->getQuery() != '') {
72
            $target .= '?' . $this->uri->getQuery();
72
            $target .= '?'.$this->uri->getQuery();
73
        }
73
        }
Línea 74... Línea 74...
74
 
74
 
75
        return $target;
75
        return $target;
Línea 83... Línea 83...
83
            );
83
            );
84
        }
84
        }
Línea 85... Línea 85...
85
 
85
 
86
        $new = clone $this;
86
        $new = clone $this;
-
 
87
        $new->requestTarget = $requestTarget;
87
        $new->requestTarget = $requestTarget;
88
 
88
        return $new;
89
        return $new;
Línea 89... Línea 90...
89
    }
90
    }
90
 
91
 
Línea 96... Línea 97...
96
    public function withMethod($method): RequestInterface
97
    public function withMethod($method): RequestInterface
97
    {
98
    {
98
        $this->assertMethod($method);
99
        $this->assertMethod($method);
99
        $new = clone $this;
100
        $new = clone $this;
100
        $new->method = strtoupper($method);
101
        $new->method = strtoupper($method);
-
 
102
 
101
        return $new;
103
        return $new;
102
    }
104
    }
Línea 103... Línea 105...
103
 
105
 
104
    public function getUri(): UriInterface
106
    public function getUri(): UriInterface
Línea 129... Línea 131...
129
        if ($host == '') {
131
        if ($host == '') {
130
            return;
132
            return;
131
        }
133
        }
Línea 132... Línea 134...
132
 
134
 
133
        if (($port = $this->uri->getPort()) !== null) {
135
        if (($port = $this->uri->getPort()) !== null) {
134
            $host .= ':' . $port;
136
            $host .= ':'.$port;
Línea 135... Línea 137...
135
        }
137
        }
136
 
138
 
137
        if (isset($this->headerNames['host'])) {
139
        if (isset($this->headerNames['host'])) {
138
            $header = $this->headerNames['host'];
140
            $header = $this->headerNames['host'];
139
        } else {
141
        } else {
140
            $header = 'Host';
142
            $header = 'Host';
141
            $this->headerNames['host'] = 'Host';
143
            $this->headerNames['host'] = 'Host';
142
        }
144
        }
143
        // Ensure Host is the first header.
145
        // Ensure Host is the first header.
144
        // See: http://tools.ietf.org/html/rfc7230#section-5.4
146
        // See: https://datatracker.ietf.org/doc/html/rfc7230#section-5.4
Línea 145... Línea 147...
145
        $this->headers = [$header => [$host]] + $this->headers;
147
        $this->headers = [$header => [$host]] + $this->headers;
146
    }
148
    }