lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



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