MCPcopy Create free account
hub / github.com/imroc/req / shouldSendContentLength

Method shouldSendContentLength

transfer.go:225–247  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

223}
224
225func (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
249func (t *transferWriter) writeHeader(writeHeader func(key string, values ...string) error) error {
250 if t.Close && !hasToken(headerGet(t.Header, "Connection"), "close") {

Callers 1

writeHeaderMethod · 0.95

Calls 2

chunkedFunction · 0.85
isIdentityFunction · 0.85

Tested by

no test coverage detected