webmcp

view framework/env/request/get_header.lua @ 458:6bbef2933ea5

Bugfix in request.get_header(...)
author jbe
date Mon Jul 25 22:49:40 2016 +0200 (2016-07-25)
parents 17a2b7e1c463
children
line source
1 --[[--
2 value = -- value of header as string containing comma (and space) separated values
3 request.get_header(
4 key -- name of header, e.g. "Authorization"
5 )
7 Returns the value of an HTTP header sent by the client. If the header occurs multiple times, the values are concatenated with a comma and zero or more space characters (e.g. "value1, value2"). If the header is missing, nil is returned.
9 --]]--
11 function request.get_header(key)
12 local http_request = request._http_request
13 local values = http_request.headers[key]
14 if #values == 0 then
15 return nil
16 elseif #values == 1 then
17 return values[1]
18 else
19 return http_request.headers_csv_string[key]
20 end
21 end

Impressum / About Us