修改网络请求
This commit is contained in:
parent
9c7638f123
commit
b679d45fc4
@ -165,6 +165,14 @@ public class OkGoBuilder<T> {
|
||||
* @param id
|
||||
*/
|
||||
public okhttp3.Response postFileSynchronization(int id) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
if (token==null){
|
||||
headers.put("Authorization","Basic YXBwOmFwcHNlY3JldA==");
|
||||
}else {
|
||||
headers.put("Authorization","bearer"+token);
|
||||
|
||||
}
|
||||
headers.put("key",null);
|
||||
try {
|
||||
okhttp3.Response execute = OkGo
|
||||
// 请求方式和请求url
|
||||
@ -172,6 +180,7 @@ public class OkGoBuilder<T> {
|
||||
// 请求的 tag, 主要用于取消对应的请求
|
||||
.params("auditId", id)
|
||||
.addFileParams("file", files)
|
||||
.headers(headers)
|
||||
.tag(this)
|
||||
.execute();
|
||||
return execute;
|
||||
@ -190,11 +199,20 @@ public class OkGoBuilder<T> {
|
||||
* @param callback
|
||||
*/
|
||||
public void postFileAsynchronous(int id, Callback callback) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
if (token==null){
|
||||
headers.put("Authorization","Basic YXBwOmFwcHNlY3JldA==");
|
||||
}else {
|
||||
headers.put("Authorization","bearer"+token);
|
||||
|
||||
}
|
||||
headers.put("key",null);
|
||||
OkGo
|
||||
// 请求方式和请求url
|
||||
.<T>post(url)
|
||||
.params("auditId", id)
|
||||
.addFileParams("file", files)
|
||||
.headers(headers)
|
||||
// .upJson(json)
|
||||
// 请求的 tag, 主要用于取消对应的请求
|
||||
.tag(this)
|
||||
@ -229,10 +247,19 @@ public class OkGoBuilder<T> {
|
||||
* get异步请求
|
||||
*/
|
||||
public void getRequest(Callback<T> callback) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
if (token==null){
|
||||
headers.put("Authorization","Basic YXBwOmFwcHNlY3JldA==");
|
||||
}else {
|
||||
headers.put("Authorization","bearer"+token);
|
||||
|
||||
}
|
||||
headers.put("key",null);
|
||||
OkGo
|
||||
// 请求方式和请求url
|
||||
.<T>get(url)
|
||||
.params(params)
|
||||
.headers(headers)
|
||||
// 请求的 tag, 主要用于取消对应的请求
|
||||
.tag(this)
|
||||
// 设置当前请求的缓存key,建议每个不同功能的请求设置一个
|
||||
@ -262,9 +289,18 @@ public class OkGoBuilder<T> {
|
||||
* @return
|
||||
*/
|
||||
public okhttp3.Response getSynchronization() {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
if (token==null){
|
||||
headers.put("Authorization","Basic YXBwOmFwcHNlY3JldA==");
|
||||
}else {
|
||||
headers.put("Authorization","bearer"+token);
|
||||
|
||||
}
|
||||
headers.put("key",null);
|
||||
try {
|
||||
okhttp3.Response execute = OkGo.<String>get(HttpInterface.SUBMIT_CSTASK)
|
||||
.params(params)
|
||||
.headers(headers)
|
||||
.tag(this)
|
||||
.execute();
|
||||
return execute;
|
||||
|
Loading…
x
Reference in New Issue
Block a user