Changeset 233

Show
Ignore:
Timestamp:
09/30/2007 15:46:06 (14 months ago)
Author:
zimbatm
Message:

Removed post method check on application/x-www-form-urlencoded entities, following
some discussion on the mailing-list.

Location:
trunk/lib
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/lib/camping-unabridged.rb

    r231 r233  
    359359      q = C.qsp(e.QUERY_STRING) 
    360360      @in = r 
    361       if %r|\Amultipart/form-.*boundary=\"?([^\";,]+)|n.match(e.CONTENT_TYPE) 
     361      case e.CONTENT_TYPE 
     362      when %r|\Amultipart/form-.*boundary=\"?([^\";,]+)|n 
    362363        b = /(?:\r?\n|\A)#{Regexp::quote("--#$1")}(?:--)?\r$/ 
    363364        until @in.eof? 
     
    394395          fh[:tempfile].rewind if fh.is_a?H 
    395396        end 
    396       elsif @method == "post" and e.CONTENT_TYPE == "application/x-www-form-urlencoded" 
     397      when "application/x-www-form-urlencoded" 
    397398        q.u(C.qsp(@in.read)) 
    398399      end 
  • trunk/lib/camping.rb

    r231 r233  
    1212send(:layout){s}}if /^_/!~a[0].to_s and m.respond_to?:layout;s end;def 
    1313redirect*a;r 302,'','Location'=>URL(*a)end;def r s,b,h={};@status=s;headers. 
    14 merge!h;@body=b end;def to_a;[status,body,headers]end;def initialize r,e,m;@status,@method,@env,@headers,@root=200,m.downcase,e,{ 
     14merge!h;@body=b end;def to_a;[status,body,headers]end;def initialize r,e,m; 
     15@status,@method,@env,@headers,@root=200,m.downcase,e,{ 
    1516'Content-Type'=>"text/html"},e.SCRIPT_NAME.sub(/\/$/,'');@k=C.kp e.HTTP_COOKIE 
    16 q=C.qsp e.QUERY_STRING;@in=r;if%r|\Amultipart/form-.*boundary=\"?([^\";,]+)|n. 
    17 match e.CONTENT_TYPE;b=/(?:\r?\n|\A)#{Regexp::quote"--#$1"}(?:--)?\r$/;until 
     17q=C.qsp e.QUERY_STRING;@in=r 
     18case e.CONTENT_TYPE when %r|\Amultipart/form-.*boundary=\"?([^\";,]+)|n 
     19b=/(?:\r?\n|\A)#{Regexp::quote"--#$1"}(?:--)?\r$/;until 
    1820@in.eof?;fh=H[];for l in@in;case l;when Z;break;when/^Content-D.+?: form-data;/ 
    1921fh.u H[*$'.scan(/(?:\s(\w+)="([^"]+)")/).flatten];when 
     
    2224l=@in.read(s*2);while l;if(k<<l)=~b;o<<$`.chomp;@in.seek(-$'.size,IO::SEEK_CUR) 
    2325break;end;o<<k.slice!(0...s);l=@in.read(s);end;C.qsp(fn,'&;',fh,q)if fn;fh[ 
    24 :tempfile].rewind if fh.is_a?H;end;elsif@method=="post" && e.CONTENT_TYPE== 
    25 "application/x-www-form-urlencoded";q.u C.qsp(@in.read)end;@cookies,@input=@k. 
    26 dup,q.dup end;def service*a;@body=send(@method,*a)if respond_to?@method 
     26:tempfile].rewind if fh.is_a?H;end;when "application/x-www-form-urlencoded" 
     27q.u C.qsp(@in.read)end;@cookies,@input=@k.dup,q.dup end 
     28def service*a;@body=send(@method,*a)if respond_to?@method 
    2729headers["Set-Cookie"]=cookies.map{|k,v|"#{k}=#{C.escape v}; path=#{self/'/'}"if 
    2830v!=@k[k]}-[nil];self end;def to_s;"Status: #@status#{Z+headers.map{|k,v|[*v].