Module: Ur::RequestAndResponse

Includes:
FaradayEntity
Included in:
Request, Response
Defined in:
lib/ur/request_and_response.rb

Overview

functionality common to Request and Response

Defined Under Namespace

Modules: FaradayEntity

Instance Method Summary collapse

Methods included from FaradayEntity

#set_body_from_faraday

Instance Method Details

#content_typeUr::ContentType

the string value of the content type header. returns an ContentType, a subclass of String which additionally parses the Content-Type according to relevant RFCs.

Returns:



32
33
34
35
36
37
# File 'lib/ur/request_and_response.rb', line 32

def content_type
  headers.each do |k, v|
    return ContentType.new(v) if k =~ /\Acontent[-_]type\z/i
  end
  nil
end

#form_urlencoded?Boolean

is our content type x-www-form-urlencoded?

Returns:

  • (Boolean)


58
59
60
# File 'lib/ur/request_and_response.rb', line 58

def form_urlencoded?
  content_type && content_type.form_urlencoded?
end

#json?Boolean

is our content type JSON?

Returns:

  • (Boolean)


46
47
48
# File 'lib/ur/request_and_response.rb', line 46

def json?
  content_type && content_type.json?
end

#media_typeObject

the media type of the content type



40
41
42
# File 'lib/ur/request_and_response.rb', line 40

def media_type
  content_type ? content_type.media_type : nil
end

#xml?Boolean

is our content type XML?

Returns:

  • (Boolean)


52
53
54
# File 'lib/ur/request_and_response.rb', line 52

def xml?
  content_type && content_type.xml?
end