1 Star 0 Fork 0

solid / sutils

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
header.go 1.08 KB
一键复制 编辑 原始数据 按行查看 历史
Solid 提交于 2024-01-19 13:34 . file功能添加,添加常见的加解密
package shttp
import "fmt"
// Accept sets the Accept header for a request.
func (c *Client) Accept(contentTypes string) {
c.http.Header.Set("Accept", contentTypes)
}
// CacheControl sets the client-side Cache-Control directive for a request.
func (c *Client) CacheControl(directive string) {
c.http.Header.Set("Cache-Control", directive)
}
// ContentType sets the Content-Type header on a request.
func (c *Client) ContentType(ct string) {
c.http.Header.Set("Content-Type", ct)
}
// UserAgent sets the User-Agent header.
func (c *Client) UserAgent(s string) {
c.http.Header.Set("User-Agent", s)
}
// 设置头部
func (c *Client) Headers(h map[string]string) error {
if c.http == nil {
return fmt.Errorf("设置失败")
}
for key, v := range h {
c.http.Header.Set(key, v)
}
return nil
}
// 设置头部
func (c *Client) Set(name, value string) {
c.http.Header.Set(name, value)
}
// 获取返回的数据大小
func (c *Client) GetContentLength() int64 {
return c.content_length
}
// 获取返回的数据类型
func (c *Client) GetContentType() string {
return c.content_type
}
Go
1
https://gitee.com/solidone/sutils.git
git@gitee.com:solidone/sutils.git
solidone
sutils
sutils
f1241d18e4eb

搜索帮助