Skip to content

Commit 5b702ba

Browse files
committed
Save trim copy
1 parent 9d96a18 commit 5b702ba

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/main/java/com/ning/http/client/cookie/CookieDecoder.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
public class CookieDecoder {
2323

2424
private static final Logger LOGGER = LoggerFactory.getLogger(CookieDecoder.class);
25-
25+
2626
/**
2727
* Decodes the specified HTTP header value into {@link Cookie}.
2828
*
@@ -248,8 +248,13 @@ private String computeValue(String header, int valueBegin, int valueEnd) {
248248
if (valueBegin == -1 || valueBegin == valueEnd) {
249249
return null;
250250
} else {
251-
String trimmed = header.substring(valueBegin, valueEnd).trim();
252-
return trimmed.isEmpty() ? null : trimmed;
251+
while (valueBegin < valueEnd && header.charAt(valueBegin) <= ' ') {
252+
valueBegin++;
253+
}
254+
while (valueBegin < valueEnd && (header.charAt(valueEnd - 1) <= ' ')) {
255+
valueEnd--;
256+
}
257+
return valueBegin == valueEnd ? null : header.substring(valueBegin, valueEnd);
253258
}
254259
}
255260
}

0 commit comments

Comments
 (0)