Page MenuHomePhorge

D5736.1775269357.diff
No OneTemporary

Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None

D5736.1775269357.diff

diff --git a/src/app/Http/DAV/Sapi.php b/src/app/Http/DAV/Sapi.php
--- a/src/app/Http/DAV/Sapi.php
+++ b/src/app/Http/DAV/Sapi.php
@@ -22,11 +22,10 @@
$headers = [];
foreach ($request->headers as $key => $val) {
- if (is_array($val)) {
+ if (is_array($val) && !in_array($key, ['php-auth-user', 'php-auth-pw'])) {
$headers[$key] = implode("\n", $val);
}
}
-
// TODO: For now we create the Sabre's Request object. For better performance
// and memory usage we should replece it completely with a "direct" access to Laravel's Request.
@@ -34,9 +33,30 @@
$r->setHttpVersion('1.1');
// $r->setRawServerData($_SERVER);
$r->setAbsoluteUrl($request->url());
- $r->setBody($request->getContent(true));
+ $r->setBody($body = $request->getContent(true));
$r->setPostData($request->all());
+ // Input debug logging
+ if (\config('app.debug')) {
+ $msg = sprintf("[DAV] %s %s\n", $request->method(), $request->path());
+
+ foreach ($headers as $key => $val) {
+ if ($key == 'authorization') {
+ $msg .= 'Authorization: ' . explode(' ', $val, 2)[0] . " ***\n";
+ } else {
+ $msg .= preg_replace_callback('/(^|-)[a-z]/', fn ($m) => strtoupper($m[0]), $key) . ": {$val}\n";
+ }
+ }
+
+ if (!\request()->isMethod('put')) {
+ $msg .= "\n" . stream_get_contents($body);
+ rewind($body);
+ // TODO: Format XML
+ }
+
+ \Log::debug($msg);
+ }
+
return $r;
}
@@ -83,6 +103,29 @@
}
};
+ // Output debug logging
+ if (\config('app.debug')) {
+ $msg = sprintf("[DAV] HTTP/%s %s %s\n", $response->getHttpVersion(), $response->getStatus(), $response->getSTatusText());
+
+ foreach ($response->getHeaders() as $key => $val) {
+ $msg .= $key . ": " . implode("\n", $val) . "\n";
+ }
+
+ if (!\request()->isMethod('get')) {
+ $body = $response->getBody();
+ $msg .= "\n";
+ if (is_resource($body)) {
+ $msg .= stream_get_contents($body);
+ rewind($body);
+ } else {
+ $msg .= $body;
+ }
+ // TODO: Format XML
+ }
+
+ \Log::debug($msg);
+ }
+
// FIXME: Should we use non-streamed responses for small bodies?
self::$response = new StreamedResponse($callback, $response->getStatus(), $response->getHeaders());

File Metadata

Mime Type
text/plain
Expires
Sat, Apr 4, 2:22 AM (19 m, 29 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18827766
Default Alt Text
D5736.1775269357.diff (2 KB)

Event Timeline