Skip to content

Commit

Permalink
Fix:ameba
Browse files Browse the repository at this point in the history
  • Loading branch information
y2k2mt committed Nov 23, 2022
1 parent da1a74e commit b4196ca
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
18 changes: 11 additions & 7 deletions src/replay/http/record.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ class HTTPRecord
end

def initialize(client_response : HTTP::Client::Response, request : Request)
initialize(
headers: client_response.headers,
body: client_response.body,
response_status: client_response.status_code,
response: client_response.not_nil!,
request: request,
)
if client_response
initialize(
headers: client_response.headers,
body: client_response.body,
response_status: client_response.status_code,
response: client_response,
request: request,
)
else
raise "Client response is not avairable for record"
end
end

def initialize(headers_content : IO, body_content : IO, request : Request)
Expand Down
16 changes: 12 additions & 4 deletions src/replay/http/request.cr
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ class HTTPRequest
@params : Hash(String, String)

def initialize(@http_request : HTTP::Request, @base_uri : URI)
base_uri.host.try do |host|
http_request.headers["Host"] = host
maybe_host = base_uri.host
if maybe_host
http_request.headers["Host"] = maybe_host
@host_name = maybe_host
else
raise "Request URI is collapsed : #{base_uri}"
end
@id = Random::Secure.hex
@host_name = base_uri.host.not_nil!
@path = @http_request.path
@method = @http_request.method
@headers = @http_request.headers.to_h
Expand Down Expand Up @@ -45,7 +48,12 @@ class HTTPRequest
)
@id = id
@base_uri = base_uri
@host_name = base_uri.host.not_nil!
maybe_host = base_uri.host
if maybe_host
@host_name = maybe_host
else
raise "Request URI is collapsed : #{base_uri}"
end
@path = path
@method = method
@headers = headers
Expand Down

0 comments on commit b4196ca

Please sign in to comment.