why remove response header "Connection: Close" automatically?

115 views
Skip to first unread message

chen...@gmail.com

unread,
Nov 15, 2021, 10:48:46 PM11/15/21
to golang-nuts
hi guys,

When i was doing a http api performance benchmark, i found a lot of  connections of status of "TIME_WAIT". I have tried to change the value of Transport.MaxConnsPerHost, but still not working. After a long time debuging, i finally found that api response header contains "
Connection: close", so that the connection was closed. But when i dump the request and response with httputil.DumpResponse, i cannot see the "Connection: close" header. This is weird!

After read the source code, i found that last parameter of function "http.shouldClose", removeCloseHeader was set to true when target is response. Once headers contains "Connection: close", the header will be removed.

so my question is, what's the purpose of the design. leaving the header exists will be be helpful for debuging, why remove it?  

thanks a lot if someone could answer my doubts.
Reply all
Reply to author
Forward
0 new messages