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)


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

#hostObject



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

def host
  @http.address
end

#methodObject



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

def method
  @request.method.to_s.upcase
end

#pathObject



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

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

#portObject



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

def port
  @http.port
end

#queryObject



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

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

#schemeObject



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

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

#status_codeObject



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

def status_code
  @response.code
end

#status_messageObject



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

def status_message
  @response.message.strip
end