Android XcapClinet 二
来源:互联网 发布:sql报表编辑器 编辑:程序博客网 时间:2024/04/30 13:33
Android XcapClinet 二、android客户端编写
转载注明出处:http://blog.csdn.net/gremorse/article/details/11737143
需要借助工具:wireshark
过滤http
以put方法为例,使用Xcapclient测试put方法时抓包得到的结果是
xcapclient openxcap
| PUT \ |
|/ 401 |
| PUT \ |
|/ 200 |
过程很迂回,出现的关键字字眼为WWW-Authenticate,参照RFC2617public static String sendPut(String url, Map<String, String> headers,String entityString, String sipName, String sipPwd)throws ClientProtocolException, IOException,MalformedChallengeException, AuthenticationException {DefaultHttpClient httpClient = (DefaultHttpClient) getHttpClient();HttpPut httpPut = new HttpPut(url);String response = "";if (headers != null) {httpPut.setHeaders(convertHead(headers));}if (entityString != null)httpPut.setEntity(new StringEntity(entityString));HttpResponse httpResponse = httpClient.execute(httpPut);if (httpResponse.getStatusLine().getStatusCode() == 401) {DigestScheme md5Auth = new DigestScheme();// 提取鉴权元素Header challenge = httpResponse.getHeaders("WWW-Authenticate")[0];md5Auth.processChallenge(challenge);Header solution = md5Auth.authenticate(new UsernamePasswordCredentials(sipName, sipPwd),new BasicHttpRequest(HttpPut.METHOD_NAME, new URL(url).getPath()));Map<String, String> tempHeaders = new HashMap<String, String>();tempHeaders = headers;tempHeaders.put(solution.getName(), solution.getValue());response = sendPut(url, tempHeaders, entityString, sipName, sipPwd);} else {response += httpResponse.getStatusLine() + "\r\n";for (Header tempHeader : httpResponse.getAllHeaders()) {response += tempHeader.getName() + ":";response += tempHeader.getValue() + "\r\n";}response += EntityUtils.toString(httpResponse.getEntity());}httpPut.abort();return response;}主要还是在
if (httpResponse.getStatusLine().getStatusCode() == 401)
- Android XcapClinet 二
- Android XcapClinet
- android二
- android(二)
- Android:Android面试准备二
- Android实践(二)
- Android学习笔记(二)
- android telephony(二)
- Android Activity 二
- Android学习笔记二
- Android学习笔记二
- Android基础(二) LinearLayout
- Android基础(二) RelativeLayout
- Android启动研究(二)
- Android应用解析(二)
- android testing (二)
- Android 淺探(二):系統架構
- Android学习笔记二
- 动态语言跟静态语言
- ASP.NET MVC4.0发布网站
- C++ AMP 概述
- ActivityGroup + GridView 实现Tab分页标签
- android在adapter中调用activity跳转效果
- Android XcapClinet 二
- iPhone开发:单独添加.xib文件
- 获取分辨率 尺寸、样式
- Ubuntu下配置samba实现文件夹共享
- 归并排序的递归实现
- JAVA反射中类的构造函数,成员变量,成员方法的使用
- 用友U8物料清单母件子件查询
- Android 请求服务器 设置本地缓存
- glib 中 IO Channels 理解