Skip to content

Commit

Permalink
Add an async parser for HTTP/2. Will continue improving it. Although …
Browse files Browse the repository at this point in the history
…it looks rather scary for GC, it actually seems to perform "ok" with h2load.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1823578 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
rmaucher committed Feb 8, 2018
1 parent fd97b37 commit 3f7fad6
Show file tree
Hide file tree
Showing 6 changed files with 669 additions and 15 deletions.
19 changes: 19 additions & 0 deletions java/org/apache/coyote/http2/ByteUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.coyote.http2;

import java.nio.ByteBuffer;

/**
* Utility class for extracting values from byte arrays.
*/
Expand All @@ -37,6 +39,12 @@ static int get31Bits(byte[] input, int firstByte) {
}


static int get31Bits(ByteBuffer input, int firstByte) {
return ((input.get(firstByte) & 0x7F) << 24) + ((input.get(firstByte + 1) & 0xFF) << 16) +
((input.get(firstByte + 2) & 0xFF) << 8) + (input.get(firstByte + 3) & 0xFF);
}


static void set31Bits(byte[] output, int firstByte, int value) {
output[firstByte] = (byte) ((value & 0x7F000000) >> 24);
output[firstByte + 1] = (byte) ((value & 0xFF0000) >> 16);
Expand All @@ -50,6 +58,11 @@ static int getOneByte(byte[] input, int pos) {
}


static int getOneByte(ByteBuffer input, int pos) {
return (input.get(pos) & 0xFF);
}


static int getTwoBytes(byte[] input, int firstByte) {
return ((input[firstByte] & 0xFF) << 8) + (input[firstByte + 1] & 0xFF);
}
Expand All @@ -61,6 +74,12 @@ static int getThreeBytes(byte[] input, int firstByte) {
}


static int getThreeBytes(ByteBuffer input, int firstByte) {
return ((input.get(firstByte) & 0xFF) << 16) + ((input.get(firstByte + 1) & 0xFF) << 8) +
(input.get(firstByte + 2) & 0xFF);
}


static void setTwoBytes(byte[] output, int firstByte, int value) {
output[firstByte] = (byte) ((value & 0xFF00) >> 8);
output[firstByte + 1] = (byte) (value & 0xFF);
Expand Down
Loading

0 comments on commit 3f7fad6

Please sign in to comment.