Class: COS::HTTP

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/cos/http.rb

Constant Summary collapse

DEFAULT_CONTENT_TYPE =

默认content-type

'application/json'
OPEN_TIMEOUT =

请求创建超时

30
READ_TIMEOUT =

响应读取超时

120

Constants included from Logging

Logging::DEFAULT_LOG_FILE, Logging::MAX_NUM_LOG, Logging::ROTATE_SIZE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

#logger, set_logger

Constructor Details

#initialize(config) ⇒ HTTP

Returns a new instance of HTTP.



23
24
25
26
# File 'lib/cos/http.rb', line 23

def initialize(config)
  @config    = config
  @signature = Signature.new(config)
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



21
22
23
# File 'lib/cos/http.rb', line 21

def config
  @config
end

#signatureObject (readonly)

Returns the value of attribute signature.



21
22
23
# File 'lib/cos/http.rb', line 21

def signature
  @signature
end

Instance Method Details

#get(path, headers, signature = nil) ⇒ Object

GET请求



29
30
31
# File 'lib/cos/http.rb', line 29

def get(path, headers, signature = nil)
  do_request('GET', path, headers, signature)
end

#post(path, headers, signature, payload) ⇒ Object

POST请求



34
35
36
# File 'lib/cos/http.rb', line 34

def post(path, headers, signature, payload)
  do_request('POST', path, headers, signature, payload)
end