mirror of
https://github.com/kataras/iris.git
synced 2025-02-02 07:20:35 +01:00
fix an issue on accesslog when response and request recorder and minifier were enabled
This commit is contained in:
parent
1ee6e83ae6
commit
d2f24fab90
|
@ -21,7 +21,9 @@ Developers are not forced to upgrade if they don't really need it. Upgrade whene
|
|||
|
||||
# Next
|
||||
|
||||
Change applies to `master` branch.
|
||||
Changes apply to `master` branch.
|
||||
|
||||
- Fix [iris-premium#17](https://github.com/kataras/iris-premium/issues/17).
|
||||
|
||||
- Replace [russross/blackfriday](github.com/russross/blackfriday/v2) with [gomarkdown](https://github.com/gomarkdown/markdown) as requested at [#2098](https://github.com/kataras/iris/issues/2098).
|
||||
|
||||
|
|
|
@ -836,20 +836,27 @@ func (ac *AccessLog) after(ctx *context.Context, lat time.Duration, method, path
|
|||
}
|
||||
|
||||
if ac.shouldReadResponseBody() {
|
||||
responseData := ctx.Recorder().Body()
|
||||
responseBodyLength := len(responseData)
|
||||
actualResponseData := ctx.Recorder().Body()
|
||||
responseBodyLength := len(actualResponseData)
|
||||
|
||||
if ac.BytesSentBody {
|
||||
bytesSent = responseBodyLength
|
||||
}
|
||||
if ac.ResponseBody && responseBodyLength > 0 {
|
||||
if ac.BodyMinify {
|
||||
// Copy response data as minifier now can change the back slice,
|
||||
// fixes: https://github.com/kataras/iris-premium/issues/17.
|
||||
responseData := make([]byte, len(actualResponseData))
|
||||
copy(responseData, actualResponseData)
|
||||
|
||||
if minified, err := ctx.Application().Minifier().Bytes(ctx.GetContentType(), responseData); err == nil {
|
||||
responseBody = string(minified)
|
||||
responseBodyLength = len(responseBody)
|
||||
}
|
||||
}
|
||||
|
||||
if responseBody == "" {
|
||||
responseBody = string(responseData)
|
||||
responseBody = string(actualResponseData)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user