nextcloud / nextcloud/server

[Bug]: HEAD requests for DAV folder downloads with ?accept=zip trigger "headers already sent" warnings

Open
#59,321 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

0. Needs triage 32-feedback bug
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

⚠️ This issue respects the following points: ⚠️
Bug description

HEAD requests for DAV folder downloads with ?accept=zip trigger PHP warnings about headers already being sent.

Observed warning:

Cannot modify header information - headers already sent by (output started at /.../3rdparty/deepdiver/zipstreamer/src/ZipStreamer.php:325) at /.../3rdparty/sabre/http/lib/Sapi.php#64

Also seen with #68 and #70.

This seems specific to HEAD requests for folder archive downloads over DAV.

Steps to reproduce
  1. Request a folder over DAV as archive with ?accept=zip
  2. Use HEAD instead of GET
  3. Check nextcloud.log

Example shape:

HEAD /remote.php/dav/files/<user>/<folder>/?accept=zip

Expected behavior

HEAD should not stream archive body data and should not produce PHP warnings.

Nextcloud Server version

32

Operating system

RHEL/CentOS

PHP engine version

PHP 8.2

Web server

Nginx

Database engine version

PostgreSQL

Is this bug present after an update or on a fresh install?

Upgraded to a MAJOR version (ex. 31 to 32)

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?
  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other
Configuration report
{
    "version": "32.0.6.2",
    "log_type": "file",
    "loglevel": 2,
    "overwriteprotocol": "https"
  }
List of activated Apps

Nextcloud Signing status

Nextcloud Logs
{
    "level": 2,
    "app": "PHP",
    "method": "HEAD",
    "url": "/remote.php/dav/files/<user>/<folder>/?accept=zip",
    "message": "Cannot modify header information - headers already sent by (output started at /mnt/ncdata/nextcloud/3rdparty/deepdiver/zipstreamer/src/ZipStreamer.php:325) at /mnt/ncdata/nextcloud/3rdparty/sabre/http/lib/Sapi.php#64",
    "version": "32.0.6.2"
  }
Additional info

Relevant code path on the affected instance:

  • apps/dav/lib/Connector/Sabre/ZipFolderPlugin.php:172-173
    • creates new Streamer(...)
    • calls $streamer->sendHeaders(...)
  • lib/private/Streamer.php
    • delegates to ZipStreamer
  • 3rdparty/deepdiver/zipstreamer/src/ZipStreamer.php
    • writes directly to output stream
  • 3rdparty/sabre/http/lib/Sapi.php
    • later calls header(...)

This suggests HEAD handling for DAV zip downloads is incomplete or inconsistent with the streaming response path.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in apps/dav/lib/Connector/Sabre/ZipFolderPlugin.php around lines 172-173, then trace the response through lib/private/Streamer.php and 3rdparty/deepdiver/zipstreamer/src/ZipStreamer.php to 3rdparty/sabre/http/lib/Sapi.php. Reproduce the HEAD DAV request with ?accept=zip and inspect the GET and HEAD paths. Done means HEAD produces no archive body and no headers-already-sent warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.