Created
October 27, 2012 13:48
-
-
Save sramam/3964671 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function http_case(header) { | |
var map = {"accept":"Accept","accept-charset":"Accept-Charset","accept-encoding":"Accept-Encoding","accept-language":"Accept-Language","accept-datetime":"Accept-Datetime","authorization":"Authorization","cache-control":"Cache-Control","connection":"Connection","cookie":"Cookie","content-length":"Content-Length","content-md5":"Content-MD5","content-type":"Content-Type","date":"Date","expect":"Expect","from":"From","host":"Host","if-match":"If-Match","if-modified-since":"If-Modified-Since","if-none-match":"If-None-Match","if-range":"If-Range","if-unmodified-since":"If-Unmodified-Since","max-forwards":"Max-Forwards","pragma":"Pragma","proxy-authorization":"Proxy-Authorization","range":"Range","referer":"Referer","te":"TE","upgrade":"Upgrade","user-agent":"User-Agent","via":"Via","warning":"Warning","x-requested-with":"X-Requested-With","dnt":"DNT","x-forwarded-for":"X-Forwarded-For","x-forwarded-proto":"X-Forwarded-Proto","front-end-https":"Front-End-Https","x-att-deviceid":"X-ATT-DeviceId","x-wap-profile":"X-Wap-Profile","proxy-connection":"Proxy-Connection","access-control-allow-origin":"Access-Control-Allow-Origin","accept-ranges":"Accept-Ranges","age":"Age","allow":"Allow","content-encoding":"Content-Encoding","content-language":"Content-Language","content-location":"Content-Location","content-disposition":"Content-Disposition","content-range":"Content-Range","etag":"ETag","expires":"Expires","last-modified":"Last-Modified","link":"Link","location":"Location","p3p":"P3P","proxy-authenticate":"Proxy-Authenticate","refresh":"Refresh","retry-after":"Retry-After","server":"Server","set-cookie":"Set-Cookie","strict-transport-security":"Strict-Transport-Security","trailer":"Trailer","transfer-encoding":"Transfer-Encoding","vary":"Vary","www-authenticate":"WWW-Authenticate","x-frame-options":"X-Frame-Options","x-xss-protection":"X-XSS-Protection","x-content-type-options":"X-Content-Type-Options","x-powered-by":"X-Powered-By","x-ua-compatible":"X-UA-Compatible"} | |
if (map.hasOwnProperty(header.toLowerCase()) { | |
return map[header.toLowerCase()] | |
} else { | |
parts = header.split('-') | |
for(var idx=0; idx<parts.length; idx++) { | |
if (parts[idx].length >0) { | |
var word = parts[idx] | |
parts[idx] = word[0].toUpperCase() + word.substr(1) | |
} | |
} | |
return parts.join('-') | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment