LukeMathWalker / LukeMathWalker/wiremock-rs

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

Open
#63 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
799
Forks
91
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the ResponseTemplate entry points set_body_bytes, set_body_json, set_body_string, and set_body_raw, then compare how they apply content-type with the behavior described in the related issues. Done means insert_header can replace the content-type set by the body helpers while their existing defaults continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
testing
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.