306840 suppress content-length in requests without content
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1404 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
da9f167b31
commit
f3e2b0248d
|
@ -488,6 +488,7 @@ public class HttpGenerator extends AbstractGenerator
|
||||||
HttpFields.Field transfer_encoding = null;
|
HttpFields.Field transfer_encoding = null;
|
||||||
boolean keep_alive = false;
|
boolean keep_alive = false;
|
||||||
boolean close=false;
|
boolean close=false;
|
||||||
|
boolean content_type=false;
|
||||||
StringBuilder connection = null;
|
StringBuilder connection = null;
|
||||||
|
|
||||||
if (fields != null)
|
if (fields != null)
|
||||||
|
@ -516,6 +517,7 @@ public class HttpGenerator extends AbstractGenerator
|
||||||
if (BufferUtil.isPrefix(MimeTypes.MULTIPART_BYTERANGES_BUFFER, field.getValueBuffer())) _contentLength = HttpTokens.SELF_DEFINING_CONTENT;
|
if (BufferUtil.isPrefix(MimeTypes.MULTIPART_BYTERANGES_BUFFER, field.getValueBuffer())) _contentLength = HttpTokens.SELF_DEFINING_CONTENT;
|
||||||
|
|
||||||
// write the field to the header buffer
|
// write the field to the header buffer
|
||||||
|
content_type=true;
|
||||||
field.put(_header);
|
field.put(_header);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -659,7 +661,7 @@ public class HttpGenerator extends AbstractGenerator
|
||||||
{
|
{
|
||||||
// we have seen all the _content there is
|
// we have seen all the _content there is
|
||||||
_contentLength = _contentWritten;
|
_contentLength = _contentWritten;
|
||||||
if (content_length == null)
|
if (content_length == null && (_method==null || _contentLength>0 || content_type ))
|
||||||
{
|
{
|
||||||
// known length but not actually set.
|
// known length but not actually set.
|
||||||
_header.put(HttpHeaders.CONTENT_LENGTH_BUFFER);
|
_header.put(HttpHeaders.CONTENT_LENGTH_BUFFER);
|
||||||
|
|
|
@ -40,6 +40,28 @@ public class HttpGeneratorTest extends TestCase
|
||||||
super(arg0);
|
super(arg0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testRequest()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
Buffer bb=new ByteArrayBuffer(8096);
|
||||||
|
Buffer sb=new ByteArrayBuffer(1500);
|
||||||
|
HttpFields fields = new HttpFields();
|
||||||
|
ByteArrayEndPoint endp = new ByteArrayEndPoint(new byte[0],4096);
|
||||||
|
HttpGenerator hg = new HttpGenerator(new SimpleBuffers(sb,bb),endp);
|
||||||
|
|
||||||
|
fields.add("Host","something");
|
||||||
|
fields.add("User-Agent","test");
|
||||||
|
|
||||||
|
hg.setRequest("GET","/index.html");
|
||||||
|
hg.setVersion(11);
|
||||||
|
hg.completeHeader(fields,true);
|
||||||
|
hg.complete();
|
||||||
|
|
||||||
|
assertTrue(endp.getOut().toString().indexOf("GET /index.html HTTP/1.1")==0);
|
||||||
|
assertTrue(endp.getOut().toString().indexOf("Content-Length")==-1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void testHTTP()
|
public void testHTTP()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue