mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-25 02:09:01 +02:00
fix(http): enhance Content-Length handling in ResponseModifier
- Introduced origContentLength and bodyModified fields to track original content length and body modification status. - Updated ContentLength and ContentLengthStr methods to return accurate content length based on body modification state. - Adjusted Write and FlushRelease methods to ensure proper handling of Content-Length header. - Modified middleware to use the new ContentLengthStr method.
This commit is contained in:
@@ -88,7 +88,7 @@ var staticReqVarSubsMap = map[string]reqVarGetter{
|
||||
|
||||
var staticRespVarSubsMap = map[string]respVarGetter{
|
||||
VarRespContentType: func(resp *ResponseModifier) string { return resp.Header().Get("Content-Type") },
|
||||
VarRespContentLen: func(resp *ResponseModifier) string { return strconv.Itoa(resp.ContentLength()) },
|
||||
VarRespContentLen: func(resp *ResponseModifier) string { return resp.ContentLengthStr() },
|
||||
VarRespStatusCode: func(resp *ResponseModifier) string { return strconv.Itoa(resp.StatusCode()) },
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user