319655 Reset HEAD status
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2115 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
701bbe1e3e
commit
124663aaf1
|
@ -2,6 +2,7 @@ jetty-7.2-SNAPSHOT
|
|||
+ 319334 Concurrent, sharable ResourceCache
|
||||
+ 319370 WebAppClassLoader.Context
|
||||
+ 319519 Warn about duplicate configuration files
|
||||
+ 319655 Reset HEAD status
|
||||
+ JETTY-1247 synchronize recylcing of SSL NIO buffers
|
||||
+ JETTY-1249 Apply max idle time to all connectors
|
||||
+ Added ignore to Logger interface
|
||||
|
|
|
@ -246,6 +246,8 @@ public abstract class AbstractGenerator implements Generator
|
|||
*/
|
||||
public void setHead(boolean head)
|
||||
{
|
||||
System.err.println("setHead "+head);
|
||||
new Throwable().printStackTrace();
|
||||
_head = head;
|
||||
}
|
||||
|
||||
|
|
|
@ -845,6 +845,7 @@ public class HttpConnection implements Connection
|
|||
|
||||
try
|
||||
{
|
||||
_head=false;
|
||||
switch (HttpMethods.CACHE.getOrdinal(method))
|
||||
{
|
||||
case HttpMethods.CONNECT_ORDINAL:
|
||||
|
|
|
@ -121,6 +121,29 @@ public class HttpConnectionTest
|
|||
offset = checkContains(response,offset,"HTTP/1.1 200");
|
||||
offset = checkContains(response,offset,"/R1");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHead() throws Exception
|
||||
{
|
||||
String responsePOST=connector.getResponses("POST /R1 HTTP/1.1\015\012"+
|
||||
"Host: localhost\015\012"+
|
||||
"\015\012");
|
||||
|
||||
String responseHEAD=connector.getResponses("HEAD /R1 HTTP/1.1\015\012"+
|
||||
"Host: localhost\015\012"+
|
||||
"\015\012");
|
||||
|
||||
assertTrue(responsePOST.startsWith(responseHEAD.substring(0,responseHEAD.length()-2)));
|
||||
assertTrue(responsePOST.length()>responseHEAD.length());
|
||||
|
||||
responsePOST=connector.getResponses("POST /R1 HTTP/1.1\015\012"+
|
||||
"Host: localhost\015\012"+
|
||||
"\015\012");
|
||||
|
||||
assertTrue(responsePOST.startsWith(responseHEAD.substring(0,responseHEAD.length()-2)));
|
||||
assertTrue(responsePOST.length()>responseHEAD.length());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBad() throws Exception
|
||||
|
|
|
@ -580,6 +580,60 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHead() throws Exception
|
||||
{
|
||||
configureServer(new EchoHandler(false));
|
||||
|
||||
Socket client=newSocket(HOST,_connector.getLocalPort());
|
||||
try
|
||||
{
|
||||
OutputStream os=client.getOutputStream();
|
||||
InputStream is=client.getInputStream();
|
||||
|
||||
os.write((
|
||||
"POST /R1 HTTP/1.1\015\012"+
|
||||
"Host: "+HOST+":"+_connector.getLocalPort()+"\r\n"+
|
||||
"content-type: text/plain; charset=utf-8\r\n"+
|
||||
"content-length: 10\r\n"+
|
||||
"\015\012"+
|
||||
"123456789\n" +
|
||||
|
||||
"HEAD /R1 HTTP/1.1\015\012"+
|
||||
"Host: "+HOST+":"+_connector.getLocalPort()+"\015\012"+
|
||||
"content-type: text/plain; charset=utf-8\r\n"+
|
||||
"content-length: 10\r\n"+
|
||||
"\015\012"+
|
||||
"123456789\n"+
|
||||
|
||||
"POST /R1 HTTP/1.1\015\012"+
|
||||
"Host: "+HOST+":"+_connector.getLocalPort()+"\015\012"+
|
||||
"content-type: text/plain; charset=utf-8\r\n"+
|
||||
"content-length: 10\r\n"+
|
||||
"Connection: close\015\012"+
|
||||
"\015\012"+
|
||||
"123456789\n"
|
||||
|
||||
).getBytes("iso-8859-1"));
|
||||
|
||||
String in = IO.toString(is);
|
||||
|
||||
System.err.println(in);
|
||||
|
||||
int index=in.indexOf("123456789");
|
||||
assertTrue(index>0);
|
||||
index=in.indexOf("123456789",index+1);
|
||||
assertTrue(index>0);
|
||||
index=in.indexOf("123456789",index+1);
|
||||
assertTrue(index==-1);
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRecycledReaders() throws Exception
|
||||
{
|
||||
|
|
|
@ -60,6 +60,16 @@ public class HttpServerTestFixture
|
|||
|
||||
protected static class EchoHandler extends AbstractHandler
|
||||
{
|
||||
boolean musthavecontent=true;
|
||||
|
||||
public EchoHandler()
|
||||
{}
|
||||
|
||||
public EchoHandler(boolean content)
|
||||
{
|
||||
musthavecontent=false;
|
||||
}
|
||||
|
||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
||||
{
|
||||
baseRequest.setHandled(true);
|
||||
|
@ -72,19 +82,28 @@ public class HttpServerTestFixture
|
|||
response.setCharacterEncoding(request.getCharacterEncoding());
|
||||
|
||||
PrintWriter writer=response.getWriter();
|
||||
BufferedReader reader=request.getReader();
|
||||
|
||||
int count=0;
|
||||
String line;
|
||||
|
||||
while ((line=reader.readLine())!=null)
|
||||
BufferedReader reader=request.getReader();
|
||||
if (request.getContentLength()!=0)
|
||||
{
|
||||
writer.print(line);
|
||||
writer.print("\n");
|
||||
count+=line.length();
|
||||
String line;
|
||||
|
||||
while ((line=reader.readLine())!=null)
|
||||
{
|
||||
writer.print(line);
|
||||
writer.print("\n");
|
||||
count+=line.length();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (count==0)
|
||||
throw new IllegalStateException("no input recieved");
|
||||
{
|
||||
if (musthavecontent)
|
||||
throw new IllegalStateException("no input recieved");
|
||||
|
||||
writer.println("No content");
|
||||
}
|
||||
|
||||
// just to be difficult
|
||||
reader.close();
|
||||
|
|
Loading…
Reference in New Issue