文章目录
1、HTTP和HTTPS协议是什么,有什么区别?
2、HTTP组成部分
2、HTTP中的请求头和响应头
3、利用okHttp实现网络请求
4、什么是Https加密?
6、Http接口调试工具
7、HTTP请求常见字段cookie、session、token鉴权
HTTP请求常见字段cookie、session、token鉴权
8、okHttp的详细使用 get、post请求
10、JSONObject put,accumulate,element的区别
JSONObject put,accumulate,element的区别
11、怎么提交JSON数组数据给服务器
正常的JSON数据
{
"username": "123",
"password": "test",
}
JSONObject jsonObject = new JSONObject();
jsonObject .put("username","123");
jsonObject .put("password","test");
JSON数组数据
{
"username": "123",
"password": "test",
"data": [{
"aa": "963",
"bb": "852",
"cc": "741",
}]
}
JSONObject jsonObject = new JSONObject();
jsonObject .put("username","123");
jsonObject .put("password","test");
JSONArray jsonArray=new JSONArray();
JSONObject payloadObject=new JSONObject();
payloadObject.put("uploadType",1);
payloadObject.put("locTime",0);
jsonArray.put(payloadObject);
jsonObject.accumulate("payload",jsonArray);
最后使用post请求即可
MediaType JSON = MediaType.parse("application/json;charset=utf-8");
RequestBody requestBody = RequestBody.create(JSON, jsonObject .toString());
Request request = new Request.Builder()
.url(URL)
.post(requestBody)
.build();