Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ext-plugin-post-resp): can't set content-type response header #8588

Merged
merged 2 commits into from
Jan 6, 2023

Conversation

soulbird
Copy link
Contributor

@soulbird soulbird commented Dec 29, 2022

Description

Fixes #8388 #8505

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@soulbird soulbird marked this pull request as ready for review December 30, 2022 00:58
@soulbird
Copy link
Contributor Author

Awaiting the outcome of the discussion at #8388 (comment)

spacewander
spacewander previously approved these changes Dec 30, 2022
@soulbird soulbird marked this pull request as draft January 3, 2023 05:59
@soulbird soulbird marked this pull request as ready for review January 3, 2023 13:12
Copy link
Member

@juzhiyuan juzhiyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cod-soap
Copy link

cod-soap commented Nov 2, 2023

@soulbird
There is still this issue, the latest version of 3.6 uses Golang

还是有这个问题,最新版的3.6,用的golang,

把原有的text/html; charset=utf-8 改为了:text/plain; charset=utf-8
代码中甚至没有做任何的业务逻辑,

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)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: external-plugin-post-resp plugin converts content-type from upstream response
5 participants