Mercurial Hosting > luan
changeset 1087:4aab4dd3ac9c
improve url error handling
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 19 Dec 2016 01:38:21 -0700 |
parents | b1f6dafa72fc |
children | bae2d0c2576c |
files | src/luan/modules/url/LuanUrl.java |
diffstat | 1 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/luan/modules/url/LuanUrl.java Mon Dec 19 01:18:46 2016 -0700 +++ b/src/luan/modules/url/LuanUrl.java Mon Dec 19 01:38:21 2016 -0700 @@ -229,12 +229,18 @@ } } } - if( method==Method.GET ) { + if( !(con instanceof HttpURLConnection) ) { + if( method!=Method.GET ) + throw new LuanException("method must be GET but is "+method); return con.getInputStream(); } HttpURLConnection httpCon = (HttpURLConnection)con; + if( method==Method.GET ) { + return getInputStream(httpCon); + } + if( method==Method.DELETE ) { httpCon.setRequestMethod("DELETE"); return getInputStream(httpCon);