Mercurial Hosting > luan
comparison src/luan/modules/url/LuanUrl.java @ 1333:25746915a241
merge Luan and LuanState
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 12 Feb 2019 22:33:40 -0700 |
parents | 35a6a195819f |
children | e0cf0d108a77 |
comparison
equal
deleted
inserted
replaced
1332:11b7e11f9ed5 | 1333:25746915a241 |
---|---|
17 import java.util.HashMap; | 17 import java.util.HashMap; |
18 import java.util.List; | 18 import java.util.List; |
19 import java.util.Base64; | 19 import java.util.Base64; |
20 import luan.lib.parser.ParseException; | 20 import luan.lib.parser.ParseException; |
21 import luan.Luan; | 21 import luan.Luan; |
22 import luan.LuanState; | |
23 import luan.LuanTable; | 22 import luan.LuanTable; |
24 import luan.LuanJavaFunction; | 23 import luan.LuanJavaFunction; |
25 import luan.LuanException; | 24 import luan.LuanException; |
26 import luan.modules.IoLuan; | 25 import luan.modules.IoLuan; |
27 import luan.modules.Utils; | 26 import luan.modules.Utils; |
194 private static Map getMap(Map map,String key) throws LuanException { | 193 private static Map getMap(Map map,String key) throws LuanException { |
195 LuanTable t = getTable(map,key); | 194 LuanTable t = getTable(map,key); |
196 return t==null ? null : t.asMap(); | 195 return t==null ? null : t.asMap(); |
197 } | 196 } |
198 | 197 |
199 @Override public InputStream inputStream(LuanState luan) throws IOException, LuanException { | 198 @Override public InputStream inputStream(Luan luan) throws IOException, LuanException { |
200 try { | 199 try { |
201 return inputStream(luan,null); | 200 return inputStream(luan,null); |
202 } catch(AuthException e) { | 201 } catch(AuthException e) { |
203 try { | 202 try { |
204 return inputStream(luan,e.authorization); | 203 return inputStream(luan,e.authorization); |
206 throw new RuntimeException(e2); // never | 205 throw new RuntimeException(e2); // never |
207 } | 206 } |
208 } | 207 } |
209 } | 208 } |
210 | 209 |
211 private InputStream inputStream(LuanState luan,String authorization) | 210 private InputStream inputStream(Luan luan,String authorization) |
212 throws IOException, LuanException, AuthException | 211 throws IOException, LuanException, AuthException |
213 { | 212 { |
214 URLConnection con = url.openConnection(); | 213 URLConnection con = url.openConnection(); |
215 if( timeout != 0 ) { | 214 if( timeout != 0 ) { |
216 con.setConnectTimeout(timeout); | 215 con.setConnectTimeout(timeout); |
268 } finally { | 267 } finally { |
269 out.close(); | 268 out.close(); |
270 } | 269 } |
271 } | 270 } |
272 | 271 |
273 private InputStream getInputStream(LuanState luan,HttpURLConnection httpCon,String authorization) | 272 private InputStream getInputStream(Luan luan,HttpURLConnection httpCon,String authorization) |
274 throws IOException, LuanException, AuthException | 273 throws IOException, LuanException, AuthException |
275 { | 274 { |
276 try { | 275 try { |
277 return httpCon.getInputStream(); | 276 return httpCon.getInputStream(); |
278 } catch(FileNotFoundException e) { | 277 } catch(FileNotFoundException e) { |