comparison src/luan/modules/url/LuanUrl.java @ 1511:fb5be0e8ca54

better time_out
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 22 May 2020 19:10:14 -0600
parents 0ba144491a42
children 3ebf9781707c
comparison
equal deleted inserted replaced
1510:20375c20289d 1511:fb5be0e8ca54
9 import java.io.UnsupportedEncodingException; 9 import java.io.UnsupportedEncodingException;
10 import java.net.URL; 10 import java.net.URL;
11 import java.net.URLConnection; 11 import java.net.URLConnection;
12 import java.net.HttpURLConnection; 12 import java.net.HttpURLConnection;
13 import java.net.URLEncoder; 13 import java.net.URLEncoder;
14 import java.net.SocketTimeoutException;
14 import java.security.MessageDigest; 15 import java.security.MessageDigest;
15 import java.security.NoSuchAlgorithmException; 16 import java.security.NoSuchAlgorithmException;
16 import java.util.Map; 17 import java.util.Map;
17 import java.util.HashMap; 18 import java.util.HashMap;
18 import java.util.List; 19 import java.util.List;
35 private Method method = Method.GET; 36 private Method method = Method.GET;
36 private final Map<String,Object> headers = new HashMap<String,Object>(); 37 private final Map<String,Object> headers = new HashMap<String,Object>();
37 private static final byte[] NO_CONTENT = new byte[0]; 38 private static final byte[] NO_CONTENT = new byte[0];
38 private byte[] content = NO_CONTENT; 39 private byte[] content = NO_CONTENT;
39 private MultipartClient multipart = null; 40 private MultipartClient multipart = null;
40 private int timeout = 0; 41 private int timeout = 60000;
41 private String authUsername = null; 42 private String authUsername = null;
42 private String authPassword = null; 43 private String authPassword = null;
43 public HttpURLConnection httpCon; 44 public HttpURLConnection httpCon;
44 45
45 public LuanUrl(URL url,LuanTable options) throws LuanException { 46 public LuanUrl(URL url,LuanTable options) throws LuanException {
188 } 189 }
189 190
190 @Override public InputStream inputStream() throws IOException, LuanException { 191 @Override public InputStream inputStream() throws IOException, LuanException {
191 try { 192 try {
192 return inputStream(null); 193 return inputStream(null);
194 } catch(SocketTimeoutException e) {
195 String msg = e.getMessage();
196 if( msg != null ) {
197 throw new LuanException(e.getMessage());
198 } else {
199 throw e;
200 }
193 } catch(AuthException e) { 201 } catch(AuthException e) {
194 try { 202 try {
195 return inputStream(e.authorization); 203 return inputStream(e.authorization);
196 } catch(AuthException e2) { 204 } catch(AuthException e2) {
197 throw new RuntimeException(e2); // never 205 throw new RuntimeException(e2); // never