Changeset 1822
- Timestamp:
- 05/31/07 22:38:50 (2 years ago)
- Files:
-
- trunk/lib/soap/mapping/mapping.rb (modified) (2 diffs)
- trunk/lib/soap/rpc/cgistub.rb (modified) (3 diffs)
- trunk/lib/soap/rpc/soaplet.rb (modified) (4 diffs)
- trunk/lib/soap/streamHandler.rb (modified) (1 diff)
- trunk/sample/cookies (added)
- trunk/sample/cookies/calc.rb (added)
- trunk/sample/cookies/client.rb (added)
- trunk/sample/cookies/server.rb (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/soap/mapping/mapping.rb
r1810 r1822 506 506 507 507 class << Mapping 508 public 509 510 def protect_threadvars(*symbols) 511 backup = {} 512 begin 513 symbols.each do |sym| 514 backup[sym] = Thread.current[sym] 515 end 516 yield 517 ensure 518 symbols.each do |sym| 519 Thread.current[sym] = backup[sym] 520 end 521 end 522 end 523 508 524 private 509 525 … … 524 540 end 525 541 526 def protect_threadvars(*symbols)527 backup = {}528 begin529 symbols.each do |sym|530 backup[sym] = Thread.current[sym]531 end532 yield533 ensure534 symbols.each do |sym|535 Thread.current[sym] = backup[sym]536 end537 end538 end539 540 542 def add_md_ary(md_ary, ary, indices, registry) 541 543 for idx in 0..(ary.size - 1) trunk/lib/soap/rpc/cgistub.rb
r1731 r1822 35 35 36 36 def meta_vars; end 37 38 def cookies; end 37 39 end 38 40 … … 54 56 } 55 57 end 58 59 def cookies 60 if cookie = ENV['HTTP_Cookie'] || ENV['Cookie'] 61 [WEBrick::Cookie.parse(cookie)] 62 end 63 end 56 64 end 57 65 … … 72 80 'HTTP_SOAPACTION' => @request.env['HTTP_SOAPAction'] 73 81 } 82 end 83 84 def cookies 85 if cookie = @request.env['HTTP_Cookie'] || @request.env['Cookie'] 86 [WEBrick::Cookie.parse(cookie)] 87 end 74 88 end 75 89 end trunk/lib/soap/rpc/soaplet.rb
r1817 r1822 86 86 setup_req(conn_data, req) 87 87 @router.external_ces = @options[:external_ces] 88 conn_data = @router.route(conn_data) 89 setup_res(conn_data, req, res) 88 Mapping.protect_threadvars(:SOAPlet) do 89 SOAPlet.cookies = req.cookies 90 conn_data = @router.route(conn_data) 91 setup_res(conn_data, req, res) 92 end 90 93 rescue Exception => e 91 94 conn_data = @router.create_fault_response(e) … … 100 103 logger.debug { "SOAP response: " + res.body } if logger 101 104 end 105 end 106 107 def self.cookies 108 if var = Thread.current[:SOAPlet] 109 var[:Cookies] 110 else 111 nil 112 end 113 end 114 115 def self.cookies=(cookies) 116 var = Thread.current[:SOAPlet] = {} 117 var[:Cookies] = cookies 102 118 end 103 119 … … 115 131 116 132 def setup_res(conn_data, req, res) 133 res['content-type'] = conn_data.send_contenttype 134 if cookies = SOAPlet.cookies 135 res['set-cookie'] = cookies.to_s 136 end 117 137 if conn_data.is_nocontent 118 138 res.status = WEBrick::HTTPStatus::RC_ACCEPTED … … 120 140 return 121 141 end 122 res['content-type'] = conn_data.send_contenttype123 142 if conn_data.is_fault 124 143 res.status = WEBrick::HTTPStatus::RC_INTERNAL_SERVER_ERROR trunk/lib/soap/streamHandler.rb
r1817 r1822 137 137 def send(endpoint_url, conn_data, soapaction = nil, charset = @charset) 138 138 conn_data.soapaction ||= soapaction # for backward conpatibility 139 send_post(endpoint_url, conn_data, charset) 139 conn_data = send_post(endpoint_url, conn_data, charset) 140 @client.save_cookie_store if @cookie_store 141 conn_data 140 142 end 141 143