Skip to content

Zyl9393/lowerkeys

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lowerkeys

Go’s http.Header does not comply with HTTP 2’s lower-case header key names because its behavior cannot be updated due to Go 1.x’s backwards compatibility promise. Since header key names are case-insensitive in HTTP 1.x, lower-case is now the de facto way to case header keys.

This package makes this easy to achieve by providing type Header http.Header in package lowerkeys which has overrides for all relevant methods of http.Header:

response, _ := http.Get("https://example.com")
header := lowerkeys.Using(response.Header()) // Same underlying map, with lower-cased keys.
header.Get("cOnTeNt-TyPe") // Has overrides which lower-cases the key parameter.

Everything else you need to know:

import "github.com/Zyl9393/lowerkeys"

lowerkeys.New() // Glorified make(lowerkeys.Header)
lowerkeys.From(response.Header()) // Like Using(), but makes a clone of the map beforehand.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages