lib/nyara/request.rb in nyara-0.0.1.pre.8 vs lib/nyara/request.rb in nyara-0.0.1.pre.9

- old
+ new

@@ -1,9 +1,9 @@ # coding: binary module Nyara - # request and handler + # Request and handler class Request # c-ext: http_method, scope, path, query, path_with_query format, accept, header # cookie, session, flash # status, response_content_type, response_header, response_header_extra_lines # todo: body, move all underline methods into Ext @@ -109,24 +109,41 @@ multipart/form-data ] def form? if type = header['Content-Type'] + type = type[/[^;\s]+/] FORM_METHODS.include?(http_method) and FORM_MEDIA_TYPES.include?(type) else post? end end def param @param ||= begin - q = query.dup + q = query ? query.dup : ParamHash.new if form? - # todo read body, change encoding - Ext.parse_param q, body + b = body # read all the message + case b + when String + Ext.parse_param q, body + when Array + b.each do |part| + part.merge_into q + end + else + # nil + end end q end + end + + def inspect + "#<Nyara::Request%s>" % + instance_variables.map { |iv| + " #{iv}=#{instance_variable_get(iv).to_s}" + }.join end end end