Skip to content

Dream.static is returning incorrect headers for non-exists file #88

@thangngoc89

Description

@thangngoc89

Given a static route like this one

Dream.get("/**") @@ Dream.static("public")

Try to access random route would have these behavior:

  • Chrome shows ERR_INVALID_RESPONSE
  • Safari downloads an empty file automatically
  • dream.log shows 404
  • curl -v -o - http://localhost:5000/not-exists
curl -v -o - http://localhost:5000/dasdabbbbsd
*   Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 5000 failed: Connection refused
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 5000 (#0)
> GET /dasdabbbbsd HTTP/1.1
> Host: localhost:5000
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Content-Type: application/octet-stream
< Set-Cookie: dream.session=0JDfhSEyb-zsmGQA1cFJae_G2; Max-Age=1209599; Path=/; HttpOnly; SameSite=Strict
< Content-Length: 0
<
* Connection #0 to host localhost left intact

@aantron said on Discord that those headers shouldn't be there.

  • Content-Type is probably what trigger safari to download it as file

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions