diff --git a/lib/camping-unabridged.rb b/lib/camping-unabridged.rb index e6826e6..c18c371 100644 --- a/lib/camping-unabridged.rb +++ b/lib/camping-unabridged.rb @@ -427,7 +427,9 @@ def service(*a) # Used by the web server to convert the current request to a string. If you need to # alter the way Camping builds HTTP headers, consider overriding this method. def to_s - "Status: #{@status}#{Z+@headers.map{|k,v|[*v].map{|x|"#{k}: #{x}"}}*Z+Z*2+@body}" + a=[] + @headers.map{|k,v|[*v].map{|x|a<<"#{k}: #{x}"}} + "Status: #{@status}#{Z+a*Z+Z*2+@body}" end end @@ -661,7 +663,7 @@ def run(r=$stdin,e=ENV) X.M k,a=X.D un("/#{e['PATH_INFO']}".gsub(/\/+/,'/')) k.new(r,e,(m=e['REQUEST_METHOD']||"GET")).Y.service *a - rescue=>x + rescue Object=>x X::ServerError.new(r,e,'get').service(k,m,x) end diff --git a/lib/camping.rb b/lib/camping.rb index 23df4bd..4ca4347 100644 --- a/lib/camping.rb +++ b/lib/camping.rb @@ -41,7 +41,7 @@ def initialize r,e,m;e=H[e.to_hash];@status,@method,@env,@headers,@root=200,m. split('=',2);h.u k.split(/[\]\[]+/).reverse.inject(y||v){|x,i|H[i,x]},&m}end;def kp s;c=qsp(s,';,')end;def run r=$stdin,e=ENV;X.M;k,a=X.D un("/#{e[ 'PATH_INFO']}".gsub(/\/+/,'/'));k.new(r,e,(m=e['REQUEST_METHOD']||"GET")).Y. -service *a;rescue=>x;X::ServerError.new(r,e,'get').service(k,m,x)end +service *a;rescue Object=>x;X::ServerError.new(r,e,'get').service(k,m,x)end def method_missing m,c,*a;X.M;k=X.const_get(c).new(StringIO.new,H['HTTP_HOST', '','SCRIPT_NAME','','HTTP_COOKIE',''],m.to_s);H.new(a.pop).each{|e,f|k.send( "#{e}=",f)}if Hash===a[-1];k.service *a;end;end;module Views;include X,Helpers