Skip to content

Commit 1cf8d00

Browse files
author
Stephane Landelle
committed
Minor changes to AsyncHttpProviderUtils.convertExpireField
* Make public so it can be used to parse Expires headers * compute trimmed unquoted String only once
1 parent 2f6549d commit 1cf8d00

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

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

559-
private static int convertExpireField(String timestring) throws Exception {
559+
public static int convertExpireField(String timestring) throws Exception {
560560
Exception exception = null;
561+
String trimmedTimeString = removeQuote(timestring.trim());
562+
long now = System.currentTimeMillis();
561563
for (SimpleDateFormat sdf : simpleDateFormat.get()) {
562564
try {
563-
long expire = sdf.parse(removeQuote(timestring.trim())).getTime();
564-
return (int) ((expire - System.currentTimeMillis()) / 1000);
565+
long expire = sdf.parse(trimmedTimeString).getTime();
566+
return (int) ((expire - now) / 1000);
565567
} catch (ParseException e) {
566568
exception = e;
567569
} catch (NumberFormatException e) {

0 commit comments

Comments
 (0)