Skip to content

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

Merged
spacewander merged 2 commits into
apache:masterfrom
soulbird:fix/ext-resp-ct
Jan 6, 2023
Merged

fix(ext-plugin-post-resp): can't set content-type response header#8588
spacewander merged 2 commits into
apache:masterfrom
soulbird:fix/ext-resp-ct

Conversation

@soulbird

@soulbird soulbird commented Dec 29, 2022

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

@juzhiyuan juzhiyuan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@cod-soap

cod-soap commented Nov 2, 2023

Copy link
Copy Markdown

@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