changeset 1511:fb5be0e8ca54

better time_out
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 22 May 2020 19:10:14 -0600
parents 20375c20289d
children 31b543826ca9
files src/luan/modules/url/LuanUrl.java
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/luan/modules/url/LuanUrl.java	Wed May 20 21:57:27 2020 -0600
+++ b/src/luan/modules/url/LuanUrl.java	Fri May 22 19:10:14 2020 -0600
@@ -11,6 +11,7 @@
 import java.net.URLConnection;
 import java.net.HttpURLConnection;
 import java.net.URLEncoder;
+import java.net.SocketTimeoutException;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.util.Map;
@@ -37,7 +38,7 @@
 	private static final byte[] NO_CONTENT = new byte[0];
 	private byte[] content = NO_CONTENT;
 	private MultipartClient multipart = null;
-	private int timeout = 0;
+	private int timeout = 60000;
 	private String authUsername = null;
 	private String authPassword = null;
 	public HttpURLConnection httpCon;
@@ -190,6 +191,13 @@
 	@Override public InputStream inputStream() throws IOException, LuanException {
 		try {
 			return inputStream(null);
+		} catch(SocketTimeoutException e) {
+			String msg = e.getMessage();
+			if( msg != null ) {
+				throw new LuanException(e.getMessage());
+			} else {
+				throw e;
+			}
 		} catch(AuthException e) {
 			try {
 				return inputStream(e.authorization);