Class: Samuel::LogEntries::NetHttp
- Inherits:
-
Base
- Object
- Base
- Samuel::LogEntries::NetHttp
show all
- Defined in:
- lib/samuel/log_entries/net_http.rb
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #log!
Instance Method Details
#error? ⇒ Boolean
36
37
38
39
40
|
# File 'lib/samuel/log_entries/net_http.rb', line 36
def error?
error_classes = %w(Exception Net::HTTPClientError Net::HTTPServerError)
response_ancestors = @response.class.ancestors.map { |a| a.to_s }
(error_classes & response_ancestors).any?
end
|
#host ⇒ Object
4
5
6
|
# File 'lib/samuel/log_entries/net_http.rb', line 4
def host
@http.address
end
|
#method ⇒ Object
24
25
26
|
# File 'lib/samuel/log_entries/net_http.rb', line 24
def method
@request.method.to_s.upcase
end
|
#path ⇒ Object
8
9
10
|
# File 'lib/samuel/log_entries/net_http.rb', line 8
def path
@request.path.split("?")[0]
end
|
#port ⇒ Object
20
21
22
|
# File 'lib/samuel/log_entries/net_http.rb', line 20
def port
@http.port
end
|
#query ⇒ Object
12
13
14
|
# File 'lib/samuel/log_entries/net_http.rb', line 12
def query
@request.path.split("?")[1]
end
|
#scheme ⇒ Object
16
17
18
|
# File 'lib/samuel/log_entries/net_http.rb', line 16
def scheme
@http.use_ssl? ? "https" : "http"
end
|
#status_code ⇒ Object
28
29
30
|
# File 'lib/samuel/log_entries/net_http.rb', line 28
def status_code
@response.code
end
|
#status_message ⇒ Object
32
33
34
|
# File 'lib/samuel/log_entries/net_http.rb', line 32
def status_message
@response.message.strip
end
|