webmcp

view framework/env/request/get_header.lua @ 466:2751b6b81c23

Minor efficiency enhancement in <db_object>:try_save() method
author jbe
date Mon Nov 07 19:32:51 2016 +0100 (2016-11-07)
parents 6bbef2933ea5
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