Changeset 35427 in osm for applications/editors/josm/plugins/http2
- Timestamp:
- 2020-04-25T10:01:42+02:00 (5 years ago)
- Location:
- applications/editors/josm/plugins/http2
- Files:
-
- 7 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/http2/src/org/openstreetmap/josm/plugins/http2/Http2Client.java
r35356 r35427 13 13 import java.net.http.HttpResponse; 14 14 import java.net.http.HttpResponse.BodyHandlers; 15 import java.time.DateTimeException; 15 16 import java.time.Duration; 16 17 import java.time.Instant; … … 175 176 @Override 176 177 public long getExpiration() { 177 return response.headers().firstValue("Expires") 178 .map(DateTimeFormatter.RFC_1123_DATE_TIME::parse) 179 .map(t -> 1000L * t.getLong(ChronoField.INSTANT_SECONDS)) 180 .orElse(0L); 178 return parseDate(response.headers().firstValue("Expires").orElse(null)); 181 179 } 182 180 183 181 @Override 184 182 public long getLastModified() { 185 return response.headers().firstValue("Last-Modified") 186 .map(DateTimeFormatter.RFC_1123_DATE_TIME::parse) 187 .map(t -> 1000L * t.getLong(ChronoField.INSTANT_SECONDS)) 188 .orElse(0L); 183 return parseDate(response.headers().firstValue("Last-Modified").orElse(null)); 184 } 185 186 static long parseDate(String string) { 187 if (string != null) { 188 try { 189 return DateTimeFormatter.RFC_1123_DATE_TIME.parse(string).getLong(ChronoField.INSTANT_SECONDS) * 1000L; 190 } catch (DateTimeException e) { 191 Logging.debug(e); 192 } 193 } 194 return 0L; 189 195 } 190 196
Note:
See TracChangeset
for help on using the changeset viewer.