MCPcopy Create free account
hub / github.com/apache/tomcat / encodeInteger

Method encodeInteger

java/org/apache/coyote/http2/Hpack.java:204–218  ·  view source on GitHub ↗

Encodes an integer in the HPACK prefix format. This method assumes that the buffer has already had the first 8-n bits filled. As such it will modify the last byte that is already present in the buffer, and potentially add more if required @param source The buffer that contains the integer @par

(ByteBuffer source, int value, int n)

Source from the content-addressed store, hash-verified

202 * @param n The encoding prefix length
203 */
204 static void encodeInteger(ByteBuffer source, int value, int n) {
205 int twoNminus1 = PREFIX_TABLE[n];
206 int pos = source.position() - 1;
207 if (value < twoNminus1) {
208 source.put(pos, (byte) (source.get(pos) | value));
209 } else {
210 source.put(pos, (byte) (source.get(pos) | twoNminus1));
211 value = value - twoNminus1;
212 while (value >= 128) {
213 source.put((byte) (value % 128 + 128));
214 value = value / 128;
215 }
216 source.put((byte) value);
217 }
218 }
219
220 /*
221 * Unused. Will be removed in Tomcat 12 onwards.

Callers 5

encodeMethod · 0.95
encodeMethod · 0.95
writeValueStringMethod · 0.95
handleTableSizeChangeMethod · 0.95

Calls 3

positionMethod · 0.80
putMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected