Issue#1066 Simplify HttpGeneration

HTTP requests cannot be close limited
This commit is contained in:
Greg Wilkins 2016-11-04 08:29:49 +11:00
parent 3c3be877c6
commit 5395cfd021
3 changed files with 25 additions and 5 deletions

View File

@ -18,6 +18,8 @@
package org.eclipse.jetty.client;
import static org.junit.Assert.assertThat;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -71,6 +73,7 @@ import org.eclipse.jetty.client.util.BytesContentProvider;
import org.eclipse.jetty.client.util.DeferredContentProvider;
import org.eclipse.jetty.client.util.FutureResponseListener;
import org.eclipse.jetty.client.util.StringContentProvider;
import org.eclipse.jetty.http.BadMessageException;
import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpHeaderValue;
@ -1289,13 +1292,29 @@ public class HttpClientTest extends AbstractHttpClientServerTest
@Test
public void testSmallContentDelimitedByEOFWithSlowRequestHTTP10() throws Exception
{
testContentDelimitedByEOFWithSlowRequest(HttpVersion.HTTP_1_0, 1024);
try
{
testContentDelimitedByEOFWithSlowRequest(HttpVersion.HTTP_1_0, 1024);
}
catch(ExecutionException e)
{
assertThat(e.getCause(), Matchers.instanceOf(BadMessageException.class));
assertThat(e.getCause().getMessage(), Matchers.containsString("Unknown content"));
}
}
@Test
public void testBigContentDelimitedByEOFWithSlowRequestHTTP10() throws Exception
{
testContentDelimitedByEOFWithSlowRequest(HttpVersion.HTTP_1_0, 128 * 1024);
try
{
testContentDelimitedByEOFWithSlowRequest(HttpVersion.HTTP_1_0, 128 * 1024);
}
catch(ExecutionException e)
{
assertThat(e.getCause(), Matchers.instanceOf(BadMessageException.class));
assertThat(e.getCause().getMessage(), Matchers.containsString("Unknown content"));
}
}
@Test

View File

@ -1,4 +1,5 @@
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
#org.eclipse.jetty.LEVEL=DEBUG
#org.eclipse.jetty.client.LEVEL=DEBUG
#org.eclipse.jetty.io.ChannelEndPoint.LEVEL=DEBUG
#org.eclipse.jetty.io.ChannelEndPoint.LEVEL=DEBUG
org.eclipse.jetty.http.LEVEL=DEBUG

View File

@ -744,7 +744,7 @@ public class HttpGenerator
transfer_encoding = null;
}
else
throw new BadMessageException(INTERNAL_SERVER_ERROR_500,"BAD TE");
throw new BadMessageException(INTERNAL_SERVER_ERROR_500,"Bad Transfer-Encoding");
}
// Else if we known the content length and are a request or a persistent response,
else if (content_length>=0 && (request!=null || _persistent))
@ -756,7 +756,7 @@ public class HttpGenerator
// Else if we are a response
else if (response!=null)
{
// We can use EOF
// We must use EOF - even if we were trying to be persistent
_endOfContent = EndOfContent.EOF_CONTENT;
_persistent=false;
if (content_length>=0 && ( content_length> 0 || assumed_content || content_length_field ))