httpprd

package module
v0.0.0-...-69c6481 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2023 License: MIT Imports: 5 Imported by: 0

README

go-httpprd

Package httpprd provides tools for HTTP products, for the Go programming language.

Documention

Online documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-httpprd

GoDoc

Example:

import "github.com/reiver/go-httpprd"

// ...

var s string = "HTTP/1.1"

name, version, err := httpprd.Parse(s)
if nil != err {
	return err
}

fmt.Printf("HTTP-product name:    %q\n", name)
fmt.Printf("HTTP-product version: %q\n", version)


// Output:
// HTTP-product name:    "HTTP"
// HTTP-product version: "1.1"

Another Example

import "github.com/reiver/go-httpprd"

// ...

var s string = "finger/beta"

name, version, err := httpprd.Parse(s)
if nil != err {
	return err
}

fmt.Printf("HTTP-product name:    %q\n", name)
fmt.Printf("HTTP-product version: %q\n", version)


// Output:
// HTTP-product name:    "finger"
// HTTP-product version: "beta"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(rs io.RuneScanner) (name string, version string, err error)

Parse parses an HTTP-product, as defined by IETF RFC-2616, and return the HTTP-product 'name' and HTTP-product 'version'.

For example, this:

"HTTP/1.1"

Would result in an HTTP-product name of:

"HTTP"

And (would result in) an HTTP-product version of:

"1.1"

From the IETF RFC-2616:

product         = token ["/" product-version]
product-version = token

token          = 1*<any CHAR except CTLs or separators>
separators     = "(" | ")" | "<" | ">" | "@"
               | "," | ";" | ":" | "\" | <">
               | "/" | "[" | "]" | "?" | "="
               | "{" | "}" | SP | HT

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL