aboutsummaryrefslogtreecommitdiff
path: root/src/http.lua
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2004-05-28 06:16:43 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2004-05-28 06:16:43 +0000
commit694edcc3c1ac3041ff8cdd753a2f7894e8783e6c (patch)
treef8797b4c7671fbf9042fc011277d69d4c3549045 /src/http.lua
parentbf738a03368b8de9c574d9631f131c5a520acf7b (diff)
downloadluasocket-694edcc3c1ac3041ff8cdd753a2f7894e8783e6c.tar.gz
luasocket-694edcc3c1ac3041ff8cdd753a2f7894e8783e6c.tar.bz2
luasocket-694edcc3c1ac3041ff8cdd753a2f7894e8783e6c.zip
Committing with require.
Diffstat (limited to 'src/http.lua')
-rw-r--r--src/http.lua10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/http.lua b/src/http.lua
index f787b9d..e6a0928 100644
--- a/src/http.lua
+++ b/src/http.lua
@@ -10,6 +10,12 @@ if not LUASOCKET_LIBNAME then error('module requires LuaSocket') end
10-- get LuaSocket namespace 10-- get LuaSocket namespace
11local socket = _G[LUASOCKET_LIBNAME] 11local socket = _G[LUASOCKET_LIBNAME]
12if not socket then error('module requires LuaSocket') end 12if not socket then error('module requires LuaSocket') end
13
14-- require other modules
15require("ltn12")
16require("mime")
17require("url")
18
13-- create namespace inside LuaSocket namespace 19-- create namespace inside LuaSocket namespace
14socket.http = socket.http or {} 20socket.http = socket.http or {}
15-- make all module globals fall into namespace 21-- make all module globals fall into namespace
@@ -41,7 +47,7 @@ end
41 47
42local function receive_headers(reqt, respt, tmp) 48local function receive_headers(reqt, respt, tmp)
43 local sock = tmp.sock 49 local sock = tmp.sock
44 local line, name, value, _ 50 local line, name, value
45 local headers = {} 51 local headers = {}
46 -- store results 52 -- store results
47 respt.headers = headers 53 respt.headers = headers
@@ -50,7 +56,7 @@ local function receive_headers(reqt, respt, tmp)
50 -- headers go until a blank line is found 56 -- headers go until a blank line is found
51 while line ~= "" do 57 while line ~= "" do
52 -- get field-name and value 58 -- get field-name and value
53 _, _, name, value = string.find(line, "^(.-):%s*(.*)") 59 name, value = socket.skip(2, string.find(line, "^(.-):%s*(.*)"))
54 socket.try(name and value, "malformed reponse headers") 60 socket.try(name and value, "malformed reponse headers")
55 name = string.lower(name) 61 name = string.lower(name)
56 -- get next line (value might be folded) 62 -- get next line (value might be folded)