codec

package
v0.27.1 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package codec — body.go: HTTP response-body decompression helpers shared by control (display decoding) and intruder (grep decoding).

Package codec provides the small, pure encode/decode transforms behind the Decoder tool and the MCP `decode` tool: base64, URL, hex, HTML entities, and JWT inspection, plus a best-effort "smart" auto-decode.

Index

Constants

This section is empty.

Variables

View Source
var Ops = []string{
	"base64encode", "base64decode",
	"urlencode", "urldecode",
	"hexencode", "hexdecode",
	"htmlencode", "htmldecode",
	"jwtdecode", "smart",
}

Ops lists every supported operation id (also the order shown in the UI).

Functions

func Apply

func Apply(op, s string) (string, error)

Apply runs one operation over s.

func DecompressBody added in v0.12.0

func DecompressBody(contentEncoding string, body []byte) ([]byte, bool)

DecompressBody inflates body according to the Content-Encoding header value. It supports gzip, deflate, br (brotli), and zstd. On success it returns the decompressed bytes and true. On any failure (unknown encoding, corrupt data, empty result) it returns nil, false — callers must fall back to the raw body.

For a comma-separated encoding chain the outermost (last) encoding is applied, which is the common case for HTTP/1.1 responses.

func IsBinaryContentType added in v0.12.0

func IsBinaryContentType(contentType string) bool

IsBinaryContentType returns true when the Content-Type header value indicates binary content (image, audio, video, font, octet-stream, zip, wasm, pdf) that cannot be meaningfully grepped as text.

Types

This section is empty.

Jump to

Keyboard shortcuts

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