binaryview

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// default number of bytes shown per line in hex dumps.
	HexDumpBytesPerLine = 16
)

Variables

This section is empty.

Functions

func Base64Lines

func Base64Lines(body []byte, width int) string

Base64Lines wraps base64 output at a given width. Long base64 strings are unreadable and break terminal rendering, so we chunk them into lines like PEM files do.

func DecodeText

func DecodeText(body []byte, charsetLabel string) (string, bool, string)

func HexDump

func HexDump(body []byte, bytesPerLine int) string

func HexPreview

func HexPreview(body []byte) string

Types

type Body added in v1.10.2

type Body struct {
	Data        []byte
	ContentType string
	Disposition string
	URL         string
}

func (Body) Name added in v1.10.2

func (b Body) Name() string

Name tries to figure out a good filename for saving a response. Order: 1) Content-Disposition header 2) URL path 3) MIME type extension 4) Fallback to "response.bin"

func (Body) ViewerName added in v1.10.2

func (b Body) ViewerName() (string, bool)

ViewerName returns a file name that is safe to open with the default app. The extension decides which app runs, so it always comes from fileTypes and never from the server. We look at the Content-Type first, then the file name the server sent, then the body bytes.

type Kind

type Kind int
const (
	KindUnknown Kind = iota
	KindText
	KindBinary
)

type Meta

type Meta struct {
	Kind       Kind
	MIME       string
	Charset    string
	Size       int
	Printable  bool
	DecodeErr  string
	PreviewHex string
	PreviewB64 string
}

func Analyze

func Analyze(body []byte, contentType string) Meta

Jump to

Keyboard shortcuts

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