com.github.df.restypass.http.converter.StringResponseConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of resty-pass Show documentation
Show all versions of resty-pass Show documentation
High-Performance Restful Client Library
The newest version!
package com.github.df.restypass.http.converter;
import java.lang.reflect.Type;
/**
* String类型响应的解析类
* Created by darrenfu on 17-7-19.
*/
public class StringResponseConverter implements ResponseConverter {
private static final String TEXT_PLAIN = "text/plain";
@Override
public boolean support(Type type, String contentType) {
if (contentType == null) {
return false;
}
if (!contentType.startsWith(TEXT_PLAIN)) {
return false;
}
if (type instanceof Class && type != String.class) {
return false;
}
return true;
}
@Override
public String convert(byte[] body, Type type, String contentType) {
return new String(body, getCharset(contentType));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy