headers

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package headers reads and writes MIME headers while preserving the header order and folding style used by Blink-generated MHTML files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ordered

func Ordered(headers textproto.MIMEHeader, f func(key string, values []string) error) error

Ordered calls f for each header in headers: first the well-known keys in OrderedKeys order, then any remaining keys sorted alphabetically so output is deterministic.

func OrderedKeys

func OrderedKeys() []string

OrderedKeys returns the header order used by Blink-generated MHTML files. Writing headers in this order keeps output byte-identical to Chrome's.

func Scan

func Scan(scanner *bufio.Scanner, headers *textproto.MIMEHeader) error

Scan reads a header block from scanner into headers. It stops at the first blank line after at least one header has been read (blank lines before the block are tolerated). Folded continuation lines (starting with a tab or space) are unfolded into the preceding header value.

Scan returns nil when the block ends normally and io.EOF when the input ends before a terminating blank line.

func Write

func Write(writer io.Writer, key string, values []string) error

Write writes one header (all of its values) to writer, re-folding each value at semicolon boundaries the way Blink does. Content-Location values are never folded, since URLs may legitimately contain semicolons.

Types

This section is empty.

Jump to

Keyboard shortcuts

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