Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.7.x'
Browse files Browse the repository at this point in the history
# Conflicts:
#	build.gradle
  • Loading branch information
li-xunhuan committed Nov 28, 2023
2 parents 8e5b997 + 3a469d3 commit 6bb5c36
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
10 changes: 7 additions & 3 deletions mica-http/src/main/java/net/dreamlu/mica/http/FormBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import javax.annotation.Nullable;
import java.util.Map;
import java.util.function.Consumer;

/**
* 表单构造器
Expand Down Expand Up @@ -52,10 +53,13 @@ public FormBuilder addEncoded(String name, @Nullable Object encodedValue) {
return this;
}

public FormBuilder add(Consumer<FormBody.Builder> consumer) {
consumer.accept(this.formBuilder);
return this;
}

public HttpRequest build() {
FormBody formBody = formBuilder.build();
this.request.form(formBody);
return this.request;
return this.request.form(this.formBuilder.build());
}

public Exchange execute() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;

/**
* 表单构造器
Expand Down Expand Up @@ -102,11 +104,20 @@ public MultipartFormBuilder add(MultipartBody.Part part) {
return this;
}

public MultipartFormBuilder addList(List<MultipartBody.Part> partList) {
for (MultipartBody.Part part : partList) {
this.formBuilder.addPart(part);
}
return this;
}

public MultipartFormBuilder add(Consumer<MultipartBody.Builder> consumer) {
consumer.accept(this.formBuilder);
return this;
}

public HttpRequest build() {
formBuilder.setType(MultipartBody.FORM);
MultipartBody formBody = formBuilder.build();
this.request.multipartForm(formBody);
return this.request;
return this.request.multipartForm(this.formBuilder.setType(MultipartBody.FORM).build());
}

public Exchange execute() {
Expand Down

0 comments on commit 6bb5c36

Please sign in to comment.