Changeset 1868
- Timestamp:
- 06/30/07 12:39:06 (1 year ago)
- Files:
-
- trunk/lib/soap/filter.rb (modified) (2 diffs)
- trunk/lib/soap/filter/filterchain.rb (modified) (1 diff)
- trunk/lib/soap/filter/streamhandler.rb (added)
- trunk/lib/soap/netHttpClient.rb (modified) (2 diffs)
- trunk/lib/soap/streamHandler.rb (modified) (12 diffs)
- trunk/sample/payload/cookies/filterclient.rb (added)
- trunk/test/soap/test_cookie.rb (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/soap/filter.rb
r1831 r1868 1 # SOAP4R - SOAP envelopefilter.1 # SOAP4R - SOAP filter. 2 2 # Copyright (C) 2000-2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>. 3 3 … … 8 8 9 9 require 'soap/filter/filterchain' 10 # envelope filter 10 11 require 'soap/filter/handler' 12 # steram filter 13 require 'soap/filter/streamhandler' trunk/lib/soap/filter/filterchain.rb
r1831 r1868 1 # SOAP4R - SOAP envelope filter handler.1 # SOAP4R - SOAP filter chain. 2 2 # Copyright (C) 2000-2007 NAKAMURA, Hiroshi <nahi@ruby-lang.org>. 3 3 trunk/lib/soap/netHttpClient.rb
r1824 r1868 31 31 attr_accessor :receive_timeout 32 32 attr_reader :test_loopback_response 33 attr_reader :request_filter # ignored for now. 33 34 34 35 def initialize(proxy = nil, agent = nil) … … 37 38 @debug_dev = nil 38 39 @test_loopback_response = [] 40 @request_filter = Filter::FilterChain.new 39 41 @session_manager = SessionManager.new 40 42 @no_proxy = @ssl_config = @protocol_version = nil trunk/lib/soap/streamHandler.rb
r1824 r1868 9 9 require 'soap/soap' 10 10 require 'soap/httpconfigloader' 11 require 'soap/filter/filterchain' 11 12 begin 12 13 require 'stringio' … … 22 23 class StreamHandler 23 24 RUBY_VERSION_STRING = "ruby #{ RUBY_VERSION } (#{ RUBY_RELEASE_DATE }) [#{ RUBY_PLATFORM }]" 25 26 attr_reader :filterchain 24 27 25 28 class ConnectionData … … 43 46 end 44 47 48 def initialize 49 @filterchain = Filter::FilterChain.new 50 end 51 45 52 def self.parse_media_type(str) 46 53 if /^#{ MediaType }(?:\s*;\s*charset=([^"]+|"[^"]+"))?$/i !~ str … … 56 63 end 57 64 58 def send( endpoint_url, conn_data, soapaction = nil, charset = nil)59 # send a ConnectionData to specified endpoint_url.65 def send(url, conn_data, soapaction = nil, charset = nil) 66 # send a ConnectionData to specified url. 60 67 # return value is a ConnectionData with receive_* property filled. 61 68 # You can fill values of given conn_data and return it. 62 69 end 63 70 64 def reset( endpoint_url = nil)71 def reset(url = nil) 65 72 # for initializing connection status if needed. 66 73 # return value is not expected. … … 99 106 end 100 107 108 class HttpPostRequestFilter 109 def initialize(filterchain) 110 @filterchain = filterchain 111 end 112 113 def filter_request(req) 114 @filterchain.each do |filter| 115 filter.on_httppost_outbound(req) 116 end 117 end 118 119 def filter_response(req, res) 120 @filterchain.each do |filter| 121 filter.on_httppost_inbound(req, res) 122 end 123 end 124 end 101 125 102 126 public … … 114 138 super() 115 139 @client = Client.new(nil, "SOAP4R/#{ Version }") 140 @client.request_filter << HttpPostRequestFilter.new(@filterchain) 116 141 @wiredump_file_base = nil 117 142 @charset = @wiredump_dev = nil … … 135 160 end 136 161 137 def send( endpoint_url, conn_data, soapaction = nil, charset = @charset)162 def send(url, conn_data, soapaction = nil, charset = @charset) 138 163 conn_data.soapaction ||= soapaction # for backward conpatibility 139 conn_data = send_post( endpoint_url, conn_data, charset)164 conn_data = send_post(url, conn_data, charset) 140 165 @client.save_cookie_store if @cookie_store 141 166 conn_data 142 167 end 143 168 144 def reset( endpoint_url = nil)145 if endpoint_url.nil?169 def reset(url = nil) 170 if url.nil? 146 171 @client.reset_all 147 172 else 148 @client.reset( endpoint_url)173 @client.reset(url) 149 174 end 150 175 @client.save_cookie_store if @cookie_store … … 182 207 end 183 208 184 def send_post( endpoint_url, conn_data, charset)209 def send_post(url, conn_data, charset) 185 210 conn_data.send_contenttype ||= StreamHandler.create_media_type(charset) 186 211 … … 192 217 end 193 218 194 ext ra= {}195 ext ra['Content-Type'] = conn_data.send_contenttype196 ext ra['SOAPAction'] = "\"#{ conn_data.soapaction }\""197 ext ra['Accept-Encoding'] = 'gzip' if send_accept_encoding_gzip?219 extheader = {} 220 extheader['Content-Type'] = conn_data.send_contenttype 221 extheader['SOAPAction'] = "\"#{ conn_data.soapaction }\"" 222 extheader['Accept-Encoding'] = 'gzip' if send_accept_encoding_gzip? 198 223 send_string = conn_data.send_string 199 224 @wiredump_dev << "Wire dump:\n\n" if @wiredump_dev … … 201 226 retry_count = 0 202 227 while true 203 res = @client.post( endpoint_url, send_string, extra)228 res = @client.post(url, send_string, extheader) 204 229 if RETRYABLE and HTTP::Status.redirect?(res.status) 205 230 retry_count += 1 … … 207 232 raise HTTPStreamError.new("redirect count exceeded") 208 233 end 209 endpoint_url = res.header["location"][0]210 puts "redirected to #{ endpoint_url}" if $DEBUG234 url = res.header["location"][0] 235 puts "redirected to #{url}" if $DEBUG 211 236 else 212 237 break … … 214 239 end 215 240 rescue 216 @client.reset( endpoint_url)241 @client.reset(url) 217 242 raise 218 243 end