Module: TingYun::TingYunService::Http

Includes:
Connection, Request, Ssl
Included in:
TingYun::TingYunService
Defined in:
lib/ting_yun/ting_yun_service/http.rb

Instance Method Summary collapse

Methods included from Connection

#close_shared_connection, #create_and_start_http_connection, #create_http_connection, #establish_shared_connection, #http_connection, #session, #session_with_keepalive, #session_without_keepalive, #setup_connection_timeouts, #start_connection

Methods included from Request

#check_post_size, #compress_request_if_needed, #send_request, #send_requestV3, #user_agent, #valid_to_marshal?

Methods included from Ssl

#cert_file_path, #setup_connection_for_ssl, #ssl_cert_store

Instance Method Details

#decompress_response(response) ⇒ Object

Decompresses the response from the server, if it is gzip encoded, otherwise returns it verbatim



37
38
39
40
41
42
43
# File 'lib/ting_yun/ting_yun_service/http.rb', line 37

def decompress_response(response)
  if response['content-encoding'] == 'gzip'
    Zlib::GzipReader.new(StringIO.new(response.body)).read
  else
    response.body
  end
end

#remote_method_uri(method) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ting_yun/ting_yun_service/http.rb', line 20

def remote_method_uri(method)
  params = {'version'=> @data_version}
  params[:license] = @license_key unless method == :trace
  raise ::TingYun::Support::Exception::AppSessionKeyError.new("@appSessionKey is asked when the upload-method happen") if method==:trace && @appSessionKey.nil?
  params[:sessionKey] = @appSessionKey
  params[:format] = "json"

  uri = "/" + method.to_s
  uri << '?' + params.map do |k,v|
    next unless v
    "#{k}=#{v}"
  end.compact.join('&')
  uri
end