mirror of
https://github.com/danieldemus/openhab-core.git
synced 2026-07-29 12:34:22 +02:00
[rest] special handling for StreamingOutput (#4145)
Signed-off-by: Jörg Sautter <joerg.sautter@gmx.net>
This commit is contained in:
+3
@@ -23,6 +23,7 @@ import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.core.Response.ResponseBuilder;
|
||||
import javax.ws.rs.core.StreamingOutput;
|
||||
import javax.ws.rs.ext.MessageBodyWriter;
|
||||
|
||||
import org.openhab.core.io.rest.JSONInputStream;
|
||||
@@ -81,6 +82,8 @@ public class GsonMessageBodyWriter<T> implements MessageBodyWriter<T> {
|
||||
try {
|
||||
if (object instanceof InputStream stream && object instanceof JSONInputStream) {
|
||||
stream.transferTo(entityStream);
|
||||
} else if (object instanceof StreamingOutput streaming) {
|
||||
streaming.write(entityStream);
|
||||
} else {
|
||||
entityStream.write(gson.toJson(object).getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user