Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

alexh's avatar
Level 5

Safari SSL / HTTP2 - file download not working

A colleague has developed a laravel application which generates a pdf with data from the database.

Local machine: working fine! Server configured with forge (HTTPS) - using Google Chrome: working fine! Server configured with forge (HTTP) - using Google Chrome: working fine!

Here is the weird part: Server configured with forge (HTTP) - using Safari: working fine! Server configured with forge (HTTPS) - using Safari: it is not working! :( The download just stops and does not continue.

We already checked the HTTP Header with Postman and everything seems to be in order. Any pointers on how to handle the https connection using Safari? In some other stackoverflow threads I have read something about that there may be issues regarding the http2 version of the SSL encryption if being used by safari?

The server has been set up by forge and is using the lets encrypt certificate with a test. subdomain.

0 likes
6 replies
laracoft's avatar

@alexh

  1. I don't think it is a HTTPS issue, HTTPS issues will be quite prominent in today's browsers.
  2. What do you mean by just stops and does not continue?
  3. You seem to be saying the download started but does not complete.
  4. How do you tell that it started?
alexh's avatar
Level 5

Hi @laracoft thanks for your quick reply!

By stops and does not continue I mean that the safari browser is showing a progress bar which just stops by around a third of the whole progress bar. Does that also answer question 3 and 4?

We tried returning the file from a controller in the following ways:

return response()->download(storage_path() . $file->name);

or

return response()->file(storage_path() . $file->name);

Both are not working on https in safari. But they are working on https in chrome. And also they are working without https in safari.

Any ideas?

When using safari with https there is the following error message on the browser console: Failed to load resource: The operation couldn’t be completed. Protocol error.

Could it be related to the follwing issue? https://stackoverflow.com/questions/37762163/safari-fails-to-give-response-when-using-http-2

laracoft's avatar

@alexh

  1. What happens when you try HTTPS without HTTP2 on Safari?
  2. Since Chrome worked, it is logical to assume the issue is with Safari
  3. If Safari support is a must, I would just disable HTTP2
  4. Of course you can always disable the Upgrade header like mentioned in the stackoverflow post
alexh's avatar
Level 5

Hi Laracroft, thanks for your reply!

1: there is no difference. We have removed the https2 from the nginx configuration and have restarted the webserver. Same issue.

  1. We also tried to update the header by inserting the following command in the nginx configuration: proxy_hide_header Upgrade; But still no difference after restarting the server.

Here is the http response if it may help:

200 X-Content-Type-Options: nosniff Content-Type: application/pdf Set-Cookie: XSRF-TOKEN=eyJpdiI6ImpVcHZodHkxeDRmL3RJcFdXVk1qTWc9PSIsInZhbHVlIjoiVlNDanBPbVkxeUdhcHR6bGx2THViNFp6Mmw5VEhkR2x1dXMrSFZMTC9ESUdhd1F4VWtxaXRES2RuWEZtZ2pDVDgvSlFmSTgzOExwTGZBTmVQZ3VNTkpHZUhFTHRNZngveEhVbG5UbUdDaDUxN250cDJOWXBaWURXZFhTaHI0VEUiLCJtYWMiOiJjNzIzMTUwMGQ0ZGI4ZDc3Yzk1MGZlZTM0OWNlNGIxOGNjMmU2MWE4ODlhYzgzYzg1NTI1YzcyYTFhNWVlODE4In0%3D; expires=Fri, 30-Oct-2020 14:56:12 GMT; Max-Age=7200; path=/; samesite=lax, test_versservice_session=eyJpdiI6IitkK2wxY0gxd0NoQ1VUT3JjaTdOZHc9PSIsInZhbHVlIjoiSzZkcXRqajcxeFFYWXpFYkhZdks4ZmZrUFJ0Si93TjZ1STJqOHYvL2lqNEVyQzNVR0ZPYzFVbTVaOGdNRW4wend3R251cHlmWmxCOTBNNjNUdUlvaGNjTG5kWVYrc1VBZ2g3dnhRYXA4eC9KS1V0ZnFHQzZVR0p1YSt5MXVLUlgiLCJtYWMiOiIwODYyNmYyZWQzYWI4MTE3MmNmMDNiNjg4NTU1NzIzYTBhZGYwYzc3MGZhZWUzZjlmNjgyODRlOWY5NjE2ZDc2In0%3D; expires=Fri, 30-Oct-2020 14:56:12 GMT; Max-Age=7200; path=/; httponly; samesite=lax Date: Fri, 30 Oct 2020 12:56:12 GMT X-Frame-Options: SAMEORIGIN Content-Disposition: inline; filename=11604062572-maklervertrag.pdf X-XSS-Protection: 1; mode=block Content-Length: 18836 Cache-Control: no-cache, private Server: nginx

gecche's avatar

Hi all,

I have this issue too.

It seems that it affects only pdfs and I solved this by using

Response::make(file_get_contents($filename), 200, [ 'Content-Type' => 'application/pdf', 'Content-Disposition' => 'attachment; filename="' . $relativeName . '"' ]);

instead of

Response::download($filename,$relativeName);

Hope this helps

stuartcusack's avatar

I had to do this on an old Laravel 5.7 installation after switching to CloudFlare:

ob_clean ( )
return Storage::disk('local')->download($pathToFile);

Please or to participate in this conversation.