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:
parent
937d475839
commit
d95081150b
|
@ -16,6 +16,7 @@ jetty-7.1.0-SNAPSHOT
|
||||||
+ JETTY-903 Stop both caches
|
+ JETTY-903 Stop both caches
|
||||||
+ JETTY-1200 SSL NIO Endpoint wraps non NIO buffers
|
+ JETTY-1200 SSL NIO Endpoint wraps non NIO buffers
|
||||||
+ JETTY-1202 Use platform default algorithm for SecureRandom
|
+ JETTY-1202 Use platform default algorithm for SecureRandom
|
||||||
|
+ JETTY-1212 handle long content lengths
|
||||||
+ Fix jetty-plus.xml reference to addLifeCycle
|
+ Fix jetty-plus.xml reference to addLifeCycle
|
||||||
+ Add AnnotationConfiguration to jetty-plus.xml
|
+ Add AnnotationConfiguration to jetty-plus.xml
|
||||||
+ 310467 Allow SocketConnector to create generic Connection objects
|
+ 310467 Allow SocketConnector to create generic Connection objects
|
||||||
|
|
|
@ -254,9 +254,9 @@ public class BufferUtil
|
||||||
{
|
{
|
||||||
boolean started= false;
|
boolean started= false;
|
||||||
// This assumes constant time int arithmatic
|
// 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)
|
if (started)
|
||||||
buffer.put((byte)'0');
|
buffer.put((byte)'0');
|
||||||
|
@ -264,25 +264,68 @@ public class BufferUtil
|
||||||
}
|
}
|
||||||
|
|
||||||
started= true;
|
started= true;
|
||||||
long d= n / decDivisors[i];
|
long d= n / decDivisorsL[i];
|
||||||
buffer.put(DIGIT[(int)d]);
|
buffer.put(DIGIT[(int)d]);
|
||||||
n= n - d * decDivisors[i];
|
n= n - d * decDivisorsL[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Buffer toBuffer(long value)
|
public static Buffer toBuffer(long value)
|
||||||
{
|
{
|
||||||
ByteArrayBuffer buf=new ByteArrayBuffer(16);
|
ByteArrayBuffer buf=new ByteArrayBuffer(32);
|
||||||
putDecLong(buf, value);
|
putDecLong(buf, value);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static int[] decDivisors=
|
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=
|
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)
|
public static void putCRLF(Buffer buffer)
|
||||||
|
|
|
@ -65,12 +65,12 @@ public class BufferUtilTest extends TestCase
|
||||||
{
|
{
|
||||||
int val[] =
|
int val[] =
|
||||||
{
|
{
|
||||||
0,42,43,-44,-45,-2147483648,2147483647
|
0,42,43,-44,-45,Integer.MIN_VALUE,Integer.MAX_VALUE
|
||||||
};
|
};
|
||||||
|
|
||||||
String str[] =
|
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);
|
Buffer buffer = new ByteArrayBuffer(12);
|
||||||
|
@ -82,6 +82,29 @@ public class BufferUtilTest extends TestCase
|
||||||
assertEquals("t"+i,str[i],BufferUtil.to8859_1_String(buffer));
|
assertEquals("t"+i,str[i],BufferUtil.to8859_1_String(buffer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()
|
public void testPutHexInt()
|
||||||
throws Exception
|
throws Exception
|
||||||
|
|
Loading…
Reference in New Issue