http_util

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2022 License: GPL-3.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CharsetNames = map[string]Charset{
	"GB2312":  GB2312,
	"GBK":     GBK,
	"GB18030": GB18030,
	"UTF-8":   UTF8,
	"UTF8":    UTF8,
}
View Source
var DefaultHttpClient = &http.Client{
	Timeout: time.Second * 3,
}

Functions

func CalcTabNum

func CalcTabNum(text string) int

* 计算文本占据多少个tab的宽度

func CalcUtf8TextWidth

func CalcUtf8TextWidth(text string) int

func Convert2UTF8

func Convert2UTF8(text []byte, charset Charset) ([]byte, error)

* 将其他编码的文本转换成utf8编码

func GetWithRetry

func GetWithRetry(url string, retryCnt int, header ...http.Header) (*http.Response, error)

* 带重试的Get请求,最多尝试 1 + retryCnt 次请求,最少尝试1次请求

Types

type Charset

type Charset uint8
const (
	GB2312 Charset = iota
	GBK
	GB18030
	UTF8
)

func GetCharset

func GetCharset(head http.Header) Charset

Jump to

Keyboard shortcuts

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