diff --git a/drivers/plugins/counter/executor.go b/drivers/plugins/counter/executor.go index 7d019991..5efd9a2c 100644 --- a/drivers/plugins/counter/executor.go +++ b/drivers/plugins/counter/executor.go @@ -51,6 +51,10 @@ func (b *executor) DoHttpFilter(ctx http_service.IHttpContext, next eocontext.IC b.client = scope_manager.Auto[counter.IClient](b.clientID, "counter") b.counterPusher = scope_manager.Auto[counter.ICountPusher](b.countPusherID, "counter-pusher") }) + body := ctx.Response().GetBody() + if len(body) < 1 { + return next.DoChain(ctx) + } key := b.keyGenerate.Key(ctx) ct, has := b.counters.Get(key) diff --git a/entries/http-entry/reader.go b/entries/http-entry/reader.go index 6135b2b4..baf10c13 100644 --- a/entries/http-entry/reader.go +++ b/entries/http-entry/reader.go @@ -191,7 +191,11 @@ var ( return ctx.Request().Header().GetHeader(strings.Replace(name, "_", "-", -1)), true }), "headers": ReadFunc(func(name string, ctx http_service.IHttpContext) (interface{}, bool) { - return ctx.Request().Header().Headers(), true + result := make(map[string]string) + for key, value := range ctx.Request().Header().Headers() { + result[strings.ToLower(key)] = strings.Join(value, ";") + } + return result, true }), "http": ReadFunc(func(name string, ctx http_service.IHttpContext) (interface{}, bool) { return ctx.Request().Header().GetHeader(strings.Replace(name, "_", "-", -1)), true @@ -220,7 +224,11 @@ var ( return ctx.Response().GetHeader(strings.Replace(name, "_", "-", -1)), true }), "headers": ReadFunc(func(name string, ctx http_service.IHttpContext) (interface{}, bool) { - return ctx.Response().Headers(), true + result := make(map[string]string) + for key, value := range ctx.Response().Headers() { + result[strings.ToLower(key)] = strings.Join(value, ";") + } + return result, true }), "status": ReadFunc(func(name string, ctx http_service.IHttpContext) (interface{}, bool) { return ctx.Response().ProxyStatus(), true @@ -233,6 +241,10 @@ var ( }), }, "set_cookies": ReadFunc(func(name string, ctx http_service.IHttpContext) (interface{}, bool) { + cookies := ctx.Response().GetHeader("Set-Cookie") + if strings.TrimSpace(cookies) == "" { + return nil, true + } return strings.Split(ctx.Response().GetHeader("Set-Cookie"), "; "), true }), "dst_ip": ReadFunc(func(name string, ctx http_service.IHttpContext) (interface{}, bool) {