Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing custom headers for directory requests (trailing slash) #333

Merged
merged 6 commits into from
Apr 11, 2024

Conversation

joseluisq
Copy link
Collaborator

Description

This PR fixes an issue where custom headers were not applied to the response for directory requests (requests ending with the slash character).

Related Issue

Fixes #332

Motivation and Context

How Has This Been Tested?

Server

[advanced]

[[advanced.headers]]
source = "**/*.{html,htm}"
headers = { Server = "Static Web Server" }
static-web-server -w config.toml

Client requests

Request 1

curl -I "http://localhost/index.html"
# HTTP/1.1 200 OK
# content-length: 536
# content-type: text/html
# accept-ranges: bytes
# last-modified: Mon, 01 Apr 2024 22:00:03 GMT
# vary: accept-encoding
# cache-control: public, max-age=86400
# server: Static Web Server
# date: Sun, 07 Apr 2024 23:00:09 GMT

Request 2

curl -I "http://localhost/"
# HTTP/1.1 200 OK
# content-length: 536
# content-type: text/html
# accept-ranges: bytes
# last-modified: Mon, 01 Apr 2024 22:00:03 GMT
# vary: accept-encoding
# cache-control: public, max-age=86400
# server: Static Web Server
# date: Sun, 07 Apr 2024 23:00:26 GMT

Screenshots (if appropriate):

@joseluisq joseluisq added v2 v2 release advanced-feature Advanced feature only available via the configuration file bugfix This is PR fixes a bug labels Apr 7, 2024
@joseluisq joseluisq self-assigned this Apr 7, 2024
Copy link

semanticdiff-com bot commented Apr 7, 2024

Review changes with SemanticDiff.

Analyzed 7 of 8 files.

Overall, the semantic diff is 34% smaller than the GitHub diff.

Filename Status
✔️ src/custom_headers.rs 27.27% smaller
✔️ src/handler.rs 24.0% smaller
✔️ src/static_files.rs 52.86% smaller
✔️ tests/compression_static.rs Analyzed
✔️ tests/dir_listing.rs 50.76% smaller
tests/fixtures/toml/handler.toml Unsupported file format
✔️ tests/handler.rs Analyzed
✔️ tests/static_files.rs 47.49% smaller

@joseluisq joseluisq marked this pull request as draft April 7, 2024 23:21
@joseluisq joseluisq changed the base branch from master to inline-several-functions April 7, 2024 23:21
@joseluisq joseluisq force-pushed the fix-missing-custom-headers-for-auto-index branch 2 times, most recently from 4e0a604 to ba614ed Compare April 7, 2024 23:28
@joseluisq joseluisq force-pushed the inline-several-functions branch 2 times, most recently from e511973 to 8892a56 Compare April 9, 2024 22:41
@joseluisq joseluisq changed the base branch from inline-several-functions to master April 9, 2024 22:52
@joseluisq joseluisq force-pushed the fix-missing-custom-headers-for-auto-index branch from 47be8e2 to 96311bf Compare April 11, 2024 16:16
@joseluisq joseluisq marked this pull request as ready for review April 11, 2024 22:36
@joseluisq joseluisq merged commit c04357e into master Apr 11, 2024
24 checks passed
@joseluisq joseluisq deleted the fix-missing-custom-headers-for-auto-index branch April 11, 2024 23:15
@joseluisq joseluisq added this to the v2.30.0 milestone Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
advanced-feature Advanced feature only available via the configuration file bugfix This is PR fixes a bug v2 v2 release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Configuration advanced.headers is not applied when html served though 'index-files' matching
1 participant