()
| 223 | } |
| 224 | |
| 225 | func (t *transferWriter) shouldSendContentLength() bool { |
| 226 | if chunked(t.TransferEncoding) { |
| 227 | return false |
| 228 | } |
| 229 | if t.ContentLength > 0 { |
| 230 | return true |
| 231 | } |
| 232 | if t.ContentLength < 0 { |
| 233 | return false |
| 234 | } |
| 235 | // Many servers expect a Content-Length for these methods |
| 236 | if t.Method == "POST" || t.Method == "PUT" || t.Method == "PATCH" { |
| 237 | return true |
| 238 | } |
| 239 | if t.ContentLength == 0 && isIdentity(t.TransferEncoding) { |
| 240 | if t.Method == "GET" || t.Method == "HEAD" { |
| 241 | return false |
| 242 | } |
| 243 | return true |
| 244 | } |
| 245 | |
| 246 | return false |
| 247 | } |
| 248 | |
| 249 | func (t *transferWriter) writeHeader(writeHeader func(key string, values ...string) error) error { |
| 250 | if t.Close && !hasToken(headerGet(t.Header, "Connection"), "close") { |
no test coverage detected