aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2012-05-12 03:09:52 +0100
committerMatthew Wild <mwild1@gmail.com>2012-05-12 03:09:52 +0100
commit6206f46784e88e648029af68e2dd496ce7715c98 (patch)
tree1ec448572fa5e6121b1e08df5b2c47eea6b7ac35
parentebdfc8c271a48583994334b5e907546d87460f70 (diff)
downloadprosody-6206f46784e88e648029af68e2dd496ce7715c98.tar.gz
prosody-6206f46784e88e648029af68e2dd496ce7715c98.zip
net.http.parser: Do full URL decoding and parsing (e.g. adds request.url.query when present)
-rw-r--r--net/http/parser.lua12
1 files changed, 7 insertions, 5 deletions
diff --git a/net/http/parser.lua b/net/http/parser.lua
index 3d9d1a87..d3f0dc03 100644
--- a/net/http/parser.lua
+++ b/net/http/parser.lua
@@ -1,8 +1,11 @@
local tonumber = tonumber;
local assert = assert;
+local url_parse = require "socket.url".parse;
+local urldecode = require "net.http".urldecode;
local function preprocess_path(path)
+ path = urldecode(path);
if path:sub(1,1) ~= "/" then
path = "/"..path;
end
@@ -88,15 +91,14 @@ function httpstream.new(success_cb, error_cb, parser_type, options_cb)
responseheaders = headers;
};
else
- -- path normalization
- if path:match("^https?://") then
- headers.host, path = path:match("^https?://([^/]*)(.*)");
- end
- path = preprocess_path(path);
+ local parsed_url = url_parse(path);
+ path = preprocess_path(parsed_url.path);
+ headers.host = parsed_url.host;
len = len or 0;
packet = {
method = method;
+ url = parsed_url;
path = path;
httpversion = httpversion;
headers = headers;