Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # HG changeset patch
- # User mbalao
- # Date 1611240728 0
- # Node ID 15862747ee15445292b4b9949b4f0f4badba4812
- # Parent c82c3d65c25617c12cd0d27c4522d15a030d2b2d
- 8257001: Improve Http Client Support
- Reviewed-by: clanger
- diff -r c82c3d65c256 -r 15862747ee15 src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java
- --- a/src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java Tue Mar 02 17:14:31 2021 +0300
- +++ b/src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java Thu Jan 21 14:52:08 2021 +0000
- @@ -121,6 +121,7 @@
- static private final int MAX_CLIENT_STREAM_ID = Integer.MAX_VALUE; // 2147483647
- static private final int MAX_SERVER_STREAM_ID = Integer.MAX_VALUE - 1; // 2147483646
- + static private final int BUFFER = 8; // added as an upper bound
- /**
- * Flag set when no more streams to be opened on this connection.
- @@ -1090,8 +1091,10 @@
- * and CONTINUATION frames from the list and return the List<Http2Frame>.
- */
- private List<HeaderFrame> encodeHeaders(OutgoingHeaders<Stream<?>> frame) {
- + // max value of frame size is clamped by default frame size to avoid OOM
- + int bufferSize = Math.min(Math.max(getMaxSendFrameSize(), 1024), DEFAULT_FRAME_SIZE);
- List<ByteBuffer> buffers = encodeHeadersImpl(
- - getMaxSendFrameSize(),
- + bufferSize,
- frame.getAttachment().getRequestPseudoHeaders(),
- frame.getUserHeaders(),
- frame.getSystemHeaders());
- @@ -1114,9 +1117,9 @@
- // by the sendLock. / (see sendFrame())
- // private final ByteBufferPool headerEncodingPool = new ByteBufferPool();
- - private ByteBuffer getHeaderBuffer(int maxFrameSize) {
- - ByteBuffer buf = ByteBuffer.allocate(maxFrameSize);
- - buf.limit(maxFrameSize);
- + private ByteBuffer getHeaderBuffer(int size) {
- + ByteBuffer buf = ByteBuffer.allocate(size);
- + buf.limit(size);
- return buf;
- }
- @@ -1131,8 +1134,8 @@
- * header field names MUST be converted to lowercase prior to their
- * encoding in HTTP/2...
- */
- - private List<ByteBuffer> encodeHeadersImpl(int maxFrameSize, HttpHeaders... headers) {
- - ByteBuffer buffer = getHeaderBuffer(maxFrameSize);
- + private List<ByteBuffer> encodeHeadersImpl(int bufferSize, HttpHeaders... headers) {
- + ByteBuffer buffer = getHeaderBuffer(bufferSize);
- List<ByteBuffer> buffers = new ArrayList<>();
- for(HttpHeaders header : headers) {
- for (Map.Entry<String, List<String>> e : header.map().entrySet()) {
- @@ -1143,7 +1146,7 @@
- while (!hpackOut.encode(buffer)) {
- buffer.flip();
- buffers.add(buffer);
- - buffer = getHeaderBuffer(maxFrameSize);
- + buffer = getHeaderBuffer(bufferSize);
- }
- }
- }
- @@ -1153,6 +1156,7 @@
- return buffers;
- }
- +
- private List<ByteBuffer> encodeHeaders(OutgoingHeaders<Stream<?>> oh, Stream<?> stream) {
- oh.streamid(stream.streamid);
- if (Log.headers()) {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement