arturobernalg commented on PR #620:
URL: 
https://github.com/apache/httpcomponents-core/pull/620#issuecomment-3914971957

   > @arturobernalg I would rewrite it as
   > 
   > ```
   >     @Override
   >     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];
   >             if (request.containsHeader(headerName)) {
   >                 if (HttpHeaders.TE.equalsIgnoreCase(headerName)) {
   >                     validateTE(request);
   >                 } else {
   >                     throw new ProtocolException("Header '%s' is illegal 
for HTTP/2 messages", headerName);
   >                 }
   >             }
   >         }
   >     }
   > 
   >     private static void validateTE(final HttpRequest request) throws 
ProtocolException {
   >         boolean sawAnyToken = false;
   >         boolean sawInvalidToken = false;
   >         for (final Iterator<String> it = 
MessageSupport.iterateTokens(request, HttpHeaders.TE); it.hasNext(); ) {
   >             final String token = it.next();
   >             sawAnyToken = true;
   >             if (!"trailers".equalsIgnoreCase(token)) {
   >                 sawInvalidToken = true;
   >                 break;
   >             }
   >         }
   >         if (sawInvalidToken || !sawAnyToken) {
   >             throw new ProtocolException("Header '%s' is illegal for HTTP/2 
messages", HttpHeaders.TE);
   >         }
   >     }
   > ```
   
   @ok2c  All right. I made the change


-- 
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]

Reply via email to