[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Tip for using a Luasocket's http.require for cranky webservers...
- From: PA <petite.abeille@...>
- Date: Sat, 20 Oct 2007 16:27:11 +0200
On Oct 20, 2007, at 02:46, gary ng wrote:
So I think it would be better to have headers sent as
proper cased for maximum compatibility.
FWIW, here is a little utility function to capitalize headers:
local function Capitalize( aValue )
return ( aValue:lower():gsub( '(%l)([%w_\']*)', function( first,
second ) return first:upper() .. second end ) )
end
Usage example:
for aKey, aValue in pairs( aHeader ) do
aWriter( ( '%s: %s' ):format( Capitalize( tostring( aKey ) ),
tostring( aValue ) ), '\r\n' )
end