Mercurial > prosody-hg
comparison net/http/parser.lua @ 4712:4fc99f1b7570
net.http.parser: Handle full URLs in status line.
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Thu, 26 Apr 2012 20:07:13 +0500 |
| parents | fc5d3b053454 |
| children | 6eeb142a8073 |
comparison
equal
deleted
inserted
replaced
| 4711:4ddf3ba0c749 | 4712:4fc99f1b7570 |
|---|---|
| 51 or (status_code >= 100 and status_code < 200) ); | 51 or (status_code >= 100 and status_code < 200) ); |
| 52 chunked = have_body and headers["transfer-encoding"] == "chunked"; | 52 chunked = have_body and headers["transfer-encoding"] == "chunked"; |
| 53 else | 53 else |
| 54 method, path, httpversion = line:match("^(%w+) (%S+) HTTP/(1%.[01])$"); | 54 method, path, httpversion = line:match("^(%w+) (%S+) HTTP/(1%.[01])$"); |
| 55 if not method then error = true; return error_cb("invalid-status-line"); end | 55 if not method then error = true; return error_cb("invalid-status-line"); end |
| 56 path = path:gsub("^//+", "/"); -- TODO parse url more | |
| 57 end | 56 end |
| 58 end | 57 end |
| 59 end | 58 end |
| 60 len = tonumber(headers["content-length"]); -- TODO check for invalid len | 59 len = tonumber(headers["content-length"]); -- TODO check for invalid len |
| 61 if client then | 60 if client then |
| 69 -- COMPAT the properties below are deprecated | 68 -- COMPAT the properties below are deprecated |
| 70 responseversion = httpversion; | 69 responseversion = httpversion; |
| 71 responseheaders = headers; | 70 responseheaders = headers; |
| 72 }; | 71 }; |
| 73 else | 72 else |
| 73 -- path normalization | |
| 74 if path:match("^https?://") then | |
| 75 headers.host, path = path:match("^https?://([^/]*)(.*)"); | |
| 76 end | |
| 77 path = path:gsub("^//+", "/"); -- TODO parse url more | |
| 78 | |
| 74 len = len or 0; | 79 len = len or 0; |
| 75 packet = { | 80 packet = { |
| 76 method = method; | 81 method = method; |
| 77 path = path; | 82 path = path; |
| 78 httpversion = httpversion; | 83 httpversion = httpversion; |
