Class: Hprose::HttpClient

Inherits:
Client
  • Object
show all
Defined in:
lib/hprose/httpclient.rb

Constant Summary

Constants included from ResultMode

ResultMode::Normal, ResultMode::Raw, ResultMode::RawWithEndTag, ResultMode::Serialized

Constants included from Tags

Tags::TagArgument, Tags::TagBytes, Tags::TagCall, Tags::TagClass, Tags::TagClosebrace, Tags::TagDate, Tags::TagDouble, Tags::TagEmpty, Tags::TagEnd, Tags::TagError, Tags::TagFalse, Tags::TagFunctions, Tags::TagGuid, Tags::TagInfinity, Tags::TagInteger, Tags::TagList, Tags::TagLong, Tags::TagMap, Tags::TagNaN, Tags::TagNeg, Tags::TagNine, Tags::TagNull, Tags::TagObject, Tags::TagOpenbrace, Tags::TagPoint, Tags::TagPos, Tags::TagQuote, Tags::TagRef, Tags::TagResult, Tags::TagSemicolon, Tags::TagString, Tags::TagTime, Tags::TagTrue, Tags::TagUTC, Tags::TagUTF8Char, Tags::TagZero

Instance Attribute Summary collapse

Attributes inherited from Client

#simple, #uri

Instance Method Summary collapse

Methods inherited from Client

#[], __new__, #add_filter, #filter, #filter=, inherited, #invoke, new, #onerror, #onerror=, #remove_filter, #use_service

Constructor Details

#initialize(uri = nil) ⇒ HttpClient

Returns a new instance of HttpClient.



30
31
32
33
34
35
36
37
38
# File 'lib/hprose/httpclient.rb', line 30

def initialize(uri = nil)
  super
  Net::HTTP.version_1_2
  @http = Net::HTTP
  @header = {}
  @timeout = 30
  @keepalive = true
  @keepalive_timeout = 300
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Hprose::Client

Instance Attribute Details

#headerObject (readonly)

Returns the value of attribute header.



39
40
41
# File 'lib/hprose/httpclient.rb', line 39

def header
  @header
end

#keepaliveObject

Returns the value of attribute keepalive.



40
41
42
# File 'lib/hprose/httpclient.rb', line 40

def keepalive
  @keepalive
end

#keepalive_timeoutObject

Returns the value of attribute keepalive_timeout.



40
41
42
# File 'lib/hprose/httpclient.rb', line 40

def keepalive_timeout
  @keepalive_timeout
end

#timeoutObject

Returns the value of attribute timeout.



40
41
42
# File 'lib/hprose/httpclient.rb', line 40

def timeout
  @timeout
end

Instance Method Details

#proxy=(proxy) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/hprose/httpclient.rb', line 41

def proxy=(proxy)
  @http = case proxy
  when Net::HTTP then
    proxy
  when String then
    uri = URI.parse(proxy)
    Net::HTTP::Proxy(uri.host, uri.port, uri.user, uri.password)
  else
    proxy.superclass == Net::HTTP ? proxy : Net::HTTP
  end
end