mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
set some http headers in the response (fix #251)
This commit is contained in:
34
src/main/java/com/commafeed/frontend/rest/JsonProvider.java
Normal file
34
src/main/java/com/commafeed/frontend/rest/JsonProvider.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package com.commafeed.frontend.rest;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.ext.Provider;
|
||||
|
||||
import org.apache.http.HttpHeaders;
|
||||
|
||||
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
|
||||
|
||||
@Provider
|
||||
public class JsonProvider extends JacksonJsonProvider {
|
||||
|
||||
@Override
|
||||
public void writeTo(Object value, Class<?> type, Type genericType,
|
||||
Annotation[] annotations, MediaType mediaType,
|
||||
MultivaluedMap<String, Object> httpHeaders,
|
||||
OutputStream entityStream) throws IOException {
|
||||
|
||||
httpHeaders.putSingle(HttpHeaders.CONTENT_TYPE, mediaType.toString()
|
||||
+ ";charset=UTF-8");
|
||||
httpHeaders.putSingle(HttpHeaders.CACHE_CONTROL, "no-cache");
|
||||
httpHeaders.putSingle(HttpHeaders.PRAGMA, "no-cache");
|
||||
|
||||
super.writeTo(value, type, genericType, annotations, mediaType,
|
||||
httpHeaders, entityStream);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user