Inconsistent HttpUrlConnection behaviours on Android - how to debug?

南笙酒味 提交于 2020-01-14 10:22:31

问题


I have a weird problem: Implementing an interface to a webserver in my Android App, I connect to it using a HttpsUrlConnection. The connection uses additional HTTP Basic authorization (using setRequestProperty), but otherwise is a plain GET request over HTTPS.

It works perfectly fine using it on the emulator using Android 4.0.3, but fails with a "Bad request" HTTP 400 Error on Android 2.3.5 (both emulator and real device). I do not have control over the server, so I cannot see what the problem exactly is.

Has anyone ever encountered such a problem or knows how to print/log the request that actually is being sent?

TIA,

Patrick


回答1:


You could set up a proxy such as Fiddler or Charles proxy (and I think there are firefox extensions as well) and point your app to the proxy instead. Even if you don't set it up to actually be a proxy (such that the requests actually work), as long as it captures the requests you should be able to compare the difference between the requests made from 4.0.3 vs. 2.3.5.



来源:https://stackoverflow.com/questions/9556316/inconsistent-httpurlconnection-behaviours-on-android-how-to-debug

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!