JETTY-1212 handle long content lengths

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1567 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2010-04-26 20:25:52 +00:00
parent 937d475839
commit d95081150b
3 changed files with 76 additions and 9 deletions

View File

@ -16,6 +16,7 @@ jetty-7.1.0-SNAPSHOT
+ JETTY-903 Stop both caches
+ JETTY-1200 SSL NIO Endpoint wraps non NIO buffers
+ JETTY-1202 Use platform default algorithm for SecureRandom
+ JETTY-1212 handle long content lengths
+ Fix jetty-plus.xml reference to addLifeCycle
+ Add AnnotationConfiguration to jetty-plus.xml
+ 310467 Allow SocketConnector to create generic Connection objects

View File

@ -254,9 +254,9 @@ public class BufferUtil
{
boolean started= false;
// This assumes constant time int arithmatic
for (int i= 0; i < decDivisors.length; i++)
for (int i= 0; i < decDivisorsL.length; i++)
{
if (n < decDivisors[i])
if (n < decDivisorsL[i])
{
if (started)
buffer.put((byte)'0');
@ -264,25 +264,68 @@ public class BufferUtil
}
started= true;
long d= n / decDivisors[i];
long d= n / decDivisorsL[i];
buffer.put(DIGIT[(int)d]);
n= n - d * decDivisors[i];
n= n - d * decDivisorsL[i];
}
}
}
public static Buffer toBuffer(long value)
{
ByteArrayBuffer buf=new ByteArrayBuffer(16);
ByteArrayBuffer buf=new ByteArrayBuffer(32);
putDecLong(buf, value);
return buf;
}
private final static int[] decDivisors=
{ 1000000000, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1 };
{
1000000000,
100000000,
10000000,
1000000,
100000,
10000,
1000,
100,
10,
1
};
private final static int[] hexDivisors=
{ 0x10000000, 0x1000000, 0x100000, 0x10000, 0x1000, 0x100, 0x10, 1 };
{
0x10000000,
0x1000000,
0x100000,
0x10000,
0x1000,
0x100,
0x10,
0x1
};
private final static long[] decDivisorsL=
{
1000000000000000000L,
100000000000000000L,
10000000000000000L,
1000000000000000L,
100000000000000L,
10000000000000L,
1000000000000L,
100000000000L,
10000000000L,
1000000000L,
100000000L,
10000000L,
1000000L,
100000L,
10000L,
1000L,
100L,
10L,
1L
};
public static void putCRLF(Buffer buffer)

View File

@ -65,12 +65,12 @@ public class BufferUtilTest extends TestCase
{
int val[] =
{
0,42,43,-44,-45,-2147483648,2147483647
0,42,43,-44,-45,Integer.MIN_VALUE,Integer.MAX_VALUE
};
String str[] =
{
"0","42","43","-44","-45","-2147483648","2147483647"
"0","42","43","-44","-45",""+Integer.MIN_VALUE,""+Integer.MAX_VALUE
};
Buffer buffer = new ByteArrayBuffer(12);
@ -83,6 +83,29 @@ public class BufferUtilTest extends TestCase
}
}
public void testPutLong()
throws Exception
{
long val[] =
{
0L,42L,43L,-44L,-45L,Long.MIN_VALUE,Long.MAX_VALUE
};
String str[] =
{
"0","42","43","-44","-45",""+Long.MIN_VALUE,""+Long.MAX_VALUE
};
Buffer buffer = new ByteArrayBuffer(50);
for (int i=0;i<val.length;i++)
{
buffer.clear();
BufferUtil.putDecLong(buffer,val[i]);
assertEquals("t"+i,str[i],BufferUtil.to8859_1_String(buffer));
}
}
public void testPutHexInt()
throws Exception
{