Commit d44088f1 authored by Emmanuel Odeke's avatar Emmanuel Odeke Committed by Brad Fitzpatrick

net/http: refactored internal shouldClose for readability

Change-Id: Ie89c0945a4cc3aebfa9f7ad7f107bc7ab59ab61c
Reviewed-on: https://go-review.googlesource.com/19685Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent db44223f
......@@ -558,21 +558,19 @@ func fixLength(isResponse bool, status int, requestMethod string, header Header,
func shouldClose(major, minor int, header Header, removeCloseHeader bool) bool {
if major < 1 {
return true
} else if major == 1 && minor == 0 {
vv := header["Connection"]
if headerValuesContainsToken(vv, "close") || !headerValuesContainsToken(vv, "keep-alive") {
return true
}
return false
} else {
if headerValuesContainsToken(header["Connection"], "close") {
if removeCloseHeader {
header.Del("Connection")
}
return true
}
}
return false
conv := header["Connection"]
hasClose := headerValuesContainsToken(conv, "close")
if major == 1 && minor == 0 {
return hasClose || !headerValuesContainsToken(conv, "keep-alive")
}
if hasClose && removeCloseHeader {
header.Del("Connection")
}
return hasClose
}
// Parse the trailer header
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment