[jnc-users] JNC + https
Status: Beta
Brought to you by:
soapy
From: Eric C. <zip...@ho...> - 2007-11-10 14:30:03
|
Hello, I have an app that breaks when I change from http to https when posting data to a web app. Is it possible that JNC does not support https at this time? Please let me know. Thanks, Eric. Here's my code: /** * data type: * 0 = ascii * 1 = binary */ public static Object postToUrl(String myUrl, String data, int dataType) { String line = ""; byte[] content = null; System.out.println("called post TO URL: " + myUrl + " data tyhpe : " + dataType); try { // Send data URL url = new URL(myUrl); URLConnection conn = url.openConnection(); conn.setDoOutput(true); OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); wr.write(data); wr.flush(); String ret = ""; // Get the response BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); //System.out.println("rd: " + rd.); if(dataType == 0) { //sent back a send code and the media and media send as string while ((ret = rd.readLine()) != null) { line += ret; } } else { int clen = conn.getContentLength(); System.out.println("content length: " + clen); content = new byte[clen]; for(int i=0; i<content.length; i++) { int r = rd.read(); content[i] = (byte) r; } } wr.close(); rd.close(); } catch (Exception e) { } System.out.println("line: " + line.trim()); if(dataType == 0) { return line; } else { return content; } } |