Module: Ur::RequestAndResponse
Overview
functionality common to Request and Response
Defined Under Namespace
Modules: FaradayEntity
Instance Method Summary collapse
-
#content_type ⇒ Ur::ContentType
the string value of the content type header.
-
#form_urlencoded? ⇒ Boolean
is our content type
x-www-form-urlencoded
?. -
#json? ⇒ Boolean
is our content type JSON?.
-
#media_type ⇒ Object
the media type of the content type.
-
#xml? ⇒ Boolean
is our content type XML?.
Methods included from FaradayEntity
Instance Method Details
#content_type ⇒ Ur::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.
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
?
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?
46 47 48 |
# File 'lib/ur/request_and_response.rb', line 46 def json? content_type && content_type.json? end |
#media_type ⇒ Object
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?
52 53 54 |
# File 'lib/ur/request_and_response.rb', line 52 def xml? content_type && content_type.xml? end |