diff --git a/ribbon-core/src/main/java/com/netflix/client/http/HttpUtils.java b/ribbon-core/src/main/java/com/netflix/client/http/HttpUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..540500194418d13a4e58a6ac7587623f437ed54f --- /dev/null +++ b/ribbon-core/src/main/java/com/netflix/client/http/HttpUtils.java @@ -0,0 +1,22 @@ +package com.netflix.client.http; + +import java.io.IOException; + +import com.netflix.serialization.ContentTypeBasedSerializerKey; +import com.netflix.serialization.Deserializer; +import com.netflix.serialization.SerializationFactory; +import com.netflix.serialization.TypeDef; + +public class HttpUtils { + + public static T getEntity(HttpResponse response, TypeDef type, Deserializer deserializer) throws IOException { + return deserializer.deserialize(response.getInputStream(), type); + } + + public static T getEntity(HttpResponse response, TypeDef type, + SerializationFactory serializationFactory) throws IOException { + String contentType = response.getHttpHeaders().getFirst("Content-Type"); + Deserializer deserializer = serializationFactory.getDeserializer(new ContentTypeBasedSerializerKey(contentType, type)); + return deserializer.deserialize(response.getInputStream(), type); + } +}