Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

english doc #736

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private void sign(HttpParams params) {
params.put("timestamp", "" + (System.currentTimeMillis() / 1000L));
StringBuilder sb = new StringBuilder();
Map<String, String> map = new HashMap<>();
for (Map.Entry<String, List<String>> entry : params.urlParamsMap.entrySet()) {
for (Map.Entry<String, List<String>> entry : params.stringParamsMap.entrySet()) {
map.put(entry.getKey(), entry.getValue().get(0));
}
for (Map.Entry<String, String> entry : getSortedMapByKey(map).entrySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public void formUpload(View view) {
// .params("file1",new File("文件路径")) //这种方式为一个key,对应一个文件
// .params("file2",new File("文件路径"))
// .params("file3",new File("文件路径"))
.addFileParams("file", files) // 这种方式为同一个key,上传多个文件
.paramsFileList("file", files) // 这种方式为同一个key,上传多个文件
.execute(new JsonCallback<LzyResponse<ServerModel>>() {
@Override
public void onStart(Request<LzyResponse<ServerModel>, ? extends Request> request) {
Expand Down
13 changes: 10 additions & 3 deletions demo/src/main/java/com/lzy/demo/okgo/TestActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import com.lzy.okgo.OkGo;
import com.lzy.okgo.adapter.Call;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.HttpHeaders;
import com.lzy.okgo.model.Response;

import org.json.JSONObject;
Expand Down Expand Up @@ -99,9 +98,17 @@ public void run() {

@OnClick(R.id.btn3)
public void btn3(View view) {
OkGo.<String>get("asdfasf")//

OkGo.<String>post("http://server.jeasonlzy.com/{server}/{path}")//
.tag(this)//
.headers(HttpHeaders.HEAD_KEY_USER_AGENT, "abcd")//
.paramsPath("server", "OkHttpUtils")//
.paramsPath("path", "method")//
.paramsQuery("aaa", "111")//
.paramsQuery("bbb", "222")//
.paramsQuery("ccc", "333")//
.params("xxx", "777")//
.params("yyy", "888")//
.params("zzz", "999")//
.execute(new StringCallback() {
@Override
public void onSuccess(Response<String> response) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {

@OnClick(R.id.formUpload1)
public void formUpload1(View view) {
ArrayList<File> files = new ArrayList<>();
List<File> files = new ArrayList<>();
if (imageItems != null && imageItems.size() > 0) {
for (int i = 0; i < imageItems.size(); i++) {
files.add(new File(imageItems.get(i).path));
Expand All @@ -148,7 +148,7 @@ public void formUpload1(View view) {
// .params("file1",new File("文件路径"))
// .params("file2",new File("文件路径"))
// .params("file3",new File("文件路径"))
.addFileParams("file", files)//
.paramsFileList("file", files)//
.converter(new StringConvert())//
.adapt(new ObservableResponse<String>())//
.doOnSubscribe(new Consumer<Disposable>() {
Expand Down Expand Up @@ -206,7 +206,7 @@ public void subscribe(@NonNull final ObservableEmitter<Progress> e) throws Excep
//.params("file1",new File("文件路径"))
//.params("file2",new File("文件路径"))
//.params("file3",new File("文件路径"))
.addFileParams("file", files)//
.paramsFileList("file", files)//
.execute(new StringCallback() {
@Override
public void onSuccess(Response<String> response) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public boolean onAnalysisResponse(Call call, okhttp3.Response response) {
public CacheEntity<T> prepareCache() {
//check the config of cache
if (request.getCacheKey() == null) {
request.cacheKey(HttpUtils.createUrlFromParams(request.getBaseUrl(), request.getParams().urlParamsMap));
request.cacheKey(HttpUtils.createUrlFromParams(request.getBaseUrl(), true, request.getParams()));
}
if (request.getCacheMode() == null) {
request.cacheMode(CacheMode.NO_CACHE);
Expand Down