apache / apache/apisix-go-plugin-runner

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

Open
#146 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
198
Forks
68
PR merge metrics
No merged PRs in 30d

Description

### 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

* APISIX Go Plugin Runner's version: 0.5.0
* APISIX version: 3.6.0
* Go version: 1.19.0
* OS (cmd: `uname -a`): Linux asec 5.15.0-78-generic 85-Ubuntu SMP Fri Jul 7 15:25:09 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
(running in docker)

### 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

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the ResponseFilter implementation and the response header handling shown in the issue, then reproduce the behavior in debug mode with the provided plugin and APISIX versions. Verify that setting or preserving content-type does not unexpectedly change it; done means the header remains unchanged or matches the value specified by the plugin.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.