Mercurial Hosting > luan
diff src/luan/modules/url/LuanUrl.java @ 1150:0842b9b570f8
change http headers interface
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 04 Feb 2018 18:03:37 -0700 |
parents | cb4c20fce7d0 |
children | dbb3cb906482 |
line wrap: on
line diff
--- a/src/luan/modules/url/LuanUrl.java Sun Feb 04 17:23:20 2018 -0700 +++ b/src/luan/modules/url/LuanUrl.java Sun Feb 04 18:03:37 2018 -0700 @@ -52,17 +52,16 @@ headers = new HashMap(); for( Object hack : headerMap.entrySet() ) { Map.Entry entry = (Map.Entry)hack; - String key = (String)entry.getKey(); + String name = (String)entry.getKey(); Object val = entry.getValue(); - String name = toHttpHeaderName(key); if( val instanceof String ) { headers.put(name,val); } else { if( !(val instanceof LuanTable) ) - throw new LuanException( "header '"+key+"' must be string or table" ); + throw new LuanException( "header '"+name+"' must be string or table" ); LuanTable t = (LuanTable)val; if( !t.isList() ) - throw new LuanException( "header '"+key+"' table must be list" ); + throw new LuanException( "header '"+name+"' table must be list" ); headers.put(name,t.asList()); } } @@ -148,24 +147,6 @@ } } - public static String toHttpHeaderName(String luanName) { - luanName = luanName.toLowerCase(); - StringBuilder buf = new StringBuilder(); - boolean capitalize = true; - char[] a = luanName.toCharArray(); - for( int i=0; i<a.length; i++ ) { - char c = a[i]; - if( c == '_' || c == '-' ) { - a[i] = '-'; - capitalize = true; - } else if( capitalize ) { - a[i] = Character.toUpperCase(c); - capitalize = false; - } - } - return String.valueOf(a); - } - private static void and(StringBuilder sb) { if( sb.length() > 0 ) sb.append('&');