Sha256: 6064cc2b234f533a1e7f560667bfbbb198590b9f87a8a0ca3198918c6a1d0b22

Contents?: true

Size: 1.05 KB

Versions: 9

Compression:

Stored size: 1.05 KB

Contents

# encoding: utf-8
# This file is distributed under Ting Yun's license terms.

require 'zlib'
require 'net/https'
require 'net/http'
require 'ting_yun/ting_yun_service/ssl'
require 'ting_yun/ting_yun_service/request'
require 'ting_yun/ting_yun_service/connection'

module TingYun
  class TingYunService
    module Http

      include Ssl
      include Request
      include Connection

      def remote_method_uri(method)
        params = {'licenseKey'=> @license_key,'version' => @data_version}
        params[:appSessionKey] = @appSessionKey if @appSessionKey
        uri = "/" + method.to_s
        uri << '?' + params.map do |k,v|
          next unless v
          "#{k}=#{v}"
        end.compact.join('&')
        uri
      end

      # Decompresses the response from the server, if it is gzip
      # encoded, otherwise returns it verbatim
      def decompress_response(response)
        if response['content-encoding'] == 'gzip'
          Zlib::GzipReader.new(StringIO.new(response.body)).read
        else
          response.body
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
tingyun_rpm-1.1.4.2 lib/ting_yun/ting_yun_service/http.rb
tingyun_rpm-1.1.4.1 lib/ting_yun/ting_yun_service/http.rb
tingyun_rpm-1.1.4 lib/ting_yun/ting_yun_service/http.rb
tingyun_rpm-1.1.3 lib/ting_yun/ting_yun_service/http.rb
tingyun_rpm-1.1.2 lib/ting_yun/ting_yun_service/http.rb
tingyun_rpm-1.1.1 lib/ting_yun/ting_yun_service/http.rb
tingyun_rpm-1.1.0 lib/ting_yun/ting_yun_service/http.rb
tingyun_rpm-1.0.7 lib/ting_yun/ting_yun_service/http.rb
tingyun_rpm-1.0.6 lib/ting_yun/ting_yun_service/http.rb