2017-12-04 51 views
0

Android 앱을 사용하여 CherryPy 서버에 base64 인코딩 문자열을 보냅니다. 안드로이드 코드는 다음과 같이 작동받은 길이가 보낸 길이와 다릅니다

URL url = new URL("http://foo.bar/blabla"); 

HttpURLConnection conn = (HttpURLConnection) url.openConnection(); 
conn.setRequestProperty("Content-Type", "application/octet-stream"); 
conn.setDoOutput(true); 
conn.setFixedLengthStreamingMode(base64s.length()); 

OutputStream out = new BufferedOutputStream(conn.getOutputStream()); 
out.write(base64s.getBytes()); 

그래서, 당신이 보낸 바이트의 양이 Content-Length 헤더의 바이트의 양을 동일 말할 것입니다.

cl = cherrypy.request.headers['Content-Length'] 
rawbody = cherrypy.request.body.read() 

print "{} bytes, {}".format(len(rawbody), cl) 

숫자 cllen(rawbody)가 다른 그러나, 파이썬, 내가이 실행할 때.

어떻게 될 수 있습니까?

+0

값은 무엇입니까 ??? 그리고 얼마나 많은 바이트가 전송 되었습니까? – greenapps

+1

잊어 버린 점 .close() ;? – greenapps

+0

@greenapps 그게 사실입니다. 네가 대답하면 내가 받아 들일거야. –

답변

0

은 어쩌면 당신은 out.close();로 스트림을 닫습니다 잊어을 위해 클라이언트가 종료 스트림 전혀 없이도 있도록 「클로우즈 헤더를 "보내 sould 서버?