Ticket #153: cookie_expires.patch

File cookie_expires.patch, 1.6 kB (added by gunark, 5 months ago)

Patch to allow cookie expiry

  • lib/camping.rb

     
    3333C.qsp(fn,'&;',fh,q)if fn;fh.tempfile.rewind if fh.is_a?H end;when 
    3434"application/x-www-form-urlencoded": q.u(C.qsp(@in.read))end 
    3535@cookies,@input=@k.dup,q.dup end;def service *a;@body=send @method,*a 
    36 headers['Set-Cookie']=cookies.map{|k,v|"#{k}=#{C.escape(v)}; path=#{self/ 
    37 "/"}"if v!=@k[k]}-[nil];self end;def to_s;"Status: #@status#{Z+(headers.inject([ 
     36headers['Set-Cookie']=cookies.map{|k,v|"#{k}=#{C.escape(v[:value] || v)}; path=#{self/ 
     37"/"}; expires=#{v[:expires] && v[:expires].strftime('%a, %d-%b-%Y %H:%M:%S %Z')  
     38|| nil}"if v!=@k[k]}-[nil];self end;def to_s;"Status: #@status#{Z+(headers.inject([ 
    3839]){|a,o|[*o[1]].map{|v|a<<[o[0],v]*": "if v&&v.to_s.any?};a}*Z)+Z+Z}#@body"end 
    3940end;X=module Controllers;@r=[];class<<self;def r;@r end;def R *u;r=@r 
    4041Class.new{meta_def(:urls){u};meta_def(:inherited){|x|r<<x}}end 
  • lib/camping-unabridged.rb

     
    454454    # on before and after overrides with Camping. 
    455455    def service(*a) 
    456456      @body = send(@method, *a) 
    457       headers['Set-Cookie'] = cookies.map { |k,v| "#{k}=#{C.escape(v)}; path=#{self/"/"}" if v != @k[k] } - [nil] 
     457      headers['Set-Cookie'] = cookies.map { |k,v|  
     458        "#{k}=#{C.escape(v[:value] || v)}; path=#{self/"/"}; expires=#{v[:expires] && v[:expires].strftime('%a, %d-%b-%Y %H:%M:%S %Z') || nil}" if v != @k[k]  
     459      } - [nil] 
    458460      self 
    459461    end 
    460462