aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/http.lua20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/http.lua b/src/http.lua
index a386165..6b26a0a 100644
--- a/src/http.lua
+++ b/src/http.lua
@@ -27,9 +27,13 @@ _M.TIMEOUT = 60
27_M.USERAGENT = socket._VERSION 27_M.USERAGENT = socket._VERSION
28 28
29-- supported schemes 29-- supported schemes
30local SCHEMES = { ["http"] = true } 30local SCHEMES = {
31-- default port for document retrieval 31 http = { port = 80 }
32local PORT = 80 32 , https = { port = 443 }}
33
34-- default scheme and port for document retrieval
35local SCHEME = 'http'
36local PORT = SCHEMES[SCHEME].port
33 37
34----------------------------------------------------------------------------- 38-----------------------------------------------------------------------------
35-- Reads MIME headers from a connection, unfolding where needed 39-- Reads MIME headers from a connection, unfolding where needed
@@ -212,10 +216,14 @@ end
212 216
213local function adjustheaders(reqt) 217local function adjustheaders(reqt)
214 -- default headers 218 -- default headers
215 local host = string.gsub(reqt.authority, "^.-@", "") 219 local headhost = reqt.host
220 local headport = tostring(reqt.port)
221 local schemeport = tostring(SCHEMES[reqt.scheme].port)
222 if headport ~= schemeport then
223 headhost = headhost .. ':' .. headport end
216 local lower = { 224 local lower = {
217 ["user-agent"] = _M.USERAGENT, 225 ["user-agent"] = _M.USERAGENT,
218 ["host"] = host, 226 ["host"] = headhost,
219 ["connection"] = "close, TE", 227 ["connection"] = "close, TE",
220 ["te"] = "trailers" 228 ["te"] = "trailers"
221 } 229 }
@@ -246,7 +254,7 @@ local default = {
246 host = "", 254 host = "",
247 port = PORT, 255 port = PORT,
248 path ="/", 256 path ="/",
249 scheme = "http" 257 scheme = SCHEME
250} 258}
251 259
252local function adjustrequest(reqt) 260local function adjustrequest(reqt)