this.headers.add(headerName, headerValue);
}
}
// HttpServletRequest exposes some headers as properties: we should include those if not already present
if (this.headers.getContentType() == null && this.servletRequest.getContentType() != null) {
MediaType contentType = MediaType.parseMediaType(this.servletRequest.getContentType());
this.headers.setContentType(contentType);
}
if (this.headers.getContentType() != null && this.headers.getContentType().getCharSet() == null &&
this.servletRequest.getCharacterEncoding() != null) {
MediaType oldContentType = this.headers.getContentType();
Charset charSet = Charset.forName(this.servletRequest.getCharacterEncoding());
Map<String, String> params = new HashMap<String, String>(oldContentType.getParameters());
params.put("charset", charSet.toString());
MediaType newContentType = new MediaType(oldContentType.getType(), oldContentType.getSubtype(), params);
this.headers.setContentType(newContentType);
}
if (this.headers.getContentLength() == -1 && this.servletRequest.getContentLength() != -1) {
this.headers.setContentLength(this.servletRequest.getContentLength());
}