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

URI decode the request path. #719

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
URI decode the request path.
  • Loading branch information
gdotdesign committed Nov 27, 2024
commit f4f77b3e8aa91d7ae2ee8a9a6f3a6be7ec51046c
7 changes: 5 additions & 2 deletions src/reactor.cr
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,14 @@ module Mint
HTTP::CompressHandler.new,
websocket_handler,
]) do |context|
path =
URI.decode(context.request.path)

# Handle the request depending on the result.
content_type, content =
if file = @files[context.request.path]?
if file = @files[path]?
{
MIME.from_filename?(context.request.path).to_s || "text/plain",
MIME.from_filename?(path).to_s || "text/plain",
file.call,
}
else
Expand Down
11 changes: 6 additions & 5 deletions src/test_runner.cr
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,15 @@ module Mint
end

@server =
HTTP::Server.new([
websocket_handler,
]) do |context|
HTTP::Server.new([websocket_handler]) do |context|
path =
URI.decode(context.request.path)

# Handle the request depending on the result.
content_type, content =
if file = @files[context.request.path]?
if file = @files[path]?
{
MIME.from_filename?(context.request.path).to_s || "text/plain",
MIME.from_filename?(path).to_s || "text/plain",
file.call,
}
else
Expand Down