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

permanent redir should avoid used when redir foo-dir to foo-dir/ #130

Merged
merged 1 commit into from
Aug 26, 2021

Conversation

ttys3
Copy link
Contributor

@ttys3 ttys3 commented Aug 26, 2021

Motivation

The problem is about default browser behavior like Chrome.

for example the root dir has a sub dir named foo and it does exists.

when user agent access /foo, by default, tower ServeDir will redirect it to /foo/

this is OK.

but somehow, you moved the foo dir to other place. and you wnat't to put a file named foo

yes, they have the same name.

then if you try to access the uri again: /foo, Chrome will not contact the http server again

and just do a client side redirect since you tell Chrome that it is permanent redirect.

image

yes, it shows Status Code: 308 Permanent Redirect (from disk cache)

you'll never have the chance to access the file named foo if you don't do a Empty Cache and Hard Reload operation. (Hard Reload and Normal Reload can not clean a Permanent Redirect)

Solution

use temporay redirect.

@ttys3 ttys3 force-pushed the permanent-redir-should-not-used branch from c7fe812 to 82ca3e6 Compare August 26, 2021 18:22
Copy link
Member

@davidpdrsn davidpdrsn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Wanna add a file to changelog as well?

@ttys3 ttys3 force-pushed the permanent-redir-should-not-used branch from 82ca3e6 to aea3136 Compare August 26, 2021 19:23
@ttys3
Copy link
Contributor Author

ttys3 commented Aug 26, 2021

Thanks!

Wanna add a file to changelog as well?

changelog added

@davidpdrsn davidpdrsn merged commit 3ee9a09 into tower-rs:master Aug 26, 2021
@ttys3 ttys3 deleted the permanent-redir-should-not-used branch August 26, 2021 20:20
davidpdrsn added a commit that referenced this pull request Nov 13, 2021
- New middleware: Add `Cors` for setting [CORS] headers ([#112])
- New middleware: Add `AsyncRequireAuthorization` ([#118])
- `Compression`: Don't recompress HTTP responses ([#140])
- `Compression` and `Decompression`: Pass configuration from layer into middleware ([#132])
- `ServeDir` and `ServeFile`: Improve performance ([#137])
- `Compression`: Remove needless `ResBody::Error: Into<BoxError>` bounds ([#117])
- `ServeDir`: Percent decode path segments ([#129])
- `ServeDir`: Use correct redirection status ([#130])
- `ServeDir`: Return `404 Not Found` on requests to directories if
  `append_index_html_on_directories` is set to `false` ([#122])

[#112]: #112
[#118]: #118
[#140]: #140
[#132]: #132
[#137]: #137
[#117]: #117
[#129]: #129
[#130]: #130
[#122]: #122
@davidpdrsn davidpdrsn mentioned this pull request Nov 13, 2021
davidpdrsn added a commit that referenced this pull request Nov 13, 2021
- New middleware: Add `Cors` for setting [CORS] headers ([#112])
- New middleware: Add `AsyncRequireAuthorization` ([#118])
- `Compression`: Don't recompress HTTP responses ([#140])
- `Compression` and `Decompression`: Pass configuration from layer into middleware ([#132])
- `ServeDir` and `ServeFile`: Improve performance ([#137])
- `Compression`: Remove needless `ResBody::Error: Into<BoxError>` bounds ([#117])
- `ServeDir`: Percent decode path segments ([#129])
- `ServeDir`: Use correct redirection status ([#130])
- `ServeDir`: Return `404 Not Found` on requests to directories if
  `append_index_html_on_directories` is set to `false` ([#122])

[#112]: #112
[#118]: #118
[#140]: #140
[#132]: #132
[#137]: #137
[#117]: #117
[#129]: #129
[#130]: #130
[#122]: #122
davidpdrsn added a commit that referenced this pull request Nov 13, 2021
- New middleware: Add `Cors` for setting [CORS] headers ([#112])
- New middleware: Add `AsyncRequireAuthorization` ([#118])
- `Compression`: Don't recompress HTTP responses ([#140])
- `Compression` and `Decompression`: Pass configuration from layer into middleware ([#132])
- `ServeDir` and `ServeFile`: Improve performance ([#137])
- `Compression`: Remove needless `ResBody::Error: Into<BoxError>` bounds ([#117])
- `ServeDir`: Percent decode path segments ([#129])
- `ServeDir`: Use correct redirection status ([#130])
- `ServeDir`: Return `404 Not Found` on requests to directories if
  `append_index_html_on_directories` is set to `false` ([#122])

[#112]: #112
[#118]: #118
[#140]: #140
[#132]: #132
[#137]: #137
[#117]: #117
[#129]: #129
[#130]: #130
[#122]: #122
davidpdrsn added a commit that referenced this pull request Nov 13, 2021
- New middleware: Add `Cors` for setting [CORS] headers ([#112])
- New middleware: Add `AsyncRequireAuthorization` ([#118])
- `Compression`: Don't recompress HTTP responses ([#140])
- `Compression` and `Decompression`: Pass configuration from layer into middleware ([#132])
- `ServeDir` and `ServeFile`: Improve performance ([#137])
- `Compression`: Remove needless `ResBody::Error: Into<BoxError>` bounds ([#117])
- `ServeDir`: Percent decode path segments ([#129])
- `ServeDir`: Use correct redirection status ([#130])
- `ServeDir`: Return `404 Not Found` on requests to directories if
  `append_index_html_on_directories` is set to `false` ([#122])

[#112]: #112
[#118]: #118
[#140]: #140
[#132]: #132
[#137]: #137
[#117]: #117
[#129]: #129
[#130]: #130
[#122]: #122
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants