use of org.springframework.http.converter.ByteArrayHttpMessageConverter in project snow-owl by b2ihealthcare.
the class SnowOwlApiConfig method configureMessageConverters.
@Override
public void configureMessageConverters(final List<HttpMessageConverter<?>> converters) {
final StringHttpMessageConverter stringConverter = new StringHttpMessageConverter(Charsets.UTF_8);
stringConverter.setWriteAcceptCharset(false);
converters.add(stringConverter);
converters.add(new ByteArrayHttpMessageConverter());
converters.add(new ResourceHttpMessageConverter());
converters.add(new CsvMessageConverter());
// XXX using null value here as Spring calls a proxied method anyway which returns an already configured instance, see mapping2JacksonHttpMessageConverter Bean method
converters.add(mapping2JacksonHttpMessageConverter(null));
}
use of org.springframework.http.converter.ByteArrayHttpMessageConverter in project littlefisher-system by littlefishercoder.
the class WebSpringMvcConfig method configureMessageConverters.
/**
* Description: 消息转换器配置
*
* @param converters converters
*/
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
MappingJackson2HttpMessageConverter jacksonConverter = new MappingJackson2HttpMessageConverter();
ObjectMapper om = jacksonConverter.getObjectMapper();
om.setDateFormat(new SimpleDateFormat(DateUtil.DATETIME_FORMAT_1));
om.setLocale(Locale.CHINA);
om.setTimeZone(TimeZone.getTimeZone("GMT+8"));
List<MediaType> mediaTypeList = Lists.newArrayList();
mediaTypeList.add(new MediaType(MediaType.APPLICATION_JSON, Charsets.UTF_8));
mediaTypeList.add(new MediaType(MediaType.TEXT_HTML, Charsets.UTF_8));
jacksonConverter.setSupportedMediaTypes(mediaTypeList);
StringHttpMessageConverter stringConverter = new StringHttpMessageConverter(Charsets.UTF_8);
stringConverter.setWriteAcceptCharset(false);
// 保持以下顺序
// "application/json" "application/*+json"
converters.add(jacksonConverter);
// "application/xml" "text/xml" "application/*+xml"
converters.add(new Jaxb2RootElementHttpMessageConverter());
// "application/xml" "text/xml" "application/*+xml"
converters.add(new SourceHttpMessageConverter<>());
// "application/x-www-form-urlencoded" "multipart/form-data"
converters.add(new AllEncompassingFormHttpMessageConverter());
// "application/octet-stream" "*/*"
converters.add(new ByteArrayHttpMessageConverter());
// "text/plain" "*/*"
converters.add(stringConverter);
// "*/*"
converters.add(new ResourceHttpMessageConverter());
}
use of org.springframework.http.converter.ByteArrayHttpMessageConverter in project ma-core-public by infiniteautomation.
the class MangoRestSpringConfiguration method configureMessageConverters.
/**
* Configure the Message Converters for the API for now only JSON
*/
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
converters.add(new ResourceHttpMessageConverter());
converters.add(new MappingJackson2HttpMessageConverter(getObjectMapper()));
converters.add(new CsvMessageConverter());
converters.add(new CsvRowMessageConverter());
converters.add(new CsvQueryArrayStreamMessageConverter());
converters.add(new CsvDataPageQueryStreamMessageConverter());
converters.add(new ByteArrayHttpMessageConverter());
converters.add(new HtmlHttpMessageConverter());
converters.add(new SerotoninJsonMessageConverter());
converters.add(new ExceptionCsvMessageConverter());
// Now is a good time to register our Sero Json Converter
Common.JSON_CONTEXT.addConverter(new AbstractRestModelConverter(), AbstractRestModel.class);
}
use of org.springframework.http.converter.ByteArrayHttpMessageConverter in project syndesis by syndesisio.
the class BaseITCase method setRestTemplate.
@Autowired
public void setRestTemplate(TestRestTemplate testRestTemplate) {
List<HttpMessageConverter<?>> messageConverters = testRestTemplate.getRestTemplate().getMessageConverters();
messageConverters.add(0, new YamlJackson2HttpMessageConverter());
messageConverters.add(0, new JsonJackson2HttpMessageConverter());
messageConverters.add(0, new ByteArrayHttpMessageConverter());
this.restTemplate = testRestTemplate;
}
use of org.springframework.http.converter.ByteArrayHttpMessageConverter in project spring-framework by spring-projects.
the class RequestPartIntegrationTests method standardMultipartResolverWithEncodedFileName.
// SPR-13319
@Test
public void standardMultipartResolverWithEncodedFileName() throws Exception {
String boundaryText = MimeTypeUtils.generateMultipartBoundaryString();
Map<String, String> params = Collections.singletonMap("boundary", boundaryText);
String content = "--" + boundaryText + "\r\n" + "Content-Disposition: form-data; name=\"file\"; filename*=\"utf-8''%C3%A9l%C3%A8ve.txt\"\r\n" + "Content-Type: text/plain\r\n" + "Content-Length: 7\r\n" + "\r\n" + "content\r\n" + "--" + boundaryText + "--";
RequestEntity<byte[]> requestEntity = RequestEntity.post(new URI(baseUrl + "/standard-resolver/spr13319")).contentType(new MediaType(MediaType.MULTIPART_FORM_DATA, params)).body(content.getBytes(StandardCharsets.US_ASCII));
ByteArrayHttpMessageConverter converter = new ByteArrayHttpMessageConverter();
converter.setSupportedMediaTypes(Collections.singletonList(MediaType.MULTIPART_FORM_DATA));
this.restTemplate.setMessageConverters(Collections.singletonList(converter));
ResponseEntity<Void> responseEntity = restTemplate.exchange(requestEntity, Void.class);
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
}
Aggregations