Software /
code /
prosody
Comparison
net/httpserver.lua @ 697:8ddc85fa7602
core.httpserver: Rename request.responseheaders to the more logical request.headers
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 12 Jan 2009 04:02:29 +0000 |
parent | 634:1af93ea23f96 |
child | 958:172fb9a73017 |
comparison
equal
deleted
inserted
replaced
696:b35faad717f2 | 697:8ddc85fa7602 |
---|---|
124 destroy_request(request); | 124 destroy_request(request); |
125 return; | 125 return; |
126 end | 126 end |
127 if request.state == "body" then | 127 if request.state == "body" then |
128 log("debug", "Reading body...") | 128 log("debug", "Reading body...") |
129 if not request.body then request.body = {}; request.havebodylength, request.bodylength = 0, tonumber(request.responseheaders["content-length"]); end | 129 if not request.body then request.body = {}; request.havebodylength, request.bodylength = 0, tonumber(request.headers["content-length"]); end |
130 if startpos then | 130 if startpos then |
131 data = data:sub(startpos, -1) | 131 data = data:sub(startpos, -1) |
132 end | 132 end |
133 t_insert(request.body, data); | 133 t_insert(request.body, data); |
134 if request.bodylength then | 134 if request.bodylength then |
139 end | 139 end |
140 end | 140 end |
141 elseif request.state == "headers" then | 141 elseif request.state == "headers" then |
142 log("debug", "Reading headers...") | 142 log("debug", "Reading headers...") |
143 local pos = startpos; | 143 local pos = startpos; |
144 local headers = request.responseheaders or {}; | 144 local headers = request.headers or {}; |
145 for line in data:gmatch("(.-)\r\n") do | 145 for line in data:gmatch("(.-)\r\n") do |
146 startpos = (startpos or 1) + #line + 2; | 146 startpos = (startpos or 1) + #line + 2; |
147 local k, v = line:match("(%S+): (.+)"); | 147 local k, v = line:match("(%S+): (.+)"); |
148 if k and v then | 148 if k and v then |
149 headers[k:lower()] = v; | 149 headers[k:lower()] = v; |
150 -- log("debug", "Header: "..k:lower().." = "..v); | 150 -- log("debug", "Header: "..k:lower().." = "..v); |
151 elseif #line == 0 then | 151 elseif #line == 0 then |
152 request.responseheaders = headers; | 152 request.headers = headers; |
153 break; | 153 break; |
154 else | 154 else |
155 log("debug", "Unhandled header line: "..line); | 155 log("debug", "Unhandled header line: "..line); |
156 end | 156 end |
157 end | 157 end |