MCPcopy Create free account
hub / github.com/error311/FileRise / request

Method request

src/FileRise/Storage/WebDavAdapter.php:478–506  ·  view source on GitHub ↗
(string $method, string $url, $body = null, array $headers = [])

Source from the content-addressed store, hash-verified

476 }
477
478 private function request(string $method, string $url, $body = null, array $headers = []): int
479 {
480 try {
481 $resp = $this->client->request($method, $url, $body, $headers);
482 $status = (int)($resp['statusCode'] ?? 0);
483 if ($status < 200 || $status >= 300) {
484 $msg = trim((string)($resp['body'] ?? ''));
485 if ($msg !== '') {
486 $msg = preg_replace('/\\s+/', ' ', $msg);
487 if (strlen($msg) > 240) {
488 $msg = substr($msg, 0, 240) . '...';
489 }
490 }
491 $this->lastError = $msg !== '' ? ('HTTP ' . $status . ': ' . $msg) : ('HTTP ' . $status);
492 } else {
493 $this->lastError = '';
494 }
495 return $status;
496 } catch (Throwable $e) {
497 $msg = trim($e->getMessage());
498 if ($msg !== '') {
499 $msg = preg_replace('/(https?:\\/\\/)([^\\s@]+@)/i', '$1', $msg);
500 $this->lastError = $msg;
501 } else {
502 $this->lastError = 'WebDAV request failed';
503 }
504 return 0;
505 }
506 }
507
508 private function isCollection($value): bool
509 {

Callers 7

testConnectionMethod · 0.95
writeMethod · 0.95
writeStreamMethod · 0.95
moveMethod · 0.95
copyMethod · 0.95
deleteMethod · 0.95
mkdirMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected