use of org.springframework.http.HttpHeaders in project spring-boot-admin by codecentric.
the class LetsChatNotifierTest method expectedMessage.
private HttpEntity<?> expectedMessage(String message) {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
String auth = Base64Utils.encodeToString(String.format("%s:%s", token, user).getBytes());
httpHeaders.add(HttpHeaders.AUTHORIZATION, String.format("Basic %s", auth));
Map<String, Object> messageJson = new HashMap<>();
messageJson.put("text", message);
return new HttpEntity<>(messageJson, httpHeaders);
}
use of org.springframework.http.HttpHeaders in project spring-boot-admin by codecentric.
the class HipchatNotifier method createHipChatNotification.
protected HttpEntity<Map<String, Object>> createHipChatNotification(ClientApplicationEvent event) {
Map<String, Object> body = new HashMap<>();
body.put("color", getColor(event));
body.put("message", getMessage(event));
body.put("notify", getNotify());
body.put("message_format", "html");
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
return new HttpEntity<>(body, headers);
}
use of org.springframework.http.HttpHeaders in project fastjson by alibaba.
the class FastJsonHttpMessageConverter method write.
/*
* @see org.springframework.http.converter.GenericHttpMessageConverter#write(java.lang.Object, java.lang.reflect.Type, org.springframework.http.MediaType, org.springframework.http.HttpOutputMessage)
*/
public //
void write(//
Object t, //
Type type, //
MediaType contentType, //
HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
HttpHeaders headers = outputMessage.getHeaders();
if (headers.getContentType() == null) {
if (contentType == null || contentType.isWildcardType() || contentType.isWildcardSubtype()) {
contentType = getDefaultContentType(t);
}
if (contentType != null) {
headers.setContentType(contentType);
}
}
if (headers.getContentLength() == -1) {
Long contentLength = getContentLength(t, headers.getContentType());
if (contentLength != null) {
headers.setContentLength(contentLength);
}
}
writeInternal(t, outputMessage);
outputMessage.getBody().flush();
}
use of org.springframework.http.HttpHeaders in project fastjson by alibaba.
the class FastJsonHttpMessageConverter4 method writeInternal.
@Override
protected //
void writeInternal(//
Object obj, //
Type type, //
HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
HttpHeaders headers = outputMessage.getHeaders();
ByteArrayOutputStream outnew = new ByteArrayOutputStream();
int len = //
JSON.writeJSONString(//
outnew, //
fastJsonConfig.getCharset(), //
obj, //
fastJsonConfig.getSerializeConfig(), //
fastJsonConfig.getSerializeFilters(), //
fastJsonConfig.getDateFormat(), //
JSON.DEFAULT_GENERATE_FEATURE, fastJsonConfig.getSerializerFeatures());
if (fastJsonConfig.isWriteContentLength()) {
headers.setContentLength(len);
}
OutputStream out = outputMessage.getBody();
outnew.writeTo(out);
outnew.close();
}
use of org.springframework.http.HttpHeaders in project fastjson by alibaba.
the class FastJsonpHttpMessageConverter4 method writeInternal.
@Override
protected void writeInternal(Object obj, Type type, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
HttpHeaders headers = outputMessage.getHeaders();
ByteArrayOutputStream outnew = new ByteArrayOutputStream();
int len = writePrefix(outnew, obj);
Object value = obj;
if (obj instanceof MappingFastJsonValue) {
MappingFastJsonValue container = (MappingFastJsonValue) obj;
value = container.getValue();
}
len += //
JSON.writeJSONString(//
outnew, //
fastJsonConfig.getCharset(), //
value, //
fastJsonConfig.getSerializeConfig(), //
fastJsonConfig.getSerializeFilters(), //
fastJsonConfig.getDateFormat(), //
JSON.DEFAULT_GENERATE_FEATURE, fastJsonConfig.getSerializerFeatures());
len += writeSuffix(outnew, obj);
if (fastJsonConfig.isWriteContentLength()) {
headers.setContentLength(len);
}
OutputStream out = outputMessage.getBody();
outnew.writeTo(out);
outnew.close();
}
Aggregations