wiremock-rs icon indicating copy to clipboard operation
wiremock-rs copied to clipboard

Allow overriding `content-type` after `set_body_{bytes,json,string}`

Open JakubKoralewski opened this issue 3 years ago • 1 comments

The call to insert_header does nothing here:

let followed_page = ResponseTemplate::new(200)
	.set_body_string(followed_page_html)
	.insert_header("content-type", "text/html");

and instead requires doing this:

let followed_page = ResponseTemplate::new(200)
	.set_body_raw(followed_page_html.as_bytes(), "text/html; charset=utf-8");

I think this is confusing. Defaults are fine I guess, but it's weird that I can't set content-type to whatever I please to overwrite it.

Related

  • https://github.com/LukeMathWalker/wiremock-rs/issues/54
  • https://github.com/LukeMathWalker/wiremock-rs/issues/3

JakubKoralewski avatar Mar 28 '21 13:03 JakubKoralewski

Also, should the set_body_json really set the mimetype? A user should be able to set their own value anyway.

95th avatar Jan 02 '22 14:01 95th