apache / apisix-go-plugin-runner

Go Plugin Runner for APISIX
https://apisix.apache.org/
Apache License 2.0
167 stars 69 forks source link

ext-plugin-post-resp processing content-type have problem #146

Open cod-soap opened 8 months ago

cod-soap commented 8 months ago

Issue description

ext-plugin-post-resp processing content-type have problem

I have seen fixed the issue: https://github.com/apache/apisix/pull/8588 But still have problem

Environment

Minimal test code / Steps to reproduce the issue

1.plugin run in debug mode

2.Changed the original text/html; charset=utf-8 to: text/plain; charset=utf-8 The code doesn't even do any business logic:

type FileRetentionConfig struct {
    Enable bool `json:"enable"`
}

type FileRetentionPlugin struct {
}

func (f FileRetentionPlugin) Name() string {
    return "file_retention_plugin"
}

func (f FileRetentionPlugin) ParseConf(in []byte) (conf interface{}, err error) {
    config := FileRetentionConfig{}
    err = jsoniter.Unmarshal(in, &config)
    return config, err
}

func (f FileRetentionPlugin) RequestFilter(conf interface{}, w http.ResponseWriter, r pkgHTTP.Request) {
    // do nothing
}

func (f FileRetentionPlugin) ResponseFilter(conf interface{}, w pkgHTTP.Response) {
    contentType := w.Header().Get("content-type")
    w.Header().Set("content-type", contentType)
    log.Infof("contentType:%v", contentType)
}

What's the actual result? (including assertion message & call stack if applicable)

hanged the original text/html; charset=utf-8 to: text/plain; charset=utf-8

What's the expected result?

do not change content-type or change to the value specified in the code

scoolor commented 7 months ago

lost content-type?