use of org.springframework.http.converter.StringHttpMessageConverter in project spring-framework by spring-projects.
the class ServletInvocableHandlerMethodTests method wrapConcurrentResult_ResponseBodyEmitter.
@Test
public void wrapConcurrentResult_ResponseBodyEmitter() throws Exception {
List<HttpMessageConverter<?>> converters = new ArrayList<>();
converters.add(new StringHttpMessageConverter());
this.returnValueHandlers.addHandler(new ResponseBodyEmitterReturnValueHandler(converters));
ServletInvocableHandlerMethod handlerMethod = getHandlerMethod(new AsyncHandler(), "handleWithEmitter");
handlerMethod = handlerMethod.wrapConcurrentResult(null);
handlerMethod.invokeAndHandle(this.webRequest, this.mavContainer);
assertEquals(200, this.response.getStatus());
assertEquals("", this.response.getContentAsString());
}
use of org.springframework.http.converter.StringHttpMessageConverter in project java-function-invoker by projectriff.
the class JavaFunctionInvokerConfiguration method textPlainMessageConverter.
/**
* Installs a message converter that supports {@literal text/plain} if the target type
* is assignable from {@literal String}.
*
* <p>
* This departs from the standard converter that is automatically registered, which
* requires that the target type is exactly String (but accepts all content types).
* This is necessary here because the signature of
* {@link JavaFunctionInvokerController#invoke(Object)} accepts {@literal Object}.
* </p>
*/
@Bean
public HttpMessageConverter<?> textPlainMessageConverter() {
StringHttpMessageConverter converter = new StringHttpMessageConverter() {
@Override
public boolean supports(Class<?> clazz) {
return clazz.isAssignableFrom(String.class);
}
};
converter.setSupportedMediaTypes(Arrays.asList(MediaType.TEXT_PLAIN));
return converter;
}
use of org.springframework.http.converter.StringHttpMessageConverter in project apollo by ctripcorp.
the class HttpMessageConverterConfiguration method messageConverters.
@Bean
public HttpMessageConverters messageConverters() {
GsonHttpMessageConverter gsonHttpMessageConverter = new GsonHttpMessageConverter();
gsonHttpMessageConverter.setGson(new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").create());
final List<HttpMessageConverter<?>> converters = Lists.newArrayList(new ByteArrayHttpMessageConverter(), new StringHttpMessageConverter(), new AllEncompassingFormHttpMessageConverter(), gsonHttpMessageConverter);
return new HttpMessageConverters() {
@Override
public List<HttpMessageConverter<?>> getConverters() {
return converters;
}
};
}
use of org.springframework.http.converter.StringHttpMessageConverter in project webofneeds by researchstudio-sat.
the class HttpService method init.
private void init(ClientHttpRequestFactory factory) {
restTemplate = new RestTemplate(factory);
restTemplate.getMessageConverters().add(new StringHttpMessageConverter(Charset.forName("UTF-8")));
jsonHeaders = new HttpHeaders();
jsonHeaders.add("Content-Type", "application/json");
jsonHeaders.add("Accept", "*/*");
}
use of org.springframework.http.converter.StringHttpMessageConverter in project crnk-framework by crnk-project.
the class SpringParameterProvider method getHttpMessageConverters.
private List<HttpMessageConverter<?>> getHttpMessageConverters() {
StringHttpMessageConverter stringHttpMessageConverter = new StringHttpMessageConverter();
// see SPR-7316
stringHttpMessageConverter.setWriteAcceptCharset(false);
List<HttpMessageConverter<?>> converters = new ArrayList<>(4);
converters.add(new ByteArrayHttpMessageConverter());
converters.add(stringHttpMessageConverter);
converters.add(new SourceHttpMessageConverter<>());
converters.add(new AllEncompassingFormHttpMessageConverter());
return converters;
}
Aggregations