mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #40173 from p8/shorten-inspect-on-request
Shorten inspect on ActionDispatch::Request
This commit is contained in:
commit
451c3c0a1b
2 changed files with 18 additions and 0 deletions
|
@ -431,6 +431,10 @@ module ActionDispatch
|
|||
super || scheme == "wss"
|
||||
end
|
||||
|
||||
def inspect # :nodoc:
|
||||
"#<#{self.class.name} #{method} #{original_url.dump} for #{remote_ip}>"
|
||||
end
|
||||
|
||||
private
|
||||
def check_method(name)
|
||||
HTTP_METHOD_LOOKUP[name] || raise(ActionController::UnknownHttpMethod, "#{name}, accepted HTTP methods are #{HTTP_METHODS[0...-1].join(', ')}, and #{HTTP_METHODS[-1]}")
|
||||
|
|
|
@ -1290,3 +1290,17 @@ class EarlyHintsRequestTest < BaseRequestTest
|
|||
assert_equal expected_hints, early_hints
|
||||
end
|
||||
end
|
||||
|
||||
class RequestInspectTest < BaseRequestTest
|
||||
test "inspect" do
|
||||
request = stub_request(
|
||||
"REQUEST_METHOD" => "POST",
|
||||
"REMOTE_ADDR" => "1.2.3.4",
|
||||
"HTTP_X_FORWARDED_PROTO" => "https",
|
||||
"HTTP_X_FORWARDED_HOST" => "example.com:443",
|
||||
"PATH_INFO" => "/path/",
|
||||
"QUERY_STRING" => "q=1"
|
||||
)
|
||||
assert_match %r(#<ActionDispatch::Request POST "https://example.com/path/\?q=1" for 1.2.3.4>), request.inspect
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue