From e48a22780fdcf8e7b7eb1bdfc9cfa39771bfb967 Mon Sep 17 00:00:00 2001 From: Arturo Bernal Date: Sun, 29 Sep 2024 15:13:08 +0200 Subject: [PATCH] avoid using for each loops --- .../src/main/java/org/apache/hc/core5/http/ContentType.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/ContentType.java b/httpcore5/src/main/java/org/apache/hc/core5/http/ContentType.java index ebee29731..a79da1543 100644 --- a/httpcore5/src/main/java/org/apache/hc/core5/http/ContentType.java +++ b/httpcore5/src/main/java/org/apache/hc/core5/http/ContentType.java @@ -334,7 +334,8 @@ public String toString() { if (this.params != null) { buf.append("; "); boolean first = true; - for (final NameValuePair param : params) { + for (int i = 0; i < params.length; i++) { + final NameValuePair param = params[i]; if (!first) { buf.append("; "); } @@ -344,6 +345,7 @@ public String toString() { BasicHeaderValueFormatter.INSTANCE.formatNameValuePair(buf, param, false); first = false; } + } else if (this.charset != null && !implicitCharset) { // Append charset only if it's not one of the types that shouldn't have charset buf.append("; charset=");