Android上的不一致HttpURLConnection的行为 - 如何调试? [英] Inconsistent HttpUrlConnection behaviours on Android - how to debug?

查看:140
本文介绍了Android上的不一致HttpURLConnection的行为 - 如何调试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的问题:
落实到我的Andr​​oid应用程序的网络服务器的接口,我连接到​​它使用HttpsURLConnection的。该连接使用额外的HTTP基本授权(使用调用setRequestProperty ),但在其他方面是通过HTTPS。一个普通的GET请求

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.

它采用了Android 4.0.3使用它在模拟器上工作完全正常,但无法用错误的请求HTTP 400在Android 2.3.5(包括模拟器和真实设备)错误。
我没有对服务器的控制,所以我看不到这个问题到底是什么。

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,

帕特里克

推荐答案

您可以设置代理,如提琴手或查尔斯代理(我认为有Firefox扩展,以及),并指向您的应用程序代理来代替。即使你不设置它实际上是一个代理(这样的要求实际工作),只要它抓住了你应该能够比较4.0.3与2.3提出的要求之间的差异请求。 5。

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.

这篇关于Android上的不一致HttpURLConnection的行为 - 如何调试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆