ok2c commented on code in PR #620:
URL:
https://github.com/apache/httpcomponents-core/pull/620#discussion_r2812136299
##########
httpcore5-h2/src/main/java/org/apache/hc/core5/http2/protocol/H2RequestConformance.java:
##########
@@ -75,18 +75,23 @@ public H2RequestConformance() {
public void process(final HttpRequest request, final EntityDetails entity,
final HttpContext localContext)
throws HttpException, IOException {
Args.notNull(request, "HTTP request");
- for (int i = 0; i < illegalHeaderNames.length; i++) {
- final String headerName = illegalHeaderNames[i];
- final Header header = request.getFirstHeader(headerName);
- if (header != null) {
- if (headerName.equalsIgnoreCase(HttpHeaders.TE)) {
- final String value = header.getValue();
- if (!"trailers".equalsIgnoreCase(value)) {
+
+ for (final String headerName : illegalHeaderNames) {
+ if (HttpHeaders.TE.equalsIgnoreCase(headerName)) {
Review Comment:
@arturobernalg This gets ugly. Use a flag to signal that a TE is present and
move TE parsing out of the for loop. Use `MessageSupport` methods to
efficiently parse list elements.
##########
httpcore5-h2/src/main/java/org/apache/hc/core5/http2/protocol/H2RequestConformance.java:
##########
@@ -75,18 +75,23 @@ public H2RequestConformance() {
public void process(final HttpRequest request, final EntityDetails entity,
final HttpContext localContext)
throws HttpException, IOException {
Args.notNull(request, "HTTP request");
- for (int i = 0; i < illegalHeaderNames.length; i++) {
- final String headerName = illegalHeaderNames[i];
- final Header header = request.getFirstHeader(headerName);
- if (header != null) {
- if (headerName.equalsIgnoreCase(HttpHeaders.TE)) {
- final String value = header.getValue();
- if (!"trailers".equalsIgnoreCase(value)) {
+
+ for (final String headerName : illegalHeaderNames) {
Review Comment:
@arturobernalg enhanced for loop creates an extra iterator, which is
unnecessary Please keep the simple loop.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]