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
37
38
39
40
41
|
# File 'lib/samuel/log_entries/net_http.rb', line 37
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
5
6
7
|
# File 'lib/samuel/log_entries/net_http.rb', line 5
def host
@http.address
end
|
#method ⇒ Object
25
26
27
|
# File 'lib/samuel/log_entries/net_http.rb', line 25
def method
@request.method.to_s.upcase
end
|
#path ⇒ Object
9
10
11
|
# File 'lib/samuel/log_entries/net_http.rb', line 9
def path
@request.path.split("?")[0]
end
|
#port ⇒ Object
21
22
23
|
# File 'lib/samuel/log_entries/net_http.rb', line 21
def port
@http.port
end
|
#query ⇒ Object
13
14
15
|
# File 'lib/samuel/log_entries/net_http.rb', line 13
def query
@request.path.split("?")[1]
end
|
#scheme ⇒ Object
17
18
19
|
# File 'lib/samuel/log_entries/net_http.rb', line 17
def scheme
@http.use_ssl? ? "https" : "http"
end
|
#status_code ⇒ Object
29
30
31
|
# File 'lib/samuel/log_entries/net_http.rb', line 29
def status_code
@response.code
end
|
#status_message ⇒ Object
33
34
35
|
# File 'lib/samuel/log_entries/net_http.rb', line 33
def status_message
@response.message.strip
end
|