Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Patches:
- patchwork/utf8: Remove trigger_error() that spammed the error log
- Doctrine: fix error handling for not null columns on some mysql servers https://github.com/doctrine/dbal/pull/2422
- SabreDAV: Make sure that files that are children of directories, are reported as files https://github.com/fruux/sabre-dav/issues/982
- SabreDAV: Don't open the file on HEAD requests https://github.com/sabre-io/dav/pull/1058
- SabreXML: Fix invalid PHP docs https://github.com/fruux/sabre-xml/pull/128
- SabreXML: Prevent infinite loops for empty props element https://github.com/fruux/sabre-xml/pull/132
- ZipStreamer: Fix zip generation for 7zip https://github.com/McNetic/PHPZipStreamer/pull/39
24 changes: 14 additions & 10 deletions sabre/dav/lib/DAV/CorePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,18 @@ function httpGet(RequestInterface $request, ResponseInterface $response) {

if (!$node instanceof IFile) return;

$body = $node->get();

// Converting string into stream, if needed.
if (is_string($body)) {
$stream = fopen('php://temp', 'r+');
fwrite($stream, $body);
rewind($stream);
$body = $stream;
if ($request->getHeader('X-Sabre-Original-Method') === 'HEAD') {
$body = '';
} else {
$body = $node->get();

// Converting string into stream, if needed.
if (is_string($body)) {
$stream = fopen('php://temp', 'r+');
fwrite($stream, $body);
rewind($stream);
$body = $stream;
}
}

/*
Expand Down Expand Up @@ -245,13 +249,13 @@ function httpOptions(RequestInterface $request, ResponseInterface $response) {
function httpHead(RequestInterface $request, ResponseInterface $response) {

// This is implemented by changing the HEAD request to a GET request,
// and dropping the response body.
// and telling the request handler that is doesn't need to create the body.
$subRequest = clone $request;
$subRequest->setMethod('GET');
$subRequest->setHeader('X-Sabre-Original-Method', 'HEAD');

try {
$this->server->invokeMethod($subRequest, $response, false);
$response->setBody('');
} catch (Exception\NotImplemented $e) {
// Some clients may do HEAD requests on collections, however, GET
// requests and HEAD requests _may_ not be defined on a collection,
Expand Down