Skip to content

HTTP request snippet for a PUT request with a query string duplicates the string's parameters in a form URL encoded body #763

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

Closed
wilkinsona opened this issue Nov 18, 2021 · 0 comments
Assignees
Labels
Milestone

Comments

@wilkinsona
Copy link
Member

wilkinsona commented Nov 18, 2021

Reported on Stack Overflow.

This test reproduces the problem:

@Test
public void putWithQueryString() throws Exception {
    MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
            .apply(new MockMvcRestDocumentationConfigurer(this.restDocumentation).snippets().withEncoding("UTF-8"))
            .build();
    mockMvc.perform(put("/?b=bravo&c=charlie").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk())
            .andDo(document("put-with-query-string"));
}

The HTTP request snippet has an unwanted body and Content-Type:

[source,http,options="nowrap"]
----
PUT /?b=bravo&c=charlie HTTP/1.1
Accept: application/json
Host: localhost:8080
Content-Type: application/x-www-form-urlencoded

b=bravo&c=charlie
----

By contrast, the curl, HTTPie, and request body snippets are correct with no body being sent:

[source,bash]
----
$ curl 'http://localhost:8080/?b=bravo&c=charlie' -i -X PUT \
    -H 'Accept: application/json'
----
[source,bash]
----
$ http PUT 'http://localhost:8080/?b=bravo&c=charlie' \
    'Accept:application/json'
----
[source,options="nowrap"]
----

----
@wilkinsona wilkinsona added the type: bug A bug label Nov 18, 2021
@wilkinsona wilkinsona added this to the 2.0.6.RELEASE milestone Nov 18, 2021
@wilkinsona wilkinsona self-assigned this Nov 18, 2021
@wilkinsona wilkinsona changed the title HTTP request snippet for a PUT request with a query string, duplicates the string's parameters in a form URL encoded body HTTP request snippet for a PUT request with a query string duplicates the string's parameters in a form URL encoded body Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant