Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Provide a preprocessor that can modify request and response headers #584

Closed
wants to merge 1 commit into from

Conversation

ghoonch4
Copy link
Contributor

@ghoonch4 ghoonch4 commented Feb 19, 2019

modifyHeaders on Preprocessors can be used to add, set, and remove request or response headers. This can completely replace the removeHeaders on Preprocessors. So if PR is accepted, I think the deprecation of removeHeaders should be considered.

The modifyHeaders can be used like this:

@Test
public void test() throws Exception {
    this.mockMvc.perform(get("/"))
        .andExpect(status().isOk())
        .andDo(document("index"),
            preprocessRequest(
                modifyHeaders()
                    .add("a", "avocado")
                    .set("a", "avocado")
                    .set("a", "avocado", "apple")
                    .remove("a")
                    .remove(Pattern.compile("^a.*"))
                    .remove("a", "avocado")),
            preprocessResponse(
                prettyPrint(),
                modifyHeaders()
                    .add("b", "bravo")));
}

@wilkinsona wilkinsona added type: enhancement Enhancement that adds a new feature and removed status: waiting-for-triage Untriaged issue labels Feb 19, 2019
@wilkinsona wilkinsona added this to the 2.1.0.RC1 milestone Feb 19, 2019
@wilkinsona wilkinsona changed the title Provide a preprocessor that can modify existing headers (#580) Provide a preprocessor that can modify existing headers Nov 13, 2020
@pivotal-issuemaster
Copy link

@jhnchv Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@pivotal-issuemaster
Copy link

@ghoonch4 Thank you for signing the Contributor License Agreement!

@ghoonch4
Copy link
Contributor Author

Hi, @wilkinsona. It's been a long time. I saw 3.0.0-M2 on https://spring.io/projects/spring-restdocs#learn. Is the plan for 2.1.0.RC1 valid?

@wilkinsona
Copy link
Member

In an ideal world, there'd still be a 2.1 release that ships with Boot 2.7. Unfortunately, I think I need to be realistic and accept that it's not going to happen due to too many competing commitments. I'll reschedule this for inclusion in 3.0.

@wilkinsona wilkinsona modified the milestones: 2.1.0-RC1, 3.0.0-M3 Mar 24, 2022
@wilkinsona wilkinsona changed the title Provide a preprocessor that can modify existing headers Provide a preprocessor that can modify request and response headers May 12, 2022
@wilkinsona
Copy link
Member

Thanks very much, @ghoonch4.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
type: enhancement Enhancement that adds a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants