All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.anthavio.httl.marshall.HttlBytesExtractor Maven / Gradle / Ivy

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