Issue #6327 Remove an invalid RequestTest
Signed-off-by: Jan Bartel <janb@webtide.com>
This commit is contained in:
parent
21aba4a724
commit
f50c4fd4b4
|
@ -1013,75 +1013,6 @@ public class RequestTest
|
|||
assertThat(response, containsString(" 200 OK"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled("See issue #1175")
|
||||
public void testMultiPartFormDataReadInputThenParams() throws Exception
|
||||
{
|
||||
final File tmpdir = MavenTestingUtils.getTargetTestingDir("multipart");
|
||||
FS.ensureEmpty(tmpdir);
|
||||
|
||||
Handler handler = new AbstractHandler()
|
||||
{
|
||||
@Override
|
||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException
|
||||
{
|
||||
if (baseRequest.getDispatcherType() != DispatcherType.REQUEST)
|
||||
return;
|
||||
|
||||
// Fake a @MultiPartConfig'd servlet endpoint
|
||||
MultipartConfigElement multipartConfig = new MultipartConfigElement(tmpdir.getAbsolutePath());
|
||||
request.setAttribute(Request.__MULTIPART_CONFIG_ELEMENT, multipartConfig);
|
||||
|
||||
// Normal processing
|
||||
baseRequest.setHandled(true);
|
||||
|
||||
// Fake the commons-fileupload behavior
|
||||
int length = request.getContentLength();
|
||||
InputStream in = request.getInputStream();
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
IO.copy(in, out, length); // KEY STEP (Don't Change!) commons-fileupload does not read to EOF
|
||||
|
||||
// Record what happened as servlet response headers
|
||||
response.setIntHeader("x-request-content-length", request.getContentLength());
|
||||
response.setIntHeader("x-request-content-read", out.size());
|
||||
String foo = request.getParameter("foo"); // uri query parameter
|
||||
String bar = request.getParameter("bar"); // form-data content parameter
|
||||
response.setHeader("x-foo", foo == null ? "null" : foo);
|
||||
response.setHeader("x-bar", bar == null ? "null" : bar);
|
||||
}
|
||||
};
|
||||
|
||||
_server.stop();
|
||||
_server.setHandler(handler);
|
||||
_server.start();
|
||||
|
||||
String multipart = "--AaBbCc\r\n" +
|
||||
"content-disposition: form-data; name=\"bar\"\r\n" +
|
||||
"\r\n" +
|
||||
"BarContent\r\n" +
|
||||
"--AaBbCc\r\n" +
|
||||
"content-disposition: form-data; name=\"stuff\"\r\n" +
|
||||
"Content-Type: text/plain;charset=ISO-8859-1\r\n" +
|
||||
"\r\n" +
|
||||
"000000000000000000000000000000000000000000000000000\r\n" +
|
||||
"--AaBbCc--\r\n";
|
||||
|
||||
String request = "POST /?foo=FooUri HTTP/1.1\r\n" +
|
||||
"Host: whatever\r\n" +
|
||||
"Content-Type: multipart/form-data; boundary=\"AaBbCc\"\r\n" +
|
||||
"Content-Length: " + multipart.getBytes().length + "\r\n" +
|
||||
"Connection: close\r\n" +
|
||||
"\r\n" +
|
||||
multipart;
|
||||
|
||||
HttpTester.Response response = HttpTester.parseResponse(_connector.getResponse(request));
|
||||
|
||||
// It should always be possible to read query string
|
||||
assertThat("response.x-foo", response.get("x-foo"), is("FooUri"));
|
||||
// Not possible to read request content parameters?
|
||||
assertThat("response.x-bar", response.get("x-bar"), is("null")); // TODO: should this work?
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPartialRead() throws Exception
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue