Я хочу получить пользовательский заголовок Дата в моем приложении. Ниже мой код
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable().authorizeRequests().antMatchers(HttpMethod.POST, "/data/**").authenticated().and()
.addFilterBefore(authenticationFilter, UsernamePasswordAuthenticationFilter.class)
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
}
Код для получения заголовка
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
Enumeration<String> ss = request.getHeaderNames();
while (ss.hasMoreElements()) {
String string = (String) ss.nextElement();
System.out.println(string);
}
System.out.println(request.getDateHeader("date"));
}
Выход:
host
connection
content-length
accept
origin
x-requested-with
user-agent
content-type
referer
accept-encoding
accept-language
cookie
-1
Запрос:
curl -X POST --header 'Content-Type: multipart/form-data' --header 'Accept: application/json' --header 'Date: Mon, 07 Jan 2019 13:46:52 GMT' {"type":"formData"} 'http://localhost:8080/data'
Я хочу получить заголовок даты, который я передаю, но не получил его. Что блокирует дополнительный заголовок?