설정 유지, 나는이 일을 해요 :HttpsURLConnection에 잘못된 매개 변수
conn
객체를 디버깅하는 동안 내가이 일을 해요하지만
String myParams = "param1=ok¶m2=ok";
byte[] outputInBytes = myParams.toString().getBytes("UTF-8");
URL url = new URL("https://myurl.com/sendData.asp");
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setRequestProperty("Set-Cookie", sessionCookie);
conn.setRequestProperty("Accept", "text/html");
conn.setRequestProperty("Content-Length", "" + Integer.toString(outputInBytes.length));
OutputStream os = conn.getOutputStream();
os.write(outputInBytes);
os.close();
response = conn.getResponseCode();
InputStream in = null;
ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
in = conn.getInputStream();
int c;
while ((c = in.read()) != -1)
byteArrayOut.write(c);
byte[] byteArray = byteArrayOut.toByteArray();
s = new String(byteArray);
는, 여기에 정보입니다 내가 얻을 :
나는 어떤 문제없이 응용 프로그램의 iOS 버전에서 동일한 엔드 포인트를 사용하고 있기 때문에 서버 측의 문제라고 생각하지 않습니다. 그러면이 문제가 발생할 수있는 이유는 무엇입니까?
는
화면 캡처 출력을 샘플링 할 때 어떤 코드 줄이 디버거였습니까? Android에서 코드를 실행할 때 적어도 ASP에서 끝점에 도달했는지 확인 했습니까? –
원시 Http 클라이언트를 사용하는 것은 매우 까다 롭습니다. 개장과 같은 라이브러리를 사용해보십시오. 내 인생을 더 쉽게 만들었습니다. –
@TimBiegeleisen'conn.getOutputStream()'줄에서 실행을 중단했습니다. 나는 또한 URL이 실제로 내가 기대하는 것임을 확인했다. – Someday