Search in sources :

Example 6 with DefaultHttpHeaders

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;
}
Also used : DefaultHttpHeaders(cn.taketoday.http.DefaultHttpHeaders)

Example 7 with DefaultHttpHeaders

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);
}
Also used : HttpHeaders(cn.taketoday.http.HttpHeaders) DefaultHttpHeaders(cn.taketoday.http.DefaultHttpHeaders) LinkedCaseInsensitiveMap(cn.taketoday.util.LinkedCaseInsensitiveMap) DefaultHttpHeaders(cn.taketoday.http.DefaultHttpHeaders) MediaType(cn.taketoday.http.MediaType)

Example 8 with DefaultHttpHeaders

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;
}
Also used : DefaultHttpHeaders(cn.taketoday.http.DefaultHttpHeaders)

Example 9 with DefaultHttpHeaders

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;
}
Also used : DefaultHttpHeaders(cn.taketoday.http.DefaultHttpHeaders)

Example 10 with DefaultHttpHeaders

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;
}
Also used : DefaultHttpHeaders(cn.taketoday.http.DefaultHttpHeaders)

Aggregations

DefaultHttpHeaders (cn.taketoday.http.DefaultHttpHeaders)12 HttpHeaders (cn.taketoday.http.HttpHeaders)2 MediaType (cn.taketoday.http.MediaType)2 LinkedCaseInsensitiveMap (cn.taketoday.util.LinkedCaseInsensitiveMap)2 IOException (java.io.IOException)1