Skip to content

Commit

Permalink
Handle client level header size validation response before sending to…
Browse files Browse the repository at this point in the history
… server
  • Loading branch information
dilanSachi committed Jan 31, 2024
1 parent 9bcc695 commit 8319c73
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function testHttp2ValidHeaderLength() returns error? {
//Tests the behaviour when header size is greater than the configured threshold
// TODO: Enable after fixing this issue : https://github.com/ballerina-platform/ballerina-standard-library/issues/3963
@test:Config {
enable: false
enable: true
}
function testHttp2InvalidHeaderLength() returns error? {
http:Client limitClient = check new ("http://localhost:" + http2RequestLimitsTestPort3.toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;
import io.netty.handler.codec.http.DefaultLastHttpContent;
import io.netty.handler.codec.http.HttpContent;
import io.netty.handler.codec.http.HttpHeaderNames;
Expand Down Expand Up @@ -320,9 +321,13 @@ public static void writeHttp2Headers(ChannelHandlerContext ctx, OutboundMsgHolde
return;
}
}

encoder.writeHeaders(ctx, streamId, http2Headers, dependencyId, weight, false, 0, endStream,
ctx.newPromise());
ChannelPromise promise = ctx.newPromise();
encoder.writeHeaders(ctx, streamId, http2Headers, dependencyId, weight, false, 0, endStream, promise);
promise.addListener((ChannelFutureListener) channelFuture -> {
if (!channelFuture.isSuccess()) {
outboundMsgHolder.getResponseFuture().notifyHttpListener(channelFuture.cause());
}
});
encoder.flowController().writePendingBytes();
ctx.flush();

Expand Down

0 comments on commit 8319c73

Please sign in to comment.