I have written a web service and gets the request in form of HttpServletRequest
Object , i then send all the headers for basic validation like checking for Blanks or null etc.
public void validateHeader(HttpServletRequest request)
Enumeration<String> headerNames = request.getHeaderNames();
while (headerNames.hasMoreElements()) {
String key = (String) headerNames.nextElement();
String value = request.getHeader(key);
genericHeaderValidator(key, value);
}
}
As you can see the request.getHeaderNames();
returns Enumeration<String>
.
But in some webservices i want to skip the validation as the above code is written in some other class, i want to keep it intact and want the change to be done at callers side.
For example
if i want to skip validation of header named "content-type" so when i do request.removeAttribute("content-type");
It doesn't remove the header attribute, so i went further and thought to remove it from Enumeration<String> headerNames
But enumeration doesn't allow us to remove any element.
Does anyone has any idea how to remove an element from the header parameters of HttpServletRequest
Object.