Merged branch 'jetty-9.4.x' into 'jetty-10.0.x'.

This commit is contained in:
Simone Bordet 2020-08-13 18:31:34 +02:00
commit 45682c2088
2 changed files with 9 additions and 8 deletions

View File

@ -796,7 +796,7 @@ public interface HttpFields extends Iterable<HttpField>
{
if (_size == 0)
throw new IllegalStateException();
Mutable.this.remove(_index - 1);
Mutable.this.remove(--_index);
}
};
}
@ -1059,7 +1059,7 @@ public interface HttpFields extends Iterable<HttpField>
}
// Remember and remove additional fields
found.add(f);
remove(i);
remove(i--);
}
}
@ -1088,7 +1088,7 @@ public interface HttpFields extends Iterable<HttpField>
{
HttpField f = _fields[i];
if (f.getHeader() == name)
remove(i);
remove(i--);
}
return this;
}
@ -1099,7 +1099,7 @@ public interface HttpFields extends Iterable<HttpField>
{
HttpField f = _fields[i];
if (fields.contains(f.getHeader()))
remove(i);
remove(i--);
}
return this;
}
@ -1116,7 +1116,7 @@ public interface HttpFields extends Iterable<HttpField>
{
HttpField f = _fields[i];
if (f.is(name))
remove(i);
remove(i--);
}
return this;
}

View File

@ -912,11 +912,12 @@ public class HttpFieldsTest
fields.add(new HttpField("After", "value"));
assertThat(fields.stream().map(HttpField::toString).collect(Collectors.toList()), contains("Before: value", "Test: one", "After: value"));
fields.add(new HttpField("Test", "extra"));
assertThat(fields.stream().map(HttpField::toString).collect(Collectors.toList()), contains("Before: value", "Test: one", "After: value", "Test: extra"));
fields.add(new HttpField("Test", "two"));
fields.add(new HttpField("Test", "three"));
assertThat(fields.stream().map(HttpField::toString).collect(Collectors.toList()), contains("Before: value", "Test: one", "After: value", "Test: two", "Test: three"));
fields.computeField("Test", (n, f) -> new HttpField("TEST", "count=" + f.size()));
assertThat(fields.stream().map(HttpField::toString).collect(Collectors.toList()), contains("Before: value", "TEST: count=2", "After: value"));
assertThat(fields.stream().map(HttpField::toString).collect(Collectors.toList()), contains("Before: value", "TEST: count=3", "After: value"));
fields.computeField("TEST", (n, f) -> null);
assertThat(fields.stream().map(HttpField::toString).collect(Collectors.toList()), contains("Before: value", "After: value"));