use of cn.taketoday.util.LinkedCaseInsensitiveMap in project today-infrastructure by TAKETODAY.
the class ServletServerHttpRequest method initHeaders.
private static MultiValueMap<String, String> initHeaders(MultiValueMap<String, String> headerValues, HttpServletRequest request) {
HttpHeaders headers = null;
MediaType contentType = null;
if (StringUtils.isEmpty(headerValues.getFirst(HttpHeaders.CONTENT_TYPE))) {
String requestContentType = request.getContentType();
if (StringUtils.isNotEmpty(requestContentType)) {
contentType = MediaType.parseMediaType(requestContentType);
headers = new DefaultHttpHeaders(headerValues);
headers.setContentType(contentType);
}
}
if (contentType != null && contentType.getCharset() == null) {
String encoding = request.getCharacterEncoding();
if (StringUtils.isNotEmpty(encoding)) {
Map<String, String> params = new LinkedCaseInsensitiveMap<>();
params.putAll(contentType.getParameters());
params.put("charset", Charset.forName(encoding).toString());
headers.setContentType(new MediaType(contentType, params));
}
}
if (headerValues.getFirst(HttpHeaders.CONTENT_TYPE) == null) {
int contentLength = request.getContentLength();
if (contentLength != -1) {
headers = (headers != null ? headers : new DefaultHttpHeaders(headerValues));
headers.setContentLength(contentLength);
}
}
return (headers != null ? headers : headerValues);
}
use of cn.taketoday.util.LinkedCaseInsensitiveMap in project today-infrastructure by TAKETODAY.
the class UtilNamespaceHandlerTests method testMapWithTypes.
@Test
public void testMapWithTypes() {
Map map = (Map) this.beanFactory.getBean("mapWithTypes");
boolean condition = map instanceof LinkedCaseInsensitiveMap;
assertThat(condition).isTrue();
assertThat(map.get("bean")).isEqualTo(this.beanFactory.getBean("testBean"));
}
use of cn.taketoday.util.LinkedCaseInsensitiveMap in project today-framework by TAKETODAY.
the class ServletServerHttpRequest method initHeaders.
private static MultiValueMap<String, String> initHeaders(MultiValueMap<String, String> headerValues, HttpServletRequest request) {
HttpHeaders headers = null;
MediaType contentType = null;
if (StringUtils.isEmpty(headerValues.getFirst(HttpHeaders.CONTENT_TYPE))) {
String requestContentType = request.getContentType();
if (StringUtils.isNotEmpty(requestContentType)) {
contentType = MediaType.parseMediaType(requestContentType);
headers = new DefaultHttpHeaders(headerValues);
headers.setContentType(contentType);
}
}
if (contentType != null && contentType.getCharset() == null) {
String encoding = request.getCharacterEncoding();
if (StringUtils.isNotEmpty(encoding)) {
Map<String, String> params = new LinkedCaseInsensitiveMap<>();
params.putAll(contentType.getParameters());
params.put("charset", Charset.forName(encoding).toString());
headers.setContentType(new MediaType(contentType, params));
}
}
if (headerValues.getFirst(HttpHeaders.CONTENT_TYPE) == null) {
int contentLength = request.getContentLength();
if (contentLength != -1) {
headers = (headers != null ? headers : new DefaultHttpHeaders(headerValues));
headers.setContentLength(contentLength);
}
}
return (headers != null ? headers : headerValues);
}
use of cn.taketoday.util.LinkedCaseInsensitiveMap in project today-framework by TAKETODAY.
the class UtilNamespaceHandlerTests method testMapWithTypes.
@Test
public void testMapWithTypes() {
Map map = (Map) this.beanFactory.getBean("mapWithTypes");
boolean condition = map instanceof LinkedCaseInsensitiveMap;
assertThat(condition).isTrue();
assertThat(map.get("bean")).isEqualTo(this.beanFactory.getBean("testBean"));
}
Aggregations