-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* lib/camping.rb: efficient multipart forms, at last.
* lib/camping-unabridged.rb: ditto. * camping.gemspec: moved to Rakefile.
- Loading branch information
_why
committed
May 6, 2006
1 parent
f808b4f
commit 4bf0b27
Showing
3 changed files
with
35 additions
and
52 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,12 +13,13 @@ module Base;include Helpers;attr_accessor :input,:cookies,:env,:headers,:body, | |
@status,@method,@env,@headers,@root=200,m.downcase,e,{'Content-Type'=>"text/htm\ | ||
l"},e.SCRIPT_NAME.sub(/\/$/,'');@k=C.kp e.HTTP_COOKIE;q=C.qs_parse e.QUERY_STRING | ||
@in=r;if %r|\Amultipart/form-.*boundary=\"?([^\";,]+)|n.match e.CONTENT_TYPE;b= | ||
"--#$1";@in.read.split(/(?:\r?\n|\A)#{Regexp.quote b}(?:--)?\r\n/m).map{|y|h,v=y. | ||
split "\r\n\r\n",2;fh={};[:name,:filename].map{|x|fh[x]=$1 if h=~/^Content-Di.+\ | ||
: form-data;.*(?:\s#{x}="([^"]+)")/m};fn=fh[:name];if fh[:filename];fh[:type]= | ||
$1 if h=~/^Content-Type: (.+?)(\r\n|\Z)/m;fh[:tempfile]=Tempfile.new(:C). | ||
instance_eval{binmode;write v;rewind;self}else;fh=v end;q[fn]=fh if fn}elsif | ||
@method=="post";q.u C.qs_parse(@in.read) end;@cookies,@input= | ||
/(?:\r?\n|\A)#{Regexp::quote("--#$1")}(?:--)?\r$/;until @in.eof?;fh=H[];for l in | ||
@in;case l;when "\r\n":break;when /^Content-Disposition: form-data;/:fh.u H[*$'. | ||
scan(/(?:\s(\w+)="([^"]+)")/).flatten];when /^Content-Type: (.+?)(\r$|\Z)/m;fh[ | ||
:type]=$1;end;end;fn=fh[:name];o=if fh[:filename];fh[:tempfile]=Tempfile.new(:C). | ||
binmode;else;fh="";end;while l=@in.read(16384);if l=~b;o<<$`.chomp;@in.seek(-$'. | ||
size,IO::SEEK_CUR);break;end;o<<l;end;q[fn]=fh if fn;fh[:tempfile].rewind if | ||
fh.is_a?H;end;elsif @method=="post";q.u C.qs_parse(@in.read) end;@cookies,@input= | ||
@k.dup,q.dup end;def service *a;@body=send(@method,*a)if respond_to?@method | ||
@headers["Set-Cookie"][email protected]{|k,v|"#{k}=#{C.escape(v)}; path=#{self/"/"}\ | ||
" if v != @k[k]}.compact;self end;def to_s;"Status: #{@status}\n#{@headers.map{ | ||
|