webmcp

annotate framework/env/request/get_header.lua @ 480:e09654c4a042

Allow main handlers to use a poll function that indicates when process termination is requested
author jbe
date Tue Jun 06 16:14:33 2017 +0200 (2017-06-06)
parents 6bbef2933ea5
children
rev   line source
jbe@456 1 --[[--
jbe@456 2 value = -- value of header as string containing comma (and space) separated values
jbe@456 3 request.get_header(
jbe@456 4 key -- name of header, e.g. "Authorization"
jbe@456 5 )
jbe@456 6
jbe@457 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.
jbe@456 8
jbe@456 9 --]]--
jbe@456 10
jbe@456 11 function request.get_header(key)
jbe@457 12 local http_request = request._http_request
jbe@458 13 local values = http_request.headers[key]
jbe@457 14 if #values == 0 then
jbe@457 15 return nil
jbe@457 16 elseif #values == 1 then
jbe@457 17 return values[1]
jbe@457 18 else
jbe@458 19 return http_request.headers_csv_string[key]
jbe@457 20 end
jbe@456 21 end

Impressum / About Us