http协议:URL、三次握手、http请求头信息,请求方式、响应码信息、协议的特点、TCP、IP四层协议、OSI七层协议
content="text/html;charset=utf-8"里面的内容就是webview加载时的参数mimetype
数据流量比较小的时候利用doGet 大的时候用doPost
post发送方式比较安全 get是通过url后面附上参数发送的
http发送请求头发送信息
General
Remote Address:192.168.1.106:8080
Request URL:http://192.168.1.106:8080/web/MyServlet
Request Method:POST
Status Code:200 OK
Response Headers
Content-Length:19
Content-Type:text/html;charset=utf-8
Date:Sun, 08 Nov 2015 08:45:46 GMT
Server:Apache-Coyote/1.1
Request Headers
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate
Accept-Language:zh-CN,zh;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:21
Content-Type:application/x-www-form-urlencoded
Cookie:JSESSIONID=E83D4C4F8162B4CAD03AF8AFD5D42638
Host:192.168.1.106:8080
Origin:http://192.168.1.106:8080
Referer:http://192.168.1.106:8080/web/
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36
Form Data
name:张
age:11
httpclient通过get方式发送请求
创建httpget对象
创建httpclient对象并调用execute方式发送请求 成功后会返回response对象
判断其类型或得响应码是否为200 然后利用EntityUtils获得数据
HttpResponse response;
HttpGet httpGet = new HttpGet(url);
HttpClient httpClient = new DefaultHttpClient();
try {
response = httpClient.execute(httpGet);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
String content = EntityUtils.toString(response.getEntity());
System.out.println("content:" + content);
}
多线程下载中用到的:
1、http协议字段 Range "bytes="+start+"-"+end
2、RandomAccessFile设置吸入的位置
3、开启线程发送网络请求
-----------------------------7df28ac180a3e
Content-Disposition: form-data; name="file"; filename="C:\Users\born\Desktop\2012081210373.jpg"
Content-Type: image/jpeg
<二进制文件数据未显示>
---------------------------7df28ac180a3e--
在Android中开发HTTP客户端的一般方法:先用浏览器试一试,
然后看浏览器传给server的request header和request body是什么,
然后我们在开发Android的HTTP客户端的时候也仿照这同样的header和body设置就行了