Mercurial > prosody-hg
comparison util/httpstream.lua @ 3920:215c0ec63816
util.httpstream: A little cleanup of the HTTP path.
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Sun, 19 Dec 2010 20:27:13 +0500 |
| parents | 6ef68af9431c |
| children | 5924197aa163 |
comparison
equal
deleted
inserted
replaced
| 3900:e1f19f437ddd | 3920:215c0ec63816 |
|---|---|
| 44 while true do | 44 while true do |
| 45 -- read status line | 45 -- read status line |
| 46 local status_line = readline(); | 46 local status_line = readline(); |
| 47 local method, path, httpversion = status_line:match("^(%S+)%s+(%S+)%s+HTTP/(%S+)$"); | 47 local method, path, httpversion = status_line:match("^(%S+)%s+(%S+)%s+HTTP/(%S+)$"); |
| 48 if not method then coroutine.yield("invalid-status-line"); end | 48 if not method then coroutine.yield("invalid-status-line"); end |
| 49 -- TODO parse url | 49 path = path:gsub("^//+", "/"); -- TODO parse url more |
| 50 local headers = readheaders(); | 50 local headers = readheaders(); |
| 51 | 51 |
| 52 -- read body | 52 -- read body |
| 53 local len = tonumber(headers["content-length"]); | 53 local len = tonumber(headers["content-length"]); |
| 54 len = len or 0; -- TODO check for invalid len | 54 len = len or 0; -- TODO check for invalid len |
