Class: NetHTTP::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/response/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Response

Returns a new instance of Response.



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/response/response.rb', line 21

def initialize(opts = {})
  send('logger=', opts[:logger])
  @response = opts[:response]
  send('response=', opts[:response])
  send('code=')
  send('headers=')
  send('headers_hash=')
  send('headers_os=')
  send('body=')
  send('body_obj=')
  send('body_os=')
  log_response
end

Instance Attribute Details

#bodyObject Also known as: resp_body, response_body

Returns the value of attribute body.



11
12
13
# File 'lib/response/response.rb', line 11

def body
  @body
end

#body_objObject Also known as: resp_body_obj, response_body_obj

Returns the value of attribute body_obj.



11
12
13
# File 'lib/response/response.rb', line 11

def body_obj
  @body_obj
end

#body_osObject Also known as: resp_body_os, response_body_os, body_open_struct, resp_body_open_struct, response_body_open_struct

Returns the value of attribute body_os.



11
12
13
# File 'lib/response/response.rb', line 11

def body_os
  @body_os
end

#codeObject Also known as: resp_code, response_code

Returns the value of attribute code.



11
12
13
# File 'lib/response/response.rb', line 11

def code
  @code
end

#headersObject Also known as: resp_headers, response_headers

Returns the value of attribute headers.



11
12
13
# File 'lib/response/response.rb', line 11

def headers
  @headers
end

#headers_hashObject Also known as: resp_headers_hash, response_headers_hash

Returns the value of attribute headers_hash.



11
12
13
# File 'lib/response/response.rb', line 11

def headers_hash
  @headers_hash
end

#headers_osObject Also known as: resp_headers_os, response_headers_os, headers_open_struct, resp_headers_struct, response_headers_open_struct

Returns the value of attribute headers_os.



11
12
13
# File 'lib/response/response.rb', line 11

def headers_os
  @headers_os
end

#logger=(logger = nil) ⇒ Object



135
136
137
# File 'lib/response/response.rb', line 135

def logger=(logger = nil)
  @logger = Core.get_logger(logger)
end

#response=(response) ⇒ Object



116
117
118
# File 'lib/response/response.rb', line 116

def response=(response)
  @response = response
end

Instance Method Details

#log_responseObject



139
140
141
142
143
144
145
# File 'lib/response/response.rb', line 139

def log_response
  logger.debug('Response Code => ' + code)
  logger.debug('Response Headers => ')
  logger.debug(headers)
  logger.debug('Response Body => ')
  logger.debug(body)
end

#valid_html?Boolean

Returns:

  • (Boolean)


128
129
130
# File 'lib/response/response.rb', line 128

def valid_html?
  NetHTTP::Core::Utilities.valid_html?(body, logger)
end

#valid_json?Boolean

Returns:

  • (Boolean)


120
121
122
# File 'lib/response/response.rb', line 120

def valid_json?
  NetHTTP::Core::Utilities.valid_json?(body, logger)
end

#valid_xml?Boolean

Returns:

  • (Boolean)


124
125
126
# File 'lib/response/response.rb', line 124

def valid_xml?
  NetHTTP::Core::Utilities.valid_xml?(body, logger)
end