Class: WirisPlugin::HttpImpl
- Inherits:
-
Http
- Object
- Http
- WirisPlugin::HttpImpl
- Includes:
- Wiris
- Defined in:
- lib/com/wiris/plugin/impl/HttpImpl.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#listener ⇒ Object
Returns the value of attribute listener.
Instance Method Summary collapse
- #getData ⇒ Object
- #getProxy ⇒ Object
-
#initialize(url, listener) ⇒ HttpImpl
constructor
A new instance of HttpImpl.
- #onData(data) ⇒ Object
- #onError(msg) ⇒ Object
- #request(post) ⇒ Object
- #setListener(listener) ⇒ Object
- #setProxy(proxy) ⇒ Object
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
#data ⇒ Object
Returns the value of attribute data.
6 7 8 |
# File 'lib/com/wiris/plugin/impl/HttpImpl.rb', line 6 def data @data end |
#listener ⇒ Object
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
#getData ⇒ Object
36 37 38 |
# File 'lib/com/wiris/plugin/impl/HttpImpl.rb', line 36 def getData() return @data end |
#getProxy ⇒ Object
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 |