mirror of
https://github.com/gospider007/requests.git
synced 2025-12-24 13:57:52 +08:00
sync
This commit is contained in:
5
tools.go
5
tools.go
@@ -117,10 +117,13 @@ func httpWrite(r *http.Request, w *bufio.Writer, orderHeaders []string) (err err
|
||||
if r.Header.Get("Host") == "" {
|
||||
r.Header.Set("Host", host)
|
||||
}
|
||||
if r.Header.Get("Connection") == "" {
|
||||
r.Header.Set("Connection", "keep-alive")
|
||||
}
|
||||
if r.Header.Get("User-Agent") == "" {
|
||||
r.Header.Set("User-Agent", UserAgent)
|
||||
}
|
||||
if r.Header.Get("Content-Length") == "" && shouldSendContentLength(r) {
|
||||
if r.Header.Get("Content-Length") == "" && r.ContentLength != 0 && shouldSendContentLength(r) {
|
||||
r.Header.Set("Content-Length", fmt.Sprint(r.ContentLength))
|
||||
}
|
||||
if _, err = w.WriteString(fmt.Sprintf("%s %s %s\r\n", r.Method, ruri, r.Proto)); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user