diff --git a/curlx.go b/curlx.go index cf8907b..ecb36ae 100644 --- a/curlx.go +++ b/curlx.go @@ -182,7 +182,9 @@ func (c *Curlx) SendWithResponee(ctx context.Context, ps ...Param) Response { if n == 0 { break } - body = append(body, buf...) + // 读取n个字节 + body = append(body, buf[:n]...) + // body = append(body, buf...) } default: body, _ = io.ReadAll(resp.Body) diff --git a/params.go b/params.go index a295159..80cced1 100644 --- a/params.go +++ b/params.go @@ -106,6 +106,15 @@ func SetUserAgent(userAgent UserAgent) Param { } } +/** + * 设置Referer + */ +func SetReferer(referer string) Param { + return func(param *ClientParams) { + param.Headers["Referer"] = referer + } +} + /** * 设置cookies */ diff --git a/post.go b/post.go new file mode 100644 index 0000000..ef6e8c1 --- /dev/null +++ b/post.go @@ -0,0 +1,10 @@ +package curlx + +import ( + "io" + "net/http" +) + +func Post(url string, contentType string, body io.Reader) (resp *http.Response, err error) { + return http.Post(url, contentType, body) +}