Class: WirisPlugin::HttpImpl

Inherits:
Http
  • Object
show all
Includes:
Wiris
Defined in:
lib/com/wiris/plugin/impl/HttpImpl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, listener) ⇒ HttpImpl

Returns a new instance of HttpImpl.



8
9
10
11
# File 'lib/com/wiris/plugin/impl/HttpImpl.rb', line 8

def initialize(url, listener)
    super(url)
    self.listener = listener
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



6
7
8
# File 'lib/com/wiris/plugin/impl/HttpImpl.rb', line 6

def data
  @data
end

#listenerObject

Returns the value of attribute listener.



7
8
9
# File 'lib/com/wiris/plugin/impl/HttpImpl.rb', line 7

def listener
  @listener
end

Instance Method Details

#getDataObject



36
37
38
# File 'lib/com/wiris/plugin/impl/HttpImpl.rb', line 36

def getData()
    return @data
end

#getProxyObject



39
40
41
42
43
44
45
# File 'lib/com/wiris/plugin/impl/HttpImpl.rb', line 39

def getProxy()
    proxy = Reflect::field(Http,"PROXY")
    if proxy == nil
        return nil
    end
    return (proxy)
end

#onData(data) ⇒ Object



23
24
25
26
27
28
# File 'lib/com/wiris/plugin/impl/HttpImpl.rb', line 23

def onData(data)
    self.data = data
    if @listener != nil
        @listener::onData(data)
    end
end

#onError(msg) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/com/wiris/plugin/impl/HttpImpl.rb', line 29

def onError(msg)
    if @listener != nil
        @listener::onError(msg)
    else 
        raise Exception,msg
    end
end

#request(post) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/com/wiris/plugin/impl/HttpImpl.rb', line 12

def request(post)
    proxy = getProxy()
    if ((proxy != nil) && (proxy::host != nil)) && (proxy::host::length() > 0)
        hpa = (proxy::auth)
        if (hpa::user != nil) && (hpa::user::length() > 0)
            data = Base64.new()::encodeBytes(Bytes::ofString((hpa::user.to_s + ":") + hpa::pass.to_s))::toString()
            self.setHeader("Proxy-Authorization","Basic " + data)
        end
    end
    super(post)
end

#setListener(listener) ⇒ Object



49
50
51
# File 'lib/com/wiris/plugin/impl/HttpImpl.rb', line 49

def setListener(listener)
    self.listener = listener
end

#setProxy(proxy) ⇒ Object



46
47
48
# File 'lib/com/wiris/plugin/impl/HttpImpl.rb', line 46

def setProxy(proxy)
    Reflect::setField(Http,"PROXY",proxy)
end