Changeset 233
- Timestamp:
- 09/30/2007 15:46:06 (14 months ago)
- Location:
- trunk/lib
- Files:
-
- 2 modified
-
camping-unabridged.rb (modified) (2 diffs)
-
camping.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/camping-unabridged.rb
r231 r233 359 359 q = C.qsp(e.QUERY_STRING) 360 360 @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 362 363 b = /(?:\r?\n|\A)#{Regexp::quote("--#$1")}(?:--)?\r$/ 363 364 until @in.eof? … … 394 395 fh[:tempfile].rewind if fh.is_a?H 395 396 end 396 elsif @method == "post" and e.CONTENT_TYPE =="application/x-www-form-urlencoded"397 when "application/x-www-form-urlencoded" 397 398 q.u(C.qsp(@in.read)) 398 399 end -
trunk/lib/camping.rb
r231 r233 12 12 send(:layout){s}}if /^_/!~a[0].to_s and m.respond_to?:layout;s end;def 13 13 redirect*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,{ 14 merge!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,{ 15 16 '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 17 q=C.qsp e.QUERY_STRING;@in=r 18 case e.CONTENT_TYPE when %r|\Amultipart/form-.*boundary=\"?([^\";,]+)|n 19 b=/(?:\r?\n|\A)#{Regexp::quote"--#$1"}(?:--)?\r$/;until 18 20 @in.eof?;fh=H[];for l in@in;case l;when Z;break;when/^Content-D.+?: form-data;/ 19 21 fh.u H[*$'.scan(/(?:\s(\w+)="([^"]+)")/).flatten];when … … 22 24 l=@in.read(s*2);while l;if(k<<l)=~b;o<<$`.chomp;@in.seek(-$'.size,IO::SEEK_CUR) 23 25 break;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 d up,q.dup end;def service*a;@body=send(@method,*a)if respond_to?@method26 :tempfile].rewind if fh.is_a?H;end;when "application/x-www-form-urlencoded" 27 q.u C.qsp(@in.read)end;@cookies,@input=@k.dup,q.dup end 28 def service*a;@body=send(@method,*a)if respond_to?@method 27 29 headers["Set-Cookie"]=cookies.map{|k,v|"#{k}=#{C.escape v}; path=#{self/'/'}"if 28 30 v!=@k[k]}-[nil];self end;def to_s;"Status: #@status#{Z+headers.map{|k,v|[*v].
