using reader for tests
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1243 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
7865c22209
commit
797a69d2b7
|
@ -15,6 +15,7 @@ package org.eclipse.jetty.server;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
|
@ -64,6 +65,13 @@ public class DumpHandler extends AbstractHandler
|
||||||
if (!isStarted())
|
if (!isStarted())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (request.getParameter("read")!=null)
|
||||||
|
{
|
||||||
|
Reader in = request.getReader();
|
||||||
|
for (int i=Integer.parseInt(request.getParameter("read"));i-->0;)
|
||||||
|
in.read();
|
||||||
|
}
|
||||||
|
|
||||||
if (request.getParameter("ISE")!=null)
|
if (request.getParameter("ISE")!=null)
|
||||||
{
|
{
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
|
@ -183,23 +191,20 @@ public class DumpHandler extends AbstractHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.write("</pre>\n<h3>Content:</h3>\n<pre>");
|
writer.write("</pre>\n<h3>Content:</h3>\n<pre>");
|
||||||
|
|
||||||
char[] content= new char[4096];
|
char[] content= new char[4096];
|
||||||
int len;
|
int len;
|
||||||
try{
|
try{
|
||||||
request.setCharacterEncoding(StringUtil.__UTF8);
|
|
||||||
Reader in=request.getReader();
|
Reader in=request.getReader();
|
||||||
String charset=request.getCharacterEncoding();
|
|
||||||
if (charset==null)
|
|
||||||
charset=StringUtil.__ISO_8859_1;
|
|
||||||
while((len=in.read(content))>=0)
|
while((len=in.read(content))>=0)
|
||||||
writer.write(new String(content,0,len));
|
writer.write(new String(content,0,len));
|
||||||
}
|
}
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
Log.warn(e);
|
|
||||||
writer.write(e.toString());
|
writer.write(e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
writer.write("</pre>");
|
writer.write("</pre>");
|
||||||
writer.write("</html>");
|
writer.write("</html>");
|
||||||
|
|
||||||
|
|
|
@ -233,7 +233,7 @@ public class HttpConnectionTest extends TestCase
|
||||||
offset = checkContains(response,offset,"HTTP/1.1 200");
|
offset = checkContains(response,offset,"HTTP/1.1 200");
|
||||||
offset = checkContains(response,offset,"encoding=unknown");
|
offset = checkContains(response,offset,"encoding=unknown");
|
||||||
offset = checkContains(response,offset,"/R1");
|
offset = checkContains(response,offset,"/R1");
|
||||||
offset = checkContains(response,offset,"12345");
|
offset = checkContains(response,offset,"UnsupportedEncodingException");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -257,12 +257,16 @@ public class HttpConnectionTest extends TestCase
|
||||||
int offset=0;
|
int offset=0;
|
||||||
|
|
||||||
offset=0;
|
offset=0;
|
||||||
requests="GET /R1?error=500 HTTP/1.1\n"+
|
requests="GET /R1?read=1&error=500 HTTP/1.1\n"+
|
||||||
"Host: localhost\n"+
|
"Host: localhost\n"+
|
||||||
|
"Transfer-Encoding: chunked\n"+
|
||||||
"Content-Type: text/plain; charset=utf-8\n"+
|
"Content-Type: text/plain; charset=utf-8\n"+
|
||||||
"Content-Length: 10\n"+
|
"\015\012"+
|
||||||
"\n"+
|
"5;\015\012"+
|
||||||
"0123456789\n"+
|
"12345\015\012"+
|
||||||
|
"5;\015\012"+
|
||||||
|
"67890\015\012"+
|
||||||
|
"0;\015\012\015\012"+
|
||||||
"GET /R2 HTTP/1.1\n"+
|
"GET /R2 HTTP/1.1\n"+
|
||||||
"Host: localhost\n"+
|
"Host: localhost\n"+
|
||||||
"Content-Type: text/plain; charset=utf-8\n"+
|
"Content-Type: text/plain; charset=utf-8\n"+
|
||||||
|
@ -287,12 +291,16 @@ public class HttpConnectionTest extends TestCase
|
||||||
int offset=0;
|
int offset=0;
|
||||||
|
|
||||||
offset=0;
|
offset=0;
|
||||||
requests="GET /R1?ISE=true HTTP/1.1\n"+
|
requests="GET /R1?read=1&ISE=true HTTP/1.1\n"+
|
||||||
"Host: localhost\n"+
|
"Host: localhost\n"+
|
||||||
|
"Transfer-Encoding: chunked\n"+
|
||||||
"Content-Type: text/plain; charset=utf-8\n"+
|
"Content-Type: text/plain; charset=utf-8\n"+
|
||||||
"Content-Length: 10\n"+
|
"\015\012"+
|
||||||
"\n"+
|
"5;\015\012"+
|
||||||
"0123456789\n"+
|
"12345\015\012"+
|
||||||
|
"5;\015\012"+
|
||||||
|
"67890\015\012"+
|
||||||
|
"0;\015\012\015\012"+
|
||||||
"GET /R2 HTTP/1.1\n"+
|
"GET /R2 HTTP/1.1\n"+
|
||||||
"Host: localhost\n"+
|
"Host: localhost\n"+
|
||||||
"Content-Type: text/plain; charset=utf-8\n"+
|
"Content-Type: text/plain; charset=utf-8\n"+
|
||||||
|
|
Loading…
Reference in New Issue