(string $path, ?int $length = null, int $offset = 0)
| 184 | } |
| 185 | |
| 186 | public function openReadStream(string $path, ?int $length = null, int $offset = 0) |
| 187 | { |
| 188 | $url = $this->buildUrlForPath($path); |
| 189 | if ($url === '') { |
| 190 | return false; |
| 191 | } |
| 192 | |
| 193 | $headers = []; |
| 194 | if ($this->username !== '') { |
| 195 | $headers[] = 'Authorization: Basic ' . base64_encode($this->username . ':' . $this->password); |
| 196 | } |
| 197 | if ($offset > 0 || $length !== null) { |
| 198 | $end = ($length !== null && $length > 0) ? ($offset + $length - 1) : ''; |
| 199 | $headers[] = 'Range: bytes=' . $offset . '-' . $end; |
| 200 | } |
| 201 | $connectTimeout = $this->timeout > 0 ? min(10, $this->timeout) : 10; |
| 202 | $stream = CurlReadStream::open( |
| 203 | $url, |
| 204 | $headers, |
| 205 | $this->verifyTls, |
| 206 | $connectTimeout, |
| 207 | $this->timeout, |
| 208 | function (string $message): void { |
| 209 | $this->lastError = $message; |
| 210 | } |
| 211 | ); |
| 212 | if ($stream === false) { |
| 213 | if ($this->lastError === '') { |
| 214 | $this->lastError = 'Unable to open WebDAV read stream.'; |
| 215 | } |
| 216 | return false; |
| 217 | } |
| 218 | |
| 219 | return $stream; |
| 220 | } |
| 221 | |
| 222 | public function write(string $path, string $data, int $flags = 0): bool |
| 223 | { |
no test coverage detected