Merge pull request #77 from NativeScript/dontFollowRedirects

dontFollowRedirects added
This commit is contained in:
Vladimir Enchev
2017-01-12 10:56:10 +02:00
committed by GitHub

View File

@@ -288,6 +288,7 @@ public class Async
public int timeout = -1; public int timeout = -1;
public int screenWidth = -1; public int screenWidth = -1;
public int screenHeight = -1; public int screenHeight = -1;
public boolean dontFollowRedirects = false;
public void addHeaders(HttpURLConnection connection) public void addHeaders(HttpURLConnection connection)
{ {
@@ -522,6 +523,11 @@ public class Async
connection.setConnectTimeout(options.timeout); connection.setConnectTimeout(options.timeout);
} }
// don't follow redirect (30x) responses; by default, HttpURLConnection follows them.
if (options.dontFollowRedirects) {
connection.setInstanceFollowRedirects(false);
}
// Do not attempt to write the content (body) for DELETE method, Java will throw directly // Do not attempt to write the content (body) for DELETE method, Java will throw directly
if (!requestMethod.equals(DELETE_METHOD)) if (!requestMethod.equals(DELETE_METHOD))
{ {