Skip to content

Commit

Permalink
Merge pull request #8691 from eclipse/fix/jetty-12-octect-typo
Browse files Browse the repository at this point in the history
Jetty 12 - Fix typo "octect" -> "octet"
  • Loading branch information
joakime authored Oct 7, 2022
2 parents f9616fe + e6ac065 commit fd8863d
Show file tree
Hide file tree
Showing 15 changed files with 44 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ public static class StaticEntry extends Entry
int huffmanLen = Huffman.octetsNeeded(value);
if (huffmanLen < 0)
throw new IllegalStateException("bad value");
int lenLen = NBitInteger.octectsNeeded(7, huffmanLen);
int lenLen = NBitInteger.octetsNeeded(7, huffmanLen);
_huffmanValue = new byte[1 + lenLen + huffmanLen];
ByteBuffer buffer = ByteBuffer.wrap(_huffmanValue);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public void encode(ByteBuffer buffer, HttpField field)
buffer.put((byte)0x80);
NBitInteger.encode(buffer, 7, index);
if (_debug)
encoding = "IdxField" + (entry.isStatic() ? "S" : "") + (1 + NBitInteger.octectsNeeded(7, index));
encoding = "IdxField" + (entry.isStatic() ? "S" : "") + (1 + NBitInteger.octetsNeeded(7, index));
}
}
else
Expand Down Expand Up @@ -393,7 +393,7 @@ else if (DO_NOT_INDEX.contains(header))

if (_debug)
encoding = "Lit" +
((name == null) ? "HuffN" : ("IdxN" + (name.isStatic() ? "S" : "") + (1 + NBitInteger.octectsNeeded(4, _context.index(name))))) +
((name == null) ? "HuffN" : ("IdxN" + (name.isStatic() ? "S" : "") + (1 + NBitInteger.octetsNeeded(4, _context.index(name))))) +
(huffman ? "HuffV" : "LitV") +
(neverIndex ? "!!Idx" : "!Idx");
}
Expand All @@ -405,7 +405,7 @@ else if (fieldSize >= _context.getMaxDynamicTableSize() || header == HttpHeader.
encodeValue(buffer, true, field.getValue());
if (_debug)
encoding = "Lit" +
((name == null) ? "HuffN" : "IdxNS" + (1 + NBitInteger.octectsNeeded(4, _context.index(name)))) +
((name == null) ? "HuffN" : "IdxNS" + (1 + NBitInteger.octetsNeeded(4, _context.index(name)))) +
"HuffV!Idx";
}
else
Expand All @@ -416,7 +416,7 @@ else if (fieldSize >= _context.getMaxDynamicTableSize() || header == HttpHeader.
encodeName(buffer, (byte)0x40, 6, header.asString(), name);
encodeValue(buffer, huffman, field.getValue());
if (_debug)
encoding = ((name == null) ? "LitHuffN" : ("LitIdxN" + (name.isStatic() ? "S" : "") + (1 + NBitInteger.octectsNeeded(6, _context.index(name))))) +
encoding = ((name == null) ? "LitHuffN" : ("LitIdxN" + (name.isStatic() ? "S" : "") + (1 + NBitInteger.octetsNeeded(6, _context.index(name))))) +
(huffman ? "HuffVIdx" : "LitVIdx");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

public class NBitInteger
{
public static int octectsNeeded(int n, int i)
public static int octetsNeeded(int n, int i)
{
if (n == 8)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ public class NBitIntegerTest
@Test
public void testOctetsNeeded()
{
assertEquals(0, NBitInteger.octectsNeeded(5, 10));
assertEquals(2, NBitInteger.octectsNeeded(5, 1337));
assertEquals(1, NBitInteger.octectsNeeded(8, 42));
assertEquals(3, NBitInteger.octectsNeeded(8, 1337));

assertEquals(0, NBitInteger.octectsNeeded(6, 62));
assertEquals(1, NBitInteger.octectsNeeded(6, 63));
assertEquals(1, NBitInteger.octectsNeeded(6, 64));
assertEquals(2, NBitInteger.octectsNeeded(6, 63 + 0x00 + 0x80 * 0x01));
assertEquals(3, NBitInteger.octectsNeeded(6, 63 + 0x00 + 0x80 * 0x80));
assertEquals(4, NBitInteger.octectsNeeded(6, 63 + 0x00 + 0x80 * 0x80 * 0x80));
assertEquals(0, NBitInteger.octetsNeeded(5, 10));
assertEquals(2, NBitInteger.octetsNeeded(5, 1337));
assertEquals(1, NBitInteger.octetsNeeded(8, 42));
assertEquals(3, NBitInteger.octetsNeeded(8, 1337));

assertEquals(0, NBitInteger.octetsNeeded(6, 62));
assertEquals(1, NBitInteger.octetsNeeded(6, 63));
assertEquals(1, NBitInteger.octetsNeeded(6, 64));
assertEquals(2, NBitInteger.octetsNeeded(6, 63 + 0x00 + 0x80 * 0x01));
assertEquals(3, NBitInteger.octetsNeeded(6, 63 + 0x00 + 0x80 * 0x80));
assertEquals(4, NBitInteger.octetsNeeded(6, 63 + 0x00 + 0x80 * 0x80 * 0x80));
}

@Test
Expand Down Expand Up @@ -84,7 +84,7 @@ public void testEncode(int n, int i, String expected)
String r = StringUtil.toHexString(BufferUtil.toArray(buf));
assertEquals(expected, r);

assertEquals(expected.length() / 2, (n < 8 ? 1 : 0) + NBitInteger.octectsNeeded(n, i));
assertEquals(expected.length() / 2, (n < 8 ? 1 : 0) + NBitInteger.octetsNeeded(n, i));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,19 @@ public int getRequiredSize(int base)
{
// Indexed Field Line with Static Reference.
int relativeIndex = _entry.getIndex();
return 1 + NBitIntegerEncoder.octectsNeeded(6, relativeIndex);
return 1 + NBitIntegerEncoder.octetsNeeded(6, relativeIndex);
}
else if (_entry.getIndex() < base)
{
// Indexed Field Line with Dynamic Reference.
int relativeIndex = base - (_entry.getIndex() + 1);
return 1 + NBitIntegerEncoder.octectsNeeded(6, relativeIndex);
return 1 + NBitIntegerEncoder.octetsNeeded(6, relativeIndex);
}
else
{
// Indexed Field Line with Post-Base Index.
int relativeIndex = _entry.getIndex() - base;
return 1 + NBitIntegerEncoder.octectsNeeded(4, relativeIndex);
return 1 + NBitIntegerEncoder.octetsNeeded(4, relativeIndex);
}
}

Expand Down Expand Up @@ -183,7 +183,7 @@ public int getRequiredSize(int base)
String value = getValue();
int relativeIndex = _nameEntry.getIndex() - base;
int valueLength = _huffman ? HuffmanEncoder.octetsNeeded(value) : value.length();
return 1 + NBitIntegerEncoder.octectsNeeded(4, relativeIndex) + 1 + NBitIntegerEncoder.octectsNeeded(7, valueLength) + valueLength;
return 1 + NBitIntegerEncoder.octetsNeeded(4, relativeIndex) + 1 + NBitIntegerEncoder.octetsNeeded(7, valueLength) + valueLength;
}

@Override
Expand Down Expand Up @@ -246,7 +246,7 @@ public int getRequiredSize(int base)
String value = getValue();
int nameLength = _huffman ? HuffmanEncoder.octetsNeeded(name) : name.length();
int valueLength = _huffman ? HuffmanEncoder.octetsNeeded(value) : value.length();
return 2 + NBitIntegerEncoder.octectsNeeded(3, nameLength) + nameLength + NBitIntegerEncoder.octectsNeeded(7, valueLength) + valueLength;
return 2 + NBitIntegerEncoder.octetsNeeded(3, nameLength) + nameLength + NBitIntegerEncoder.octetsNeeded(7, valueLength) + valueLength;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public int getIndex()
@Override
public void encode(ByteBufferPool.Lease lease)
{
int size = NBitIntegerEncoder.octectsNeeded(5, _index) + 1;
int size = NBitIntegerEncoder.octetsNeeded(5, _index) + 1;
ByteBuffer buffer = lease.acquire(size, false);
buffer.put((byte)0x00);
NBitIntegerEncoder.encode(buffer, 5, _index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public String getValue()
@Override
public void encode(ByteBufferPool.Lease lease)
{
int size = NBitIntegerEncoder.octectsNeeded(6, _index) + (_huffman ? HuffmanEncoder.octetsNeeded(_value) : _value.length()) + 2;
int size = NBitIntegerEncoder.octetsNeeded(6, _index) + (_huffman ? HuffmanEncoder.octetsNeeded(_value) : _value.length()) + 2;
ByteBuffer buffer = lease.acquire(size, false);

// First bit indicates the instruction, second bit is whether it is a dynamic table reference or not.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public int getIncrement()
@Override
public void encode(ByteBufferPool.Lease lease)
{
int size = NBitIntegerEncoder.octectsNeeded(6, _increment) + 1;
int size = NBitIntegerEncoder.octetsNeeded(6, _increment) + 1;
ByteBuffer buffer = lease.acquire(size, false);
buffer.put((byte)0x00);
NBitIntegerEncoder.encode(buffer, 6, _increment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public long getStreamId()
@Override
public void encode(ByteBufferPool.Lease lease)
{
int size = NBitIntegerEncoder.octectsNeeded(7, _streamId) + 1;
int size = NBitIntegerEncoder.octetsNeeded(7, _streamId) + 1;
ByteBuffer buffer = lease.acquire(size, false);
buffer.put((byte)0x80);
NBitIntegerEncoder.encode(buffer, 7, _streamId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public int getCapacity()
@Override
public void encode(ByteBufferPool.Lease lease)
{
int size = NBitIntegerEncoder.octectsNeeded(5, _capacity) + 1;
int size = NBitIntegerEncoder.octetsNeeded(5, _capacity) + 1;
ByteBuffer buffer = lease.acquire(size, false);
buffer.put((byte)0x20);
NBitIntegerEncoder.encode(buffer, 5, _capacity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public StreamCancellationInstruction(long streamId)
@Override
public void encode(ByteBufferPool.Lease lease)
{
int size = NBitIntegerEncoder.octectsNeeded(6, _streamId) + 1;
int size = NBitIntegerEncoder.octetsNeeded(6, _streamId) + 1;
ByteBuffer buffer = lease.acquire(size, false);
buffer.put((byte)0x40);
NBitIntegerEncoder.encode(buffer, 6, _streamId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public static class StaticEntry extends Entry
int huffmanLen = HuffmanEncoder.octetsNeeded(value);
if (huffmanLen < 0)
throw new IllegalStateException("bad value");
int lenLen = NBitIntegerEncoder.octectsNeeded(7, huffmanLen);
int lenLen = NBitIntegerEncoder.octetsNeeded(7, huffmanLen);
_huffmanValue = new byte[1 + lenLen + huffmanLen];
ByteBuffer buffer = ByteBuffer.wrap(_huffmanValue);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

public class NBitIntegerEncoder
{
public static int octectsNeeded(int n, long i)
public static int octetsNeeded(int n, long i)
{
if (n == 8)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ public class NBitIntegerTest
@Test
public void testOctetsNeeded()
{
assertEquals(0, NBitIntegerEncoder.octectsNeeded(5, 10));
assertEquals(2, NBitIntegerEncoder.octectsNeeded(5, 1337));
assertEquals(1, NBitIntegerEncoder.octectsNeeded(8, 42));
assertEquals(3, NBitIntegerEncoder.octectsNeeded(8, 1337));

assertEquals(0, NBitIntegerEncoder.octectsNeeded(6, 62));
assertEquals(1, NBitIntegerEncoder.octectsNeeded(6, 63));
assertEquals(1, NBitIntegerEncoder.octectsNeeded(6, 64));
assertEquals(2, NBitIntegerEncoder.octectsNeeded(6, 63 + 0x00 + 0x80 * 0x01));
assertEquals(3, NBitIntegerEncoder.octectsNeeded(6, 63 + 0x00 + 0x80 * 0x80));
assertEquals(4, NBitIntegerEncoder.octectsNeeded(6, 63 + 0x00 + 0x80 * 0x80 * 0x80));
assertEquals(0, NBitIntegerEncoder.octetsNeeded(5, 10));
assertEquals(2, NBitIntegerEncoder.octetsNeeded(5, 1337));
assertEquals(1, NBitIntegerEncoder.octetsNeeded(8, 42));
assertEquals(3, NBitIntegerEncoder.octetsNeeded(8, 1337));

assertEquals(0, NBitIntegerEncoder.octetsNeeded(6, 62));
assertEquals(1, NBitIntegerEncoder.octetsNeeded(6, 63));
assertEquals(1, NBitIntegerEncoder.octetsNeeded(6, 64));
assertEquals(2, NBitIntegerEncoder.octetsNeeded(6, 63 + 0x00 + 0x80 * 0x01));
assertEquals(3, NBitIntegerEncoder.octetsNeeded(6, 63 + 0x00 + 0x80 * 0x80));
assertEquals(4, NBitIntegerEncoder.octetsNeeded(6, 63 + 0x00 + 0x80 * 0x80 * 0x80));
}

@Test
Expand Down Expand Up @@ -87,7 +87,7 @@ public void testEncode(int n, int i, String expected)
String r = TypeUtil.toHexString(BufferUtil.toArray(buf));
assertEquals(expected, r);

assertEquals(expected.length() / 2, (n < 8 ? 1 : 0) + NBitIntegerEncoder.octectsNeeded(n, i));
assertEquals(expected.length() / 2, (n < 8 ? 1 : 0) + NBitIntegerEncoder.octetsNeeded(n, i));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public void run()
out.write("POST / HTTP/1.1\r\n".getBytes());
out.write("Host: localhost\r\n".getBytes());
out.write(("Content-Length: " + contentSize + "\r\n").getBytes());
out.write("Content-Type: application/octect-stream\r\n".getBytes());
out.write("Content-Type: application/octet-stream\r\n".getBytes());
if (closeConnection)
out.write("Connection: close\r\n".getBytes());
out.write("\r\n".getBytes());
Expand Down

0 comments on commit fd8863d

Please sign in to comment.