
net.anthavio.httl.marshall.HttlBytesExtractor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hatatitla Show documentation
Show all versions of hatatitla Show documentation
Compact but tweakable REST client library you have been dreaming of
The newest version!
package net.anthavio.httl.marshall;
import java.io.IOException;
import net.anthavio.httl.HttlResponse;
import net.anthavio.httl.HttlResponseExtractor;
import net.anthavio.httl.HttlStatusException;
import net.anthavio.httl.util.HttlUtil;
/**
*
* @author martin.vanek
*
*/
public class HttlBytesExtractor implements HttlResponseExtractor {
private int httpMin;
private int httpMax;
public HttlBytesExtractor(int httpMin, int httpMax) {
this.httpMin = httpMin;
this.httpMax = httpMax;
}
@Override
public byte[] extract(HttlResponse response) throws IOException {
if (response.getHttpStatusCode() > httpMax || response.getHttpStatusCode() < httpMin) {
throw new HttlStatusException(response);
} else {
return HttlUtil.readAsBytes(response);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy