All Projects β†’ vfaronov β†’ httpheader

vfaronov / httpheader

Licence: MIT license
Parse and generate HTTP headers correctly

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to httpheader

laravel-secureheaders
πŸ”’ SecureHeaders wrapper for Laravel.
Stars: ✭ 52 (+92.59%)
Mutual labels:  headers
toolbox-wiki
Internet.nl toolbox - how-to's for modern mail security standards (DMARC, DKIM, SPF and DANE)
Stars: ✭ 96 (+255.56%)
Mutual labels:  standards
laravel-mitnick
πŸ” laravel-security helps you secure your Laravel apps by setting various HTTP headers.
Stars: ✭ 76 (+181.48%)
Mutual labels:  headers
standards-maintenance
This repository houses the interactions, consultations and work management to support the maintenance of baselined components of the Consumer Data Right API Standards and Information Security profile.
Stars: ✭ 32 (+18.52%)
Mutual labels:  standards
iOS11RuntimeHeaders
iOS11RuntimeHeaders
Stars: ✭ 26 (-3.7%)
Mutual labels:  headers
zerover
0️⃣ Minimalist versioning scheme for devs who can't be bothered.
Stars: ✭ 141 (+422.22%)
Mutual labels:  standards
bids-examples
A set of BIDS compatible datasets with empty raw data files that can be used for writing lightweight software tests.
Stars: ✭ 127 (+370.37%)
Mutual labels:  standards
MapML
Map Markup Language is hypertext for Web maps, like HTML is hypertext for Web pages https://maps4html.org/MapML/spec/
Stars: ✭ 48 (+77.78%)
Mutual labels:  standards
detect-cloudflare-plus
True Sight Firefox extension.
Stars: ✭ 34 (+25.93%)
Mutual labels:  headers
swift-http-structured-headers
A Swift implementation of the HTTP Structured Header Field specification.
Stars: ✭ 126 (+366.67%)
Mutual labels:  headers
data-standards-authority
Collaboration space for working on data standards and guidance for the DSA
Stars: ✭ 23 (-14.81%)
Mutual labels:  standards
QCElemental
Periodic table, physical constants, and molecule parsing for quantum chemistry.
Stars: ✭ 116 (+329.63%)
Mutual labels:  standards
I40KG
Contains the development for the Industry 4.0 standards knowledge graph (I40KG). Its current collaborative development is driven by VoCol - http://vocol.iais.fraunhofer.de/sto/
Stars: ✭ 50 (+85.19%)
Mutual labels:  standards
Runtime-Headers
πŸ’Ώ iOS, macOS runtime headers
Stars: ✭ 26 (-3.7%)
Mutual labels:  headers
LIPs
LUKSO Improvement Proposals. Repository for the LUKSO Blockchain Improvement Proposals (LIPs) and LUKSO Standards Process (LSP).
Stars: ✭ 39 (+44.44%)
Mutual labels:  standards
software-dev
Coding Standards for the USC Biostats group
Stars: ✭ 33 (+22.22%)
Mutual labels:  standards
digitalgov.gov
Digital.gov β€”Β Helping the government community deliver better digital services.
Stars: ✭ 167 (+518.52%)
Mutual labels:  standards
gdelt2HeaderRows
A file that contains the schema for GDELT 2.0 Header rows for the Events Database.
Stars: ✭ 28 (+3.7%)
Mutual labels:  headers
MangoServer
A MongoDB implementation of the W3C Web Annotation Protocol
Stars: ✭ 16 (-40.74%)
Mutual labels:  standards
humble
A humble, and fast, security-oriented HTTP headers analyzer
Stars: ✭ 17 (-37.04%)
Mutual labels:  headers

httpheader

GoDoc Travis build status Codecov Go Report Card

This is a Go package to parse and generate standard HTTP headers correctly. It knows about complex headers like Accept, Prefer, Link. Unlike many other implementations, it handles all the tricky bits of syntax like quoted commas, multiple header lines, Unicode parameters. It gives you convenient structures to work with, and can serialize them back into HTTP.

This package is distributed under the MIT license, and hosted on GitHub. If it doesn't yet support a header that you need, feel free to open an issue there.

Installation

go get github.com/vfaronov/httpheader

Example

const request = `GET / HTTP/1.1
Host: api.example.com
User-Agent: MyApp/1.2.3 python-requests/2.22.0
Accept: text/*, application/json;q=0.8
Forwarded: for="198.51.100.30:14852";by="[2001:db8::ae:56]";proto=https

`

r, _ := http.ReadRequest(bufio.NewReader(strings.NewReader(request)))

forwarded := httpheader.Forwarded(r.Header)
fmt.Println("received request from user at", forwarded[0].For.IP)

for _, product := range httpheader.UserAgent(r.Header) {
	if product.Name == "MyApp" && product.Version < "2.0" {
		fmt.Println("enabling compatibility mode for", product)
	}
}

accept := httpheader.Accept(r.Header)
acceptJSON := httpheader.MatchAccept(accept, "application/json")
acceptXML := httpheader.MatchAccept(accept, "text/xml")
if acceptXML.Q > acceptJSON.Q {
	fmt.Println("responding with XML")
}

// Output: received request from user at 198.51.100.30
// enabling compatibility mode for {MyApp 1.2.3 }
// responding with XML
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].