Class: ActiveResource::Connection
- Inherits:
-
Object
- Object
- ActiveResource::Connection
- Defined in:
- lib/liquidplanner/ext/connection.rb
Instance Method Summary collapse
-
#enable_gzip ⇒ Object
force accept-encoding request header to “gzip” so that server compresses its response.
-
#get_raw(path, headers = {}) ⇒ Object
get a raw response (not just the decoded response body); used for non-standard responses (e.g. binary / file data).
- #handle_response(response) ⇒ Object
-
#handle_response_without_gzip ⇒ Object
transparently decompress response body, if content-encoding indicates it is gzipped.
Instance Method Details
#enable_gzip ⇒ Object
force accept-encoding request header to “gzip” so that server compresses its response
13 14 15 |
# File 'lib/liquidplanner/ext/connection.rb', line 13 def enable_gzip default_header['accept-encoding'] = 'gzip' end |
#get_raw(path, headers = {}) ⇒ Object
get a raw response (not just the decoded response body); used for non-standard responses (e.g. binary / file data)
6 7 8 |
# File 'lib/liquidplanner/ext/connection.rb', line 6 def get_raw(path, headers = {}) with_auth { request(:get, path, build_request_headers(headers, :get, self.site.merge(path))) } end |
#handle_response(response) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/liquidplanner/ext/connection.rb', line 21 def handle_response(response) if 'gzip' == response['content-encoding'] response.body = Zlib::GzipReader.new(StringIO.new(response.body)).read response.delete('content-encoding') end handle_response_without_gzip(response) end |
#handle_response_without_gzip ⇒ Object
transparently decompress response body, if content-encoding indicates it is gzipped
20 |
# File 'lib/liquidplanner/ext/connection.rb', line 20 alias_method :handle_response_without_gzip, :handle_response |