|
@@ -23,6 +23,7 @@ import java.io.InputStream;
|
|
|
import java.io.OutputStream;
|
|
|
import java.net.MalformedURLException;
|
|
|
import java.net.URL;
|
|
|
+import java.net.HttpURLConnection;
|
|
|
import java.net.URLConnection;
|
|
|
import java.util.HashSet;
|
|
|
import java.util.List;
|
|
@@ -204,7 +205,7 @@ class Fetcher<K,V> extends Thread {
|
|
|
|
|
|
try {
|
|
|
URL url = getMapOutputURL(host, maps);
|
|
|
- URLConnection connection = url.openConnection();
|
|
|
+ HttpURLConnection connection = (HttpURLConnection)url.openConnection();
|
|
|
|
|
|
// generate hash of the url
|
|
|
String msgToEncode = SecureShuffleUtils.buildMsgFrom(url);
|
|
@@ -218,6 +219,14 @@ class Fetcher<K,V> extends Thread {
|
|
|
connect(connection, connectionTimeout);
|
|
|
connectSucceeded = true;
|
|
|
input = new DataInputStream(connection.getInputStream());
|
|
|
+
|
|
|
+ // Validate response code
|
|
|
+ int rc = connection.getResponseCode();
|
|
|
+ if (rc != HttpURLConnection.HTTP_OK) {
|
|
|
+ throw new IOException(
|
|
|
+ "Got invalid response code " + rc + " from " + url +
|
|
|
+ ": " + connection.getResponseMessage());
|
|
|
+ }
|
|
|
|
|
|
// get the replyHash which is HMac of the encHash we sent to the server
|
|
|
String replyHash = connection.getHeaderField(SecureShuffleUtils.HTTP_HEADER_REPLY_URL_HASH);
|