# HG changeset patch # User Matthew Wild # Date 1336788592 -3600 # Node ID d54999db3aa19efa2203b94c107393b7c0ee5959 # Parent 9171dc2357e0e0018aaff5b0f4debdd6cb704984 net.http.parser: Do full URL decoding and parsing (e.g. adds request.url.query when present) diff -r 9171dc2357e0 -r d54999db3aa1 net/http/parser.lua --- 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;