Class: Samuel::LogEntries::NetHttp

Inherits:
Base
  • Object
show all
Defined in:
lib/samuel/log_entries/net_http.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize, #log!

Constructor Details

This class inherits a constructor from Samuel::LogEntries::Base

Instance Method Details

#error?Boolean

Returns:

  • (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

#hostObject



5
6
7
# File 'lib/samuel/log_entries/net_http.rb', line 5

def host
  @http.address
end

#methodObject



25
26
27
# File 'lib/samuel/log_entries/net_http.rb', line 25

def method
  @request.method.to_s.upcase
end

#pathObject



9
10
11
# File 'lib/samuel/log_entries/net_http.rb', line 9

def path
  @request.path.split("?")[0]
end

#portObject



21
22
23
# File 'lib/samuel/log_entries/net_http.rb', line 21

def port
  @http.port
end

#queryObject



13
14
15
# File 'lib/samuel/log_entries/net_http.rb', line 13

def query
  @request.path.split("?")[1]
end

#schemeObject



17
18
19
# File 'lib/samuel/log_entries/net_http.rb', line 17

def scheme
  @http.use_ssl? ? "https" : "http"
end

#status_codeObject



29
30
31
# File 'lib/samuel/log_entries/net_http.rb', line 29

def status_code
  @response.code
end

#status_messageObject



33
34
35
# File 'lib/samuel/log_entries/net_http.rb', line 33

def status_message
  @response.message.strip
end