net.sf.aguacate.connector.spi.ConnectorHttpGet Maven / Gradle / Ivy
package net.sf.aguacate.connector.spi;
import java.io.IOException;
import java.net.URI;
import java.util.Collection;
import java.util.Map;
import net.sf.aguacate.util.codec.bridge.CodecBridge;
import net.sf.aguacate.util.codec.bridge.CodecCoupling;
import net.sf.aguacate.util.http.bridge.HttpCoupling;
public class ConnectorHttpGet extends ConnectorHttp {
public ConnectorHttpGet(String base, String expectedMimeType, Map headers,
Collection parameters) {
super(false, base, expectedMimeType, headers, parameters);
}
@Override
protected CodecBridge getCodecBridge(String mimeType) {
CodecBridge jsonCodec = CodecCoupling.jsonCodecBridge();
if (jsonCodec.support(mimeType)) {
return jsonCodec;
} else {
throw new IllegalArgumentException(mimeType);
}
}
@Override
protected Object execute0(URI uri, Map headers, CodecBridge codec)
throws IOException {
return HttpCoupling.defaultInstance().readFromGet(uri, headers, codec);
}
}