Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add getter method for the query string (and use it internally)

darcs-hash:20070221222514-ae511-43b5126c066e22bfdfcab100d4953a00dc0c294b.gz
  • Loading branch information...
commit 166ab15f948f542530fcfa198df50482d57dfa49 1 parent 9e45430
@qerub qerub authored
Showing with 7 additions and 6 deletions.
  1. +7 −6 lib/rack/request.rb
View
13 lib/rack/request.rb
@@ -15,6 +15,7 @@ def path_info; @env["PATH_INFO"].to_s end
def host; @env["HTTP_HOST"] || @env["SERVER_NAME"] end
def port; @env["SERVER_PORT"].to_i end
def request_method; @env["REQUEST_METHOD"] end
+ def query_string; @env["QUERY_STRING"].to_s end
def script_name=(s); @env["SCRIPT_NAME"] = s.to_s end
def path_info=(s); @env["PATH_INFO"] = s.to_s end
@@ -25,12 +26,12 @@ def put?; request_method == "PUT" end
def delete?; request_method == "DELETE" end
def GET
- if @env["rack.request.query_string"] == @env["QUERY_STRING"]
+ if @env["rack.request.query_string"] == query_string
@env["rack.request.query_hash"]
else
- @env["rack.request.query_string"] = @env["QUERY_STRING"]
- @env["rack.request.query_hash"] =
- Utils.parse_query(@env["QUERY_STRING"])
+ @env["rack.request.query_string"] = query_string
+ @env["rack.request.query_hash"] =
+ Utils.parse_query(query_string)
end
end
@@ -78,8 +79,8 @@ def url
url << script_name
url << path_info
- if @env["QUERY_STRING"] && !@env["QUERY_STRING"].empty?
- url << "?" << @env["QUERY_STRING"]
+ unless query_string.empty?
+ url << "?" << query_string
end
url
Please sign in to comment.
Something went wrong with that request. Please try again.