http协议接口调用,basic验证
来源:互联网 发布:河南省网络教研室 编辑:程序博客网 时间:2024/06/05 23:54
一般服务端采用Basic方式作验证时,就会用到这个。
public void testCj{ private String username="test"; private String password="test" static class MyAuthenticator extends Authenticator { @Override public PasswordAuthentication getPasswordAuthentication() { return (new PasswordAuthentication(username, password.toCharArray())); } } @Test public void test(){ Authenticator.setDefault(new MyAuthenticator()); //获取连接 URL url = new URL(""); HttpURLConnection conn =(HttpURLConnection)url.opentConnection(); conn.setRequestMethod("GET"); conn.setDoInput(true); conn.setDoOutput(true); conn.connect(); //获取数据流 InputStream is = conn.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(is,"utf-8"),5*1024*1024); //根据服务器编码设置 String next = null; while ((next = reader.readLine()) != null) { sb.append(next); } if (StringUtils.isBlank(sb.toString())) { //System.out.println("结果集为null"); return null; }else{ return sb.toString(); } }}
阅读全文
0 0
- http协议接口调用,basic验证
- C#如何调用axis发布的带HTTP Basic Authentication验证的接口配置方式
- http协议接口调用之WebClient
- http协议接口调用之HttpClient
- Http Basic Authorizaition验证
- php通过http调用验证码短信接口源码
- ASP通过http调用验证码短信接口源码
- VB通过http调用验证码短信接口源码
- JSP通过http调用验证码短信接口源码
- JAVA通过http调用验证码短信接口源码
- ASP.net通过http调用验证码短信接口源码
- 验证码短信接口php调用http源码
- Java http协议调用接口返回json字符串
- http协议调用接口并反馈消息的小例子
- HTTP Basic Authentication验证WCF Data Service
- Java中,使用HTTP Basic进行验证
- 使用HttpClient进行HTTP BASIC验证
- Visual Basic .Net中实现HTTP协议
- 跨浏览器的事件处理、事件对象
- Netty实战读书笔记(第五章(一))
- mqtt+activemq用发布订阅实现点对点推送
- 数据分析的统计学基础--方差分析
- 根据xml的标签解析文件的Demo
- http协议接口调用,basic验证
- 【WEB】表单基础知识实例DEMO
- Java实现-Huffman编码与解码
- 内核链表
- LINUX 版本信息查看(全)
- 用with open完成python读写
- 读懂深度学习
- JS工具类
- httpclient 发送post请求