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

SetCommonContentType is no longer respected when SetBody() is called #265

Closed
gg718 opened this issue Aug 11, 2023 · 2 comments
Closed

SetCommonContentType is no longer respected when SetBody() is called #265

gg718 opened this issue Aug 11, 2023 · 2 comments

Comments

@gg718
Copy link

gg718 commented Aug 11, 2023

Summary

I am not sure exactly when this was broken, but it works as expected in v3.37.2 and does not work in v3.40.1, so at some point between then, calling SetBody on the request seems to disregard the Content-Type set at the global level.

Repro

package main

import (
	"github.com/imroc/req/v3"
)

func main() {
	client := req.C().
		DevMode().
		SetCommonContentType("application/json")

	_, _ = client.R().SetBody("").Post("https://example.com")
}

Expected

...
content-type: application/json; charset=utf-8
...

Actual

...
content-type: text/plain; charset=utf-8
...
@imroc
Copy link
Owner

imroc commented Aug 11, 2023

Nice catch! It's been fixed in the latest release.

@gg718
Copy link
Author

gg718 commented Aug 11, 2023

Thanks for the speedy fix!

@gg718 gg718 closed this as completed Aug 11, 2023
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

No branches or pull requests

2 participants