Closed
Description
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"]
----
----