File tree 2 files changed +11
-2
lines changed
main/java/org/springframework/restdocs/http
test/java/org/springframework/restdocs/http
2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ private String getRequestBody(OperationRequest request) {
134
134
}
135
135
else if (isPutOrPost (request )) {
136
136
if (request .getParts ().isEmpty ()) {
137
- String queryString = request .getParameters ().toQueryString ();
137
+ String queryString = request .getParameters ().getUniqueParameters ( request . getUri ()). toQueryString ();
138
138
if (StringUtils .hasText (queryString )) {
139
139
writer .println ();
140
140
writer .print (queryString );
@@ -206,7 +206,8 @@ private void writeMultipartEnd(PrintWriter writer) {
206
206
207
207
private boolean requiresFormEncodingContentTypeHeader (OperationRequest request ) {
208
208
return request .getHeaders ().get (HttpHeaders .CONTENT_TYPE ) == null && isPutOrPost (request )
209
- && (!request .getParameters ().isEmpty () && !includeParametersInUri (request ));
209
+ && !request .getParameters ().getUniqueParameters (request .getUri ()).isEmpty ()
210
+ && !includeParametersInUri (request );
210
211
}
211
212
212
213
private Map <String , String > header (String name , String value ) {
Original file line number Diff line number Diff line change @@ -224,6 +224,14 @@ public void putRequestWithParameter() throws IOException {
224
224
.header ("Content-Type" , "application/x-www-form-urlencoded" ).content ("b%26r=baz&a=alpha" ));
225
225
}
226
226
227
+ @ Test
228
+ public void putRequestWithTotallyOverlappingQueryStringAndParameters () throws IOException {
229
+ new HttpRequestSnippet ().document (this .operationBuilder .request ("http://localhost/foo?a=alpha&b=bravo" )
230
+ .method ("PUT" ).param ("a" , "alpha" ).param ("b" , "bravo" ).build ());
231
+ assertThat (this .generatedSnippets .httpRequest ())
232
+ .is (httpRequest (RequestMethod .PUT , "/foo?a=alpha&b=bravo" ).header (HttpHeaders .HOST , "localhost" ));
233
+ }
234
+
227
235
@ Test
228
236
public void multipartPost () throws IOException {
229
237
new HttpRequestSnippet ().document (this .operationBuilder .request ("http://localhost/upload" ).method ("POST" )
You can’t perform that action at this time.
0 commit comments