一些优化

This commit is contained in:
Yun
2024-03-23 13:11:15 +08:00
parent 7254a9c8fb
commit 83e815bd1f
3 changed files with 22 additions and 1 deletions
+3 -1
View File
@@ -182,7 +182,9 @@ func (c *Curlx) SendWithResponee(ctx context.Context, ps ...Param) Response {
if n == 0 { if n == 0 {
break break
} }
body = append(body, buf...) // 读取n个字节
body = append(body, buf[:n]...)
// body = append(body, buf...)
} }
default: default:
body, _ = io.ReadAll(resp.Body) body, _ = io.ReadAll(resp.Body)
+9
View File
@@ -106,6 +106,15 @@ func SetUserAgent(userAgent UserAgent) Param {
} }
} }
/**
* 设置Referer
*/
func SetReferer(referer string) Param {
return func(param *ClientParams) {
param.Headers["Referer"] = referer
}
}
/** /**
* 设置cookies * 设置cookies
*/ */
+10
View File
@@ -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)
}