Skip to content

Commit

Permalink
Fix KeyError with missing Host in HTTP::Request
Browse files Browse the repository at this point in the history
  • Loading branch information
felixbuenemann committed Jul 19, 2018
1 parent 7e7e7ff commit 4655868
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/webmock/stub.cr
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ class WebMock::Stub
end

def matches_host?(request)
host_uri = parse_uri(request.headers["Host"])
host_uri.host == @uri.host && host_uri.port == @uri.port
if host_header = request.headers["Host"]?
host_uri = parse_uri(host_header)
host_uri.host == @uri.host && host_uri.port == @uri.port
else
true
end
end

def matches_path?(request)
Expand Down

0 comments on commit 4655868

Please sign in to comment.