Síguenos en: icono twitter icono facebook

 

Solución al error 500 de enviar cabecera HTTP "If-Modified-Since" mal formada

La versiones anteriores a la 7.0.4 están afectadas por este error.

El se produce al enviarle a Opemcms una petición HTTP en cuya cabecera el campo If-Modified-Since no se encuntre en formato espeficicado por http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html, como por ejemplo realizan las BlackBerrys y algunos dispositivos móviles.

La clase afectada por este error se trata de org.opencms.flex.CmsFlexController en el método isNotModifiedSince(HttpServletRequest req, long dateLastModified)

Para solucionar el error, sobrescribimos el método, y volvemos a colocar la clase dentro de la libreria opencms.jar.

http://cvs.opencms.org/viewvc.cgi/opencms/src/org/opencms/flex/CmsFlexController.java?r1=1.40&r2=1.41
 

public static boolean isNotModifiedSince(HttpServletRequest req, long dateLastModified) {
 
	// check if the request contains a last modified header
	long lastModifiedHeader = req.getDateHeader(CmsRequestUtil.HEADER_IF_MODIFIED_SINCE);
	// if last modified header is set (> -1), compare it to the requested resource                           
	return ((lastModifiedHeader > -1) && (((dateLastModified / 1000) * 1000) == lastModifiedHeader));
	try {
		long lastModifiedHeader = req.getDateHeader(CmsRequestUtil.HEADER_IF_MODIFIED_SINCE);
		// if last modified header is set (> -1), compare it to the requested resource                           
		return ((lastModifiedHeader > -1) && (((dateLastModified / 1000) * 1000) == lastModifiedHeader));
	} catch (Exception ex) {
		// some clients (e.g. User-Agent: BlackBerry7290/4.1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/111)
		// send an invalid "If-Modified-Since" header (e.g. in german locale) 
		// which breaks with http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html
		// this has to be caught because the subsequent request for the 500 error handler 
		// would run into the same exception. 
		LOG.warn(Messages.get().getBundle().key(
		Messages.ERR_HEADER_IFMODIFIEDSINCE_FORMAT_3,
		new Object[] {
			CmsRequestUtil.HEADER_IF_MODIFIED_SINCE,
			req.getHeader(CmsRequestUtil.HEADER_USER_AGENT),
			req.getHeader(CmsRequestUtil.HEADER_IF_MODIFIED_SINCE)}));
	}
	return false;
}

Enlaces de interés

Fernando Rivas

© OpenCms Hispano - Powered by OpenCms 7.5.2 & Template Saga
logo template Saga