try {
getMethod = srcHelper.executeRequest(wmsUrl, requestParams, backendTimeout);
if (getMethod.getStatusCode() != 200) {
throw new GeoWebCacheException("Received response code "
+ getMethod.getStatusCode() + "\n");
}
if (!getMethod.getResponseHeader("Content-Type").getValue().startsWith("image/")) {
throw new GeoWebCacheException("Unexpected response content type "
+ getMethod.getResponseHeader("Content-Type").getValue()
+ " , request was " + urlStr + "\n");
}
byte[] ret = ServletUtils.readStream(getMethod.getResponseBodyAsStream(), 16384, 2048);
InputStream is = new ByteArrayInputStream(ret);
img = ImageIO.read(is);
} finally {
if (getMethod != null) {
getMethod.releaseConnection();
}
}
if (img.getWidth() != widthHeight[0] || img.getHeight() != widthHeight[1]) {
String msg = "WMS raster filter has dimensions " + img.getWidth() + ","
+ img.getHeight() + ", expected " + widthHeight[0] + "," + widthHeight[1]
+ "\n";
throw new GeoWebCacheException(msg);
}
return img;
}