http-server icon indicating copy to clipboard operation
http-server copied to clipboard

Serve compressed files if already exist

Open De-Panther opened this issue 3 years ago • 2 comments

If file is already compressed (ends with .gz or .br), no need to add those file extensions. Sometime files are already compressed and needs to serve with the correct header. In some cases engines like Unity output some of the files as compressed and others not.

This change allows to serve already compressed files even if Serve GZIP Files or Serve Brotli Files are false.

I'm not sure how to write a test, or if this change should be documented. It seems to me like an obvious outcome when serving a .gz or .br file. So I think it's a bug fix rather than a feature or a change in a feature.

Relevant issues

Resolves #844 Resolves #780

Contributor checklist
  • [x] Provide tests for the changes (unless documentation-only)
  • [ ] Documented any new features, CLI switches, etc. (if applicable)
    • [ ] Server --help output
    • [ ] README.md
    • [ ] doc/http-server.1 (use the same format as other entries)
  • [x] The pull request is being made against the master branch
Maintainer checklist
  • [ ] Assign a version triage tag
  • [ ] Approve tests if applicable

De-Panther avatar Feb 06 '23 23:02 De-Panther

Apparently there were already tests for gzip and brotli, and my first commit broke the Content-Type tests. I moved the defaultType to the start of the process right after the options are parsed. Also moved the MIME lookup to right after we get the file, which made redundant the special lookup for compressed files.

Some unrelated CLI tests don't work for me both on master and on this PR.

@thornjad is there something else I should do for this PR to be approved? Thanks

De-Panther avatar Jul 10 '23 23:07 De-Panther

This pull request has been inactive for 360 days

github-actions[bot] avatar Jul 05 '24 12:07 github-actions[bot]