rfc

package
v0.16.16 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: Apache-2.0, MIT Imports: 1 Imported by: 0

Documentation

Overview

Package rfc provides standards related functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PatchHost added in v0.13.113

func PatchHost(host string) string

PatchHost returns a host string without trailing dot. For details see also the discussion in https://lists.w3.org/Archives/Public/ietf-http-wg/2016JanMar/0430.html.

func PatchPath

func PatchPath(parsed, raw string) string

PatchPath attempts to patch a request path based on an interpretation of the standards RFC 2616 and RFC 3986 where the reserved characters should not be unescaped. Currently the Go stdlib does unescape these characters (v1.12.5).

It expects the parsed path as found in http.Request.URL.Path and the raw path as found in http.Request.URL.RawPath. It returns a path where characters e.g. like '/' have the escaped form of %2F, if it was detected that they are unescaped in the raw path.

It only returns the patched variant, if the only difference between the parsed and raw paths are the encoding of the chars, according to RFC 3986. If it detects any other difference between the two, it returns the original parsed path as provided. It tolerates an empty argument for the raw path, which can happen when the URL parsed via the stdlib url package, and there is no difference between the parsed and the raw path. This basically means that the following code is correct:

req.URL.Path = rfc.PatchPath(req.URL.Path, req.URL.RawPath)

Links: - https://tools.ietf.org/html/rfc2616#section-3.2.3 and - https://tools.ietf.org/html/rfc3986#section-2.2

Types

This section is empty.

Jump to

Keyboard shortcuts

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