use of org.springframework.web.filter.CharacterEncodingFilter in project spring-boot by spring-projects.
the class HttpEncodingAutoConfigurationTests method forceRequestOverridesForce.
@Test
public void forceRequestOverridesForce() throws Exception {
load(EmptyConfiguration.class, "spring.http.encoding.force:true", "spring.http.encoding.force-request:false");
CharacterEncodingFilter filter = this.context.getBean(CharacterEncodingFilter.class);
assertCharacterEncodingFilter(filter, "UTF-8", false, true);
}
use of org.springframework.web.filter.CharacterEncodingFilter in project cas by apereo.
the class CasFiltersConfiguration method characterEncodingFilter.
@RefreshScope
@Bean
public FilterRegistrationBean characterEncodingFilter() {
final FilterRegistrationBean bean = new FilterRegistrationBean();
bean.setFilter(new CharacterEncodingFilter(casProperties.getHttpWebRequest().getWeb().getEncoding(), casProperties.getHttpWebRequest().getWeb().isForceEncoding()));
bean.setUrlPatterns(Collections.singleton("/*"));
bean.setName("characterEncodingFilter");
bean.setAsyncSupported(true);
return bean;
}
use of org.springframework.web.filter.CharacterEncodingFilter in project zipkin by openzipkin.
the class ZipkinUiAutoConfiguration method characterEncodingFilter.
/**
* This opts out of adding charset to png resources.
*
* <p>By default, {@linkplain CharacterEncodingFilter} adds a charset qualifier to all resources,
* which helps, as javascript assets include extended character sets. However, the filter also
* adds charset to well-known binary ones like png. This creates confusing content types, such as
* "image/png;charset=UTF-8".
*
* See https://github.com/spring-projects/spring-boot/issues/5459
*/
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public CharacterEncodingFilter characterEncodingFilter() {
CharacterEncodingFilter filter = new CharacterEncodingFilter() {
@Override
protected boolean shouldNotFilter(HttpServletRequest request) {
return request.getServletPath().endsWith(".png");
}
};
filter.setEncoding("UTF-8");
filter.setForceEncoding(true);
return filter;
}
use of org.springframework.web.filter.CharacterEncodingFilter in project spring-boot by spring-projects.
the class HttpEncodingAutoConfiguration method characterEncodingFilter.
@Bean
@ConditionalOnMissingBean(CharacterEncodingFilter.class)
public CharacterEncodingFilter characterEncodingFilter() {
CharacterEncodingFilter filter = new OrderedCharacterEncodingFilter();
filter.setEncoding(this.properties.getCharset().name());
filter.setForceRequestEncoding(this.properties.shouldForce(Type.REQUEST));
filter.setForceResponseEncoding(this.properties.shouldForce(Type.RESPONSE));
return filter;
}
use of org.springframework.web.filter.CharacterEncodingFilter in project spring-boot by spring-projects.
the class HttpEncodingAutoConfigurationTests method customFilterConfiguration.
@Test
public void customFilterConfiguration() {
load(FilterConfiguration.class, "spring.http.encoding.charset:ISO-8859-15", "spring.http.encoding.force:false");
CharacterEncodingFilter filter = this.context.getBean(CharacterEncodingFilter.class);
assertCharacterEncodingFilter(filter, "US-ASCII", false, false);
}
Aggregations