移动APP之HTTP协议
2013-11-26 23:08
435 查看
HTTP —— 超文本传输协议,也是移动互联网比较常用协议之一。是一种应用层协议,由请求和应答两部分构成,是典型的服务器客户端模型。比较常用的方法有POST,GET方法。
目前Java部分实现基本分两种方式,一种Java的JDK提供的HttpURLConnection,还有一种是Apache封装的开源框架HttpClient。相比较HttpClient由于是封装后的HTTP实现,所以比较适合快速开发上层应用。二者区别如下(借用网上别人的表格):
目前Java部分实现基本分两种方式,一种Java的JDK提供的HttpURLConnection,还有一种是Apache封装的开源框架HttpClient。相比较HttpClient由于是封装后的HTTP实现,所以比较适合快速开发上层应用。二者区别如下(借用网上别人的表格):
URLConnection | HTTPClient | |
---|---|---|
代理和SOCKS | Full support in Netscape browser, appletviewer, and applications (SOCKS: Version 4 only); no additional limitations from security policies. | Full support (SOCKS: Version 4 and 5); limited in applets however by security policies; in Netscape can't pick up the settings from the browser. |
授权 | Full support for Basic Authorization in Netscape (can use info given by the user for normal accesses outside of the applet); no support in appletviewer or applications. | Full support everywhere; however cannot access previously given info from Netscape, thereby possibly requesting the user to enter info (s)he has already given for a previous access. Also, you can add/implement additional authentication mechanisms yourself. |
支持的方法 | 只支持GET和POST方法 Only has GET and POST. | Has HEAD, GET, POST, PUT, DELETE, TRACE and OPTIONS, 添加了一些额外的属性方法。 |
头部信息 | Currently you can only set any request headers if you are doing a POST under Netscape; for GETs and the JDK you can't set any headers. Under Netscape 3.0 you can read headers only if the resource was returned with a Content-length header; if no Content-length header was returned, or under previous versions of Netscape, or using the JDK no headers can be read. | Allows any arbitrary headers to be sent and received. |
自动重定向处理 | Yes. | Yes (as allowed by the HTTP/1.1 spec). |
持久连接 | No support currently in JDK; under Netscape uses HTTP/1.0 Keep-Alive's. | Supports HTTP/1.0 Keep-Alive's and HTTP/1.1 persistence. |
Pipelining of Requests | No. | Yes. |
可以处理HTTP之外的协议 | 理论上可以,然而当前仅仅实现了HTTP协议 | 不支持 |
可以做基于SSL的HTTP (https) | Under Netscape, yes. Using Appletviewer or in an application, no. | No (not yet). |
Source code available | No. | Yes. |
相关文章推荐
- Git出现fatal: Unable to find remote helper for 'https'
- Acceptor+TcpConnection+TcpServer
- TCP连接建立过程中为什么需要“三次握手”
- Http请求之--C#的HttpWebRequest实现POST方式请求
- Http请求之--C#的HttpWebRequest实现POST方式请求
- C#--网络流Stream、字节数组保存到字符串中
- C#--网络流Stream、字节数组保存到字符串中
- Java网络编程DatagramPacket传数据
- 基于Heritrix的特定主题的网络爬虫配置与实现
- 【自由谈】城域网IPv6过渡技术——NAT444与DS-lite概述
- http://codeforces.com/contest/366/problem/D
- http://codeforces.com/contest/366/problem/C之01背包
- HTTP 错误 404.2 - Not Found 由于 Web 服务器上的“ISAPI 和 CGI 限制”列表设置,无法提供您请求的页面。
- 哪些网络虚拟化技术适合现代网络?
- http server样例
- cmd几个小命令排除网络故障
- http-equiv是什么意思(转载)
- HttpServlet- 读取表单参数Get&Post
- 《TCP-IP详解 卷2:实现》学习笔记—接口层分析
- iOS网络编程–ASIHTTPRequest框架安装和配置-图文解说