Software /
code /
prosody
Changeset
4866:d54999db3aa1
net.http.parser: Do full URL decoding and parsing (e.g. adds request.url.query when present)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 12 May 2012 03:09:52 +0100 |
parents | 4865:9171dc2357e0 |
children | 4867:b4219d987d05 |
files | net/http/parser.lua |
diffstat | 1 files changed, 7 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/net/http/parser.lua Sat May 12 02:50:38 2012 +0100 +++ b/net/http/parser.lua Sat May 12 03:09:52 2012 +0100 @@ -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 @@ 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;