Skip to content

Commit b80589e

Browse files
Stephane Landellejfarcand
Stephane Landelle
authored andcommitted
Minor changes to AsyncHttpProviderUtils.convertExpireField
* Make public so it can be used to parse Expires headers * compute trimmed unquoted String only once
1 parent 4669c7d commit b80589e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/main/java/com/ning/http/util/AsyncHttpProviderUtils.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,12 +500,14 @@ public static Cookie parseCookie(String value) {
500500
return new Cookie(domain, cookieName, cookieValue, path, maxAge, secure);
501501
}
502502

503-
private static int convertExpireField(String timestring) throws Exception {
503+
public static int convertExpireField(String timestring) throws Exception {
504504
Exception exception = null;
505+
String trimmedTimeString = removeQuote(timestring.trim());
506+
long now = System.currentTimeMillis();
505507
for (SimpleDateFormat sdf : simpleDateFormat.get()) {
506508
try {
507-
long expire = sdf.parse(removeQuote(timestring.trim())).getTime();
508-
return (int) ((expire - System.currentTimeMillis()) / 1000);
509+
long expire = sdf.parse(trimmedTimeString).getTime();
510+
return (int) ((expire - now) / 1000);
509511
} catch (ParseException e) {
510512
exception = e;
511513
} catch (NumberFormatException e) {

0 commit comments

Comments
 (0)