Spiacente se questo è il posto sbagliato per questo.Eccezione lancio lancio a molla su valore If-Modified-Since non valido
Secondo le specifiche HTTP come definito: http://tools.ietf.org/html/rfc7232#section-3.3
Il destinatario deve ignorare il If-Modified-Since campo di intestazione se il ricevuta campo-valore non è un HTTP-data valida, o se la richiesta il metodo non è né GET né HEAD.
Spring Boot non lo fa. Sta lanciando un IllegalArgumentException che non viene gestito dal codice che controlla il valore dell'intestazione.
Ecco il codice di conversione in org.springframework.http.HttpHeaders.java
/**
* Return the value of the {@code If-Modified-Since} header.
* <p>The date is returned as the number of milliseconds since
* January 1, 1970 GMT. Returns -1 when the date is unknown.
*/
public long getIfModifiedSince() {
return getFirstDate(IF_MODIFIED_SINCE);
}
/**
* Parse the first header value for the given header name as a date,
* return -1 if there is no value, or raise {@link IllegalArgumentException}
* if the value cannot be parsed as a date.
*/
public long getFirstDate(String headerName) {
String headerValue = getFirst(headerName);
if (headerValue == null) {
return -1;
}
for (String dateFormat : DATE_FORMATS) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormat, Locale.US);
simpleDateFormat.setTimeZone(GMT);
try {
return simpleDateFormat.parse(headerValue).getTime();
}
catch (ParseException ex) {
// ignore
}
}
throw new IllegalArgumentException("Cannot parse date value \"" + headerValue +
"\" for \"" + headerName + "\" header");
}
Quindi, se si invia l'intestazione If-Modified-Since: 0 si otterrà un'eccezione, invece di restituire il fresco OTTIENI la risposta come definito nella specifica http.
Qualcun altro lo vede come un problema?
La vera domanda è cosa fa un chiamante di questo metodo. Il metodo stesso non può violare le specifiche. – zeroflagL
Mentre hai ragione, perché qualcuno dovrebbe inviare un'intestazione If-Modified-Since non valida? Preferirei risolvere il bug nel client, temo che il springframework non risolvesse immediatamente questo problema. – burna
@zeroflagL - il chiamante non lo gestisce. L'eccezione bolle in alto. – micko