Class: ClickhouseRuby::Connection::DecompressedResponse
- Inherits:
-
Object
- Object
- ClickhouseRuby::Connection::DecompressedResponse
- Defined in:
- lib/clickhouse_ruby/connection.rb
Overview
Wrapper for automatically decompressing gzip responses
Instance Method Summary collapse
-
#[](header) ⇒ String?
Returns a header value.
-
#body ⇒ String
Returns the decompressed response body.
-
#code ⇒ String
Returns the HTTP status code.
-
#initialize(response) ⇒ DecompressedResponse
constructor
A new instance of DecompressedResponse.
Constructor Details
#initialize(response) ⇒ DecompressedResponse
Returns a new instance of DecompressedResponse.
410 411 412 413 |
# File 'lib/clickhouse_ruby/connection.rb', line 410 def initialize(response) @response = response @decompressed_body = nil end |
Instance Method Details
#[](header) ⇒ String?
Returns a header value
426 427 428 |
# File 'lib/clickhouse_ruby/connection.rb', line 426 def [](header) @response[header] end |
#body ⇒ String
Returns the decompressed response body
433 434 435 436 437 438 439 440 441 |
# File 'lib/clickhouse_ruby/connection.rb', line 433 def body @decompressed_body ||= begin return @response.body if @response.body.nil? || @response.body.empty? Zlib.gunzip(@response.body) rescue Zlib::Error @response.body end end |
#code ⇒ String
Returns the HTTP status code
418 419 420 |
# File 'lib/clickhouse_ruby/connection.rb', line 418 def code @response.code end |