Class: Etapper::SessionFilter
- Inherits:
-
SOAP::Filter::StreamHandler
- Object
- SOAP::Filter::StreamHandler
- Etapper::SessionFilter
- Defined in:
- lib/etapper/session_filter.rb
Instance Attribute Summary collapse
-
#cookie_values ⇒ Object
Returns the value of attribute cookie_values.
Instance Method Summary collapse
-
#initialize ⇒ SessionFilter
constructor
A new instance of SessionFilter.
- #on_http_inbound(req, res) ⇒ Object
- #on_http_outbound(req) ⇒ Object
Constructor Details
#initialize ⇒ SessionFilter
Returns a new instance of SessionFilter.
8 9 10 |
# File 'lib/etapper/session_filter.rb', line 8 def initialize @cookie_values = {} end |
Instance Attribute Details
#cookie_values ⇒ Object
Returns the value of attribute cookie_values.
6 7 8 |
# File 'lib/etapper/session_filter.rb', line 6 def @cookie_values end |
Instance Method Details
#on_http_inbound(req, res) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/etapper/session_filter.rb', line 28 def on_http_inbound(req, res) res.header['Set-Cookie'].each do || value = .sub(/;.*/, '') if value =~ /(.*?)\s*=\s*(.*)/ @cookie_values[$1] = $2 end end end |
#on_http_outbound(req) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/etapper/session_filter.rb', line 12 def on_http_outbound(req) if .empty? req.header.delete('Cookie') else req.header['Cookie'] = end # Tweak the XML body to fit eTapestry's quirks and bugs b = HTTP::Message::Body.new c = req.body.content c.gsub!(/>\s*</m,'><') # Remove whitespace between elements c.gsub!(/<(\S+) xsi:nil="true"><\/\1>/,'') # Strip out elements that are simply nil b.init_request(c) req.body = b end |