Skip to content

Preserve original Content-Type in OHTTP requests#52

Merged
ameshkov merged 1 commit into
ameshkov:masterfrom
D13410N3:master
May 22, 2026
Merged

Preserve original Content-Type in OHTTP requests#52
ameshkov merged 1 commit into
ameshkov:masterfrom
D13410N3:master

Conversation

@D13410N3

Copy link
Copy Markdown
Contributor

Current behaviour of gocurl explicitly sets "Content-Type", "application/x-www-form-urlencoded" if request data is not empty

func addBodyHeaders(req *http.Request, cfg *config.Config) {
	if cfg.Data != "" && !websocket.IsWebSocket(cfg.RequestURL) {
		req.Header.Add("Content-Type", "application/x-www-form-urlencoded")

If user's request contains its own "Content-Type" header - both headers are clued to one

...
"Content-Type": "application/x-www-form-urlencoded  application/json",

This is wrong behaviour - we need to overwrite user's request content-type

This PR fix this behaviour

@ameshkov ameshkov merged commit b50c3e5 into ameshkov:master May 22, 2026
6 checks passed
@D13410N3 D13410N3 review requested due to automatic review settings May 22, 2026 14:02
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.

2 participants