use of cn.taketoday.http.DefaultHttpHeaders in project today-framework by TAKETODAY.
the class AbstractMultipart method createHttpHeaders.
protected HttpHeaders createHttpHeaders() {
DefaultHttpHeaders headers = HttpHeaders.create();
headers.set(HttpHeaders.CONTENT_TYPE, getContentType());
return headers;
}
use of cn.taketoday.http.DefaultHttpHeaders 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.http.DefaultHttpHeaders in project today-framework by TAKETODAY.
the class MockMultipartFile method createHttpHeaders.
protected DefaultHttpHeaders createHttpHeaders() {
DefaultHttpHeaders headers = HttpHeaders.create();
headers.set(HttpHeaders.CONTENT_TYPE, getContentType());
return headers;
}
use of cn.taketoday.http.DefaultHttpHeaders in project today-framework by TAKETODAY.
the class MockMultipartFile method createHttpHeaders.
protected DefaultHttpHeaders createHttpHeaders() {
DefaultHttpHeaders headers = HttpHeaders.create();
headers.set(HttpHeaders.CONTENT_TYPE, getContentType());
return headers;
}
use of cn.taketoday.http.DefaultHttpHeaders in project today-infrastructure by TAKETODAY.
the class AbstractMultipartFile method createHttpHeaders.
protected DefaultHttpHeaders createHttpHeaders() {
DefaultHttpHeaders headers = HttpHeaders.create();
headers.set(HttpHeaders.CONTENT_TYPE, getContentType());
return headers;
}
Aggregations