How to fix Findbugs HTTP parameter directly written to HTTP header output

后端 未结 2 961
-上瘾入骨i
-上瘾入骨i 2021-01-05 21:47

I have a class RequestFilter and @Override methods doFilterInternal. And when i add Header for response, findbugs show error HTTP parameter directly written to HTTP header o

2条回答
  •  孤街浪徒
    2021-01-05 22:32

    Watch out if you wan't to set ETag header. ETag looks like W/"myetagvalue"

    String etagHd = request.getHeader(HttpHeaders.ETAG);    
    response.addHeader(HttpHeaders.ETAG,  URLEncoder.encode(etagHd,StandardCharsets.UTF_8.displayName()); 
    

    Will be encoded W%2F%22myetagvalue%22 be carefull !

提交回复
热议问题