1
1
/*
2
- * Copyright 2002-2022 the original author or authors.
2
+ * Copyright 2002-2023 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -167,18 +167,16 @@ void getBody() throws IOException {
167
167
assertThat (result ).as ("Invalid content returned" ).isEqualTo (content );
168
168
}
169
169
170
- @ Test
170
+ @ Test // gh-13318
171
171
void getFormBody () throws IOException {
172
- // Charset (SPR-8676)
173
172
mockRequest .setContentType ("application/x-www-form-urlencoded; charset=UTF-8" );
174
173
mockRequest .setMethod ("POST" );
175
174
mockRequest .addParameter ("name 1" , "value 1" );
176
175
mockRequest .addParameter ("name 2" , "value 2+1" , "value 2+2" );
177
176
mockRequest .addParameter ("name 3" , (String ) null );
178
177
179
178
byte [] result = FileCopyUtils .copyToByteArray (request .getBody ());
180
- byte [] content = "name+1=value+1&name+2=value+2%2B1&name+2=value+2%2B2&name+3" .getBytes (
181
- StandardCharsets .UTF_8 );
179
+ byte [] content = "name+1=value+1&name+2=value+2%2B1&name+2=value+2%2B2&name+3" .getBytes (StandardCharsets .UTF_8 );
182
180
assertThat (result ).as ("Invalid content returned" ).isEqualTo (content );
183
181
}
184
182
@@ -192,4 +190,18 @@ void getEmptyFormBody() throws IOException {
192
190
assertThat (result ).as ("Invalid content returned" ).isEqualTo (content );
193
191
}
194
192
193
+ @ Test // gh-31327
194
+ void getFormBodyWhenQueryParamsAlsoPresent () throws IOException {
195
+ mockRequest .setContentType ("application/x-www-form-urlencoded; charset=UTF-8" );
196
+ mockRequest .setMethod ("POST" );
197
+ mockRequest .setQueryString ("q=1" );
198
+ mockRequest .addParameter ("q" , "1" );
199
+ mockRequest .setContent ("foo=bar" .getBytes (StandardCharsets .UTF_8 ));
200
+ mockRequest .addHeader ("Content-Length" , 7 );
201
+
202
+ byte [] result = FileCopyUtils .copyToByteArray (request .getBody ());
203
+ byte [] content = "foo=bar" .getBytes (StandardCharsets .UTF_8 );
204
+ assertThat (result ).as ("Invalid content returned" ).isEqualTo (content );
205
+ }
206
+
195
207
}
0 commit comments