From 78988713b3ab4c721b155d26558e6fda68365954 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Tue, 22 Sep 2020 12:12:38 +0200 Subject: [PATCH] Issue #5304 HTTP2 HostHeader + refixed bug in HttpFields Signed-off-by: Greg Wilkins --- .../src/main/java/org/eclipse/jetty/http/HttpFields.java | 4 +++- .../src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java index 26d20e83ec2b..dbd1eecaa76f 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java @@ -642,7 +642,9 @@ public Mutable add(HttpFields fields) if (fields.size() == 0) return this; - if (_size + fields.size() >= _fields.length) + if (_fields == null) + _fields = new HttpField[fields.size() + 4]; + else if (_size + fields.size() >= _fields.length) _fields = Arrays.copyOf(_fields, _size + fields.size() + 4); if (fields instanceof Immutable) diff --git a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java index f31548e461c4..be2e871d40b1 100644 --- a/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java +++ b/jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java @@ -747,6 +747,9 @@ public void testAddHttpFields() { HttpFields.Mutable fields = HttpFields.build(); fields.add("One", "1"); + + fields = new HttpFields.Mutable(fields); + fields.add(HttpFields.build().add("two", "2").add("three", "3")); fields.add(HttpFields.build().add("four", "4").add("five", "5").asImmutable());