diff options
author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-06-16 22:51:04 +0000 |
---|---|---|
committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-06-16 22:51:04 +0000 |
commit | 9fc682a106f13901b60a665619fc61d9dae49fb0 (patch) | |
tree | 6efdd73fa4f2abce56b6fb710f7516d0a5c6c758 /src/http.lua | |
parent | 574708380f19b15bd19419bfd64ccbe422f2d924 (diff) | |
download | luasocket-9fc682a106f13901b60a665619fc61d9dae49fb0.tar.gz luasocket-9fc682a106f13901b60a665619fc61d9dae49fb0.tar.bz2 luasocket-9fc682a106f13901b60a665619fc61d9dae49fb0.zip |
HTTP now has only one function.
Diffstat (limited to 'src/http.lua')
-rw-r--r-- | src/http.lua | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/http.lua b/src/http.lua index e0c4c27..b341ebb 100644 --- a/src/http.lua +++ b/src/http.lua | |||
@@ -122,7 +122,7 @@ local function uri(reqt) | |||
122 | local u = reqt | 122 | local u = reqt |
123 | if not reqt.proxy and not PROXY then | 123 | if not reqt.proxy and not PROXY then |
124 | u = { | 124 | u = { |
125 | path = reqt.path, | 125 | path = socket.try(reqt.path, "invalid path 'nil'"), |
126 | params = reqt.params, | 126 | params = reqt.params, |
127 | query = reqt.query, | 127 | query = reqt.query, |
128 | fragment = reqt.fragment | 128 | fragment = reqt.fragment |
@@ -152,18 +152,15 @@ local default = { | |||
152 | 152 | ||
153 | local function adjustrequest(reqt) | 153 | local function adjustrequest(reqt) |
154 | -- parse url if provided | 154 | -- parse url if provided |
155 | if reqt.url then | 155 | local nreqt = reqt.url and url.parse(reqt.url, default) or {} |
156 | local parsed = url.parse(reqt.url, default) | 156 | -- explicit components override url |
157 | -- explicit components override url | 157 | for i,v in reqt do nreqt[i] = reqt[i] end |
158 | for i,v in parsed do reqt[i] = reqt[i] or v end | 158 | socket.try(nreqt.host, "invalid host '" .. tostring(nreqt.host) .. "'") |
159 | end | ||
160 | socket.try(reqt.host, "invalid host '" .. tostring(reqt.host) .. "'") | ||
161 | socket.try(reqt.path, "invalid path '" .. tostring(reqt.path) .. "'") | ||
162 | -- compute uri if user hasn't overriden | 159 | -- compute uri if user hasn't overriden |
163 | reqt.uri = reqt.uri or uri(reqt) | 160 | nreqt.uri = nreqt.uri or uri(nreqt) |
164 | -- adjust headers in request | 161 | -- adjust headers in request |
165 | reqt.headers = adjustheaders(reqt.headers, reqt.host) | 162 | nreqt.headers = adjustheaders(nreqt.headers, nreqt.host) |
166 | return reqt | 163 | return nreqt |
167 | end | 164 | end |
168 | 165 | ||
169 | local function shouldredirect(reqt, code) | 166 | local function shouldredirect(reqt, code) |