diff options
author | Emil Renner Berthing <esmil@mailme.dk> | 2013-01-24 11:26:09 +0100 |
---|---|---|
committer | Emil Renner Berthing <esmil@mailme.dk> | 2013-01-24 22:03:28 +0100 |
commit | bdb085de82231eb709058ffa78fbac6ff2df8c38 (patch) | |
tree | 903de6d619ec91d01a377f82c54a9c097420b6a2 /lem/http.lua | |
parent | 4c264373c100af4cf9f3c350ad923d47135bb5c5 (diff) | |
download | lem-bdb085de82231eb709058ffa78fbac6ff2df8c38.tar.gz lem-bdb085de82231eb709058ffa78fbac6ff2df8c38.tar.xz lem-bdb085de82231eb709058ffa78fbac6ff2df8c38.zip |
http: header names are case-insensitive
..so make the parser lower-case header names
Diffstat (limited to 'lem/http.lua')
-rw-r--r-- | lem/http.lua | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lem/http.lua b/lem/http.lua index 8635bf9..dcdbd56 100644 --- a/lem/http.lua +++ b/lem/http.lua @@ -1,6 +1,6 @@ -- -- This file is part of LEM, a Lua Event Machine. --- Copyright 2011-2012 Emil Renner Berthing +-- Copyright 2011-2013 Emil Renner Berthing -- -- LEM is free software: you can redistribute it and/or modify it -- under the terms of the GNU Lesser General Public License as @@ -32,13 +32,13 @@ local tonumber = tonumber local concat = table.concat function http.Request:body() - local len, body = self.headers['Content-Length'], '' + local len, body = self.headers['content-length'], '' if not len then return body end len = tonumber(len) if len <= 0 then return body end - if self.headers['Expect'] == '100-continue' then + if self.headers['expect'] == '100-continue' then local ok, err = self.client:send('HTTP/1.1 100 Continue\r\n\r\n') if not ok then return nil, err end end @@ -75,17 +75,17 @@ function http.Response:body_chunked() line, err = client:read('*l') if not line then return nil, err end - return t + return concat(t) end function http.Response:body() - if self.headers['Transfer-Encoding'] == 'chunked' then - return concat(self:body_chunked()) + if self.headers['transfer-encoding'] == 'chunked' then + return self:body_chunked() end - local num = self.headers['Content-Length'] + local num = self.headers['content-length'] if not num then - if self.headers['Connection'] == 'close' then + if self.headers['connection'] == 'close' then return self.client:read('*a') end return nil, 'no content length specified' |