comparison src/luan/modules/url/LuanUrl.java @ 1087:4aab4dd3ac9c

improve url error handling
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 19 Dec 2016 01:38:21 -0700
parents a04da9a3e9eb
children cb4c20fce7d0
comparison
equal deleted inserted replaced
1086:b1f6dafa72fc 1087:4aab4dd3ac9c
227 con.addRequestProperty(key,(String)obj); 227 con.addRequestProperty(key,(String)obj);
228 } 228 }
229 } 229 }
230 } 230 }
231 } 231 }
232 if( !(con instanceof HttpURLConnection) ) {
233 if( method!=Method.GET )
234 throw new LuanException("method must be GET but is "+method);
235 return con.getInputStream();
236 }
237
238 HttpURLConnection httpCon = (HttpURLConnection)con;
239
232 if( method==Method.GET ) { 240 if( method==Method.GET ) {
233 return con.getInputStream(); 241 return getInputStream(httpCon);
234 } 242 }
235
236 HttpURLConnection httpCon = (HttpURLConnection)con;
237 243
238 if( method==Method.DELETE ) { 244 if( method==Method.DELETE ) {
239 httpCon.setRequestMethod("DELETE"); 245 httpCon.setRequestMethod("DELETE");
240 return getInputStream(httpCon); 246 return getInputStream(httpCon);
241 } 247 }