[PHP] Error: Error: Cannot modify header information

Hallo,
sorry for my bad english.

System:
-Raspberry Pi 4 Model B
-Raspbian Linux 10
-Linux 5.4.51-v7l+ auf armv7l
-Nextcloud 19.0.4
-php 7.3+69
-apache2 2.4.38-3+deb10u4
-libmariadb3 10.3.23-0+deb10u1
-UFW and Fail2Ban
-Webmin 1.955
-SSL with CertBot
-extern Storages with Nextcloud App
-At the SD Card is the Nextcloud installation with Database and a little Storage
-At the extern HDD (in ext format) is the big Storage
-the swap cache is at a 16GB usb stick

Steps to replicate it:

  1. Upload or Download a big file in external or internal storage (in my case 15GB)

The output of your Nextcloud log in Admin > Logging:

[PHP] Error: Error: Cannot modify header information - headers already sent by (output started at /var/www/html/3rdparty/sabre/http/lib/Sapi.php:132) at /var/www/html/apps/dav/lib/Connector/Sabre/File.php#690 at <>

    <>
    OC\Log\ErrorHandler::onError(2, “Cannot modify h … )”, “/var/www/html/a … p”, 690, {string: "X-Hash … "})
    /var/www/html/apps/dav/lib/Connector/Sabre/File.php line 690
    header(“X-Hash-MD5: d41 … e”)
    /var/www/html/apps/dav/lib/Connector/Sabre/File.php line 188
    OCA\DAV\Connector\Sabre\File->header(“X-Hash-MD5: d41 … e”)
    <>
    OCA\DAV\Connector\Sabre\File->OCA\DAV\Connector\Sabre{closure}("*** sensitive parameters replaced ***")
    /var/www/html/lib/private/Files/Stream/HashWrapper.php line 71
    call_user_func(Closure {}, “*** sensitive parameter replaced ***”)
    <>
    OC\Files\Stream\HashWrapper->stream_close()
    /var/www/html/apps/files_external/3rdparty/icewind/streams/src/Wrapper.php line 132
    fclose(null)
    /var/www/html/lib/private/Files/Stream/HashWrapper.php line 75
    Icewind\Streams\Wrapper->stream_close()
    <>
    OC\Files\Stream\HashWrapper->stream_close()
    /var/www/html/apps/files_external/3rdparty/icewind/streams/src/Wrapper.php line 132
    fclose(null)
    /var/www/html/lib/private/Files/Stream/HashWrapper.php line 75
    Icewind\Streams\Wrapper->stream_close()
    /var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php line 319
    OC\Files\Stream\HashWrapper->stream_close()
    /var/www/html/apps/dav/lib/Server.php line 320
    Sabre\DAV\Server->exec()
    /var/www/html/apps/dav/appinfo/v2/remote.php line 35
    OCA\DAV\Server->exec()
    /var/www/html/remote.php line 167
    require_once("/var/www/html/a … p")

PUT /remote.php/dav/uploads/xxx/web-file-upload-9f7578e01f46e94cd73771ce02a3a3eb-1602666872448/15372124160
from 192.xxx.xxx.xx by xxx at 2020-10-14T14:12:47+02:00
[details="Support intro"]
[index] Error: TypeError: Argument 2 passed to OC\Streamer::__construct() must be of the type int, float given, called in /var/www/html/lib/private/legacy/OC_Files.php on line 163 at <>

    /var/www/html/lib/private/legacy/OC_Files.php line 163
    OC\Streamer->__construct(OC\AppFramework\Http\Request {}, 8233944213, 32)
    /var/www/html/apps/files/ajax/download.php line 64
    OC_Files::get("/HDD/xxxxxxx", “xxxxxx”, {head: false})
    /var/www/html/lib/private/Route/Route.php line 156
    require_once("/var/www/html/a … p")
    <>
    OC\Route\Route->OC\Route{closure}("*** sensitive parameters replaced ***")
    /var/www/html/lib/private/Route/Router.php line 297
    call_user_func(Closure {}, {_route: “files_ajax_download”})
    /var/www/html/lib/base.php line 1011
    OC\Route\Router->match("/apps/files/ajax/download.php")
    /var/www/html/index.php line 37
    OC::handleRequest()

GET /index.php/apps/files/ajax/download.php?dir=%2xxxxxx&files=xxxxxx&downloadStartSecret=nu6cllupngg
from 192.xxx.xxx.xx by User at 2020-10-13T20:16:54+02:00

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'xxx',
  'passwordsalt' => 'xxx',
  'secret' => 'xxx',
  'trusted_domains' => 
  array (
    0 => 'xxx',
    1 => 'xxx',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '19.0.4.2',
  'overwrite.cli.url' => 'xxx',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'oc_xxx',
  'dbpassword' => 'xxx',
  'installed' => true,
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'tls',
  'mail_sendmailmode' => 'smtp',
  'mail_smtpauth' => 1,
  'mail_from_address' => 'xxx',
  'mail_domain' => 'xxx',
  'mail_smtphost' => 'xxx',
  'mail_smtpport' => 'xxx',
  'mail_smtpname' => 'xxx',
  'mail_smtppassword' => 'xxx',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'mail_smtpauthtype' => 'LOGIN',
  'auth.bruteforce.protection.enabled' => false,
  'logtimezone' => 'Europe/Berlin',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
);

The output of your Apache/nginx/system log in /var/log/____:

[Wed Oct 14 00:00:18.267851 2020] [mpm_prefork:notice] [pid 718] AH00163: Apache/2.4.38 (Raspbian) OpenSSL/1.1.1d configured -- resuming normal operations
[Wed Oct 14 00:00:18.267927 2020] [core:notice] [pid 718] AH00094: Command line: '/usr/sbin/apache2'
[Wed Oct 14 09:11:30.371499 2020] [access_compat:error] [pid 2417] [client 192.xxx.xxx.xx:49718] AH01797: client denied by server configuration: /var/www/html/config
[Wed Oct 14 11:32:29.178958 2020] [access_compat:error] [pid 4955] [client 192.xxx.xxx.xx:51776] AH01797: client denied by server configuration: /var/www/html/config
[Wed Oct 14 14:53:46.067003 2020] [access_compat:error] [pid 19163] [client 192.xxx.xxx.xx:54136] AH01797: client denied by server configuration: /var/www/html/config
[Wed Oct 14 15:08:26.330605 2020] [access_compat:error] [pid 31225] [client 192.xxx.xxx.xx:54416] AH01797: client denied by server configuration: /var/www/html/config
[Wed Oct 14 15:16:11.985700 2020] [access_compat:error] [pid 31329] [client 192.xxx.xxx.xx:54534] AH01797: client denied by server configuration: /var/www/html/config
[Thu Oct 15 00:00:02.704890 2020] [mpm_prefork:notice] [pid 718] AH00171: Graceful restart requested, doing restart
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message

i tried this fix first because i first noticed the error only in the browser download : Remove type for size on Streamer constructor

Then i got this error:

[no app in context] Error: OverflowException: Count64 object limited to 32 bit (overflow) at <>

    /var/www/html/3rdparty/deepdiver/zipstreamer/src/ZipStreamer.php line 236
    ZipStreamer\Count64_32->add([0,573257433])
    /var/www/html/lib/private/Streamer.php line 165
    ZipStreamer\ZipStreamer->addFileFromStream(null, “datei.m4v”, {timestamp: 1600 … 1})
    /var/www/html/lib/private/Streamer.php line 136
    OC\Streamer->addFileFromStream(null, “datei”, 573257433, 1600513560)
    /var/www/html/lib/private/legacy/OC_Files.php line 203
    OC\Streamer->addDirRecursive("/HDD/ordner")
    /var/www/html/apps/files/ajax/download.php line 64
    OC_Files::get("/HDD/ordner", “ordner”, {head: false})
    /var/www/html/lib/private/Route/Route.php line 156
    require_once("/var/www/html/a … p")
    <>
    OC\Route\Route->OC\Route{closure}("*** sensitive parameters replaced ***")
    /var/www/html/lib/private/Route/Router.php line 297
    call_user_func(Closure {}, {_route: “files_ajax_download”})
    /var/www/html/lib/base.php line 1011
    OC\Route\Router->match("/apps/files/ajax/download.php")
    /var/www/html/index.php line 37
    OC::handleRequest()

GET /index.php/apps/files/ajax/download.php?dir=%2FHDD%2Fordner&files=ordner&downloadStartSecret=mv54ymva9j
from 192.xxx.xxx.xx by User at 2020-10-12T09:26:42+02:00

Thank you very much

I had the same issue (NC 19.0.4)
I had configure an external storage to a SMB share that was off-line.
I remove the configuration and all works well

I try this but i still got this Error:

[no app in context] Error: OverflowException: Count64 object limited to 32 bit (overflow) at <<closure>>

0. /var/www/html/3rdparty/deepdiver/zipstreamer/src/ZipStreamer.php line 236
   ZipStreamer\Count64_32->add([0,21682509])
1. /var/www/html/lib/private/Streamer.php line 165
   ZipStreamer\ZipStreamer->addFileFromStream(null, "xxxxi ... f", {timestamp: 1588 ... 1})
2. /var/www/html/lib/private/Streamer.php line 136
   OC\Streamer->addFileFromStream(null, "xxxxx ... f", 21682509, 1588260780)
3. /var/www/html/lib/private/legacy/OC_Files.php line 203
   OC\Streamer->addDirRecursive("xxxx")
4. /var/www/html/apps/files/ajax/download.php line 64
   OC_Files::get("/xxxx", "xxxx", {head: false})
5. /var/www/html/lib/private/Route/Route.php line 156
   require_once("/var/www/html/a ... p")
6. <<closure>>
   OC\Route\Route->OC\Route\{closure}("*** sensitive parameters replaced ***")
7. /var/www/html/lib/private/Route/Router.php line 297
   call_user_func(Closure {}, {_route: "files_ajax_download"})
8. /var/www/html/lib/base.php line 1011
   OC\Route\Router->match("/apps/files/ajax/download.php")
9. /var/www/html/index.php line 37
   OC::handleRequest()

GET /index.php/apps/files/ajax/download.php?dir=%2Fxxx%2Fxxx&files=B%C3%BCcher&downloadStartSecret=4430m3nujbf
from 192.168.178.32 by xxx at 2020-10-17T21:35:48+02:00