Skip to content

Commit 27233ae

Browse files
修复GET、Head请求参数没上传问题
1 parent 0936d7d commit 27233ae

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

rxhttp/src/main/java/rxhttp/wrapper/utils/BuildUtil.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import okhttp3.RequestBody;
2323
import rxhttp.wrapper.entity.UpFile;
2424
import rxhttp.wrapper.param.IRequest;
25+
import rxhttp.wrapper.param.Method;
2526

2627
/**
2728
* User: ljx
@@ -33,10 +34,12 @@ public class BuildUtil {
3334
private static final MediaType MEDIA_TYPE_JSON = MediaType.parse("application/json;charset=utf-8");
3435

3536
public static Request buildRequest(@NonNull IRequest r) {
37+
Method method = r.getMethod();
38+
String url = method == Method.GET || method == Method.HEAD ? r.getUrl() : r.getSimpleUrl();
3639
Builder builder = new Request.Builder()
37-
.url(r.getSimpleUrl())
40+
.url(url)
3841
.tag(r.getTag())
39-
.method(r.getMethod().name(), r.getRequestBody());
42+
.method(method.name(), r.getRequestBody());
4043
CacheControl cacheControl = r.getCacheControl();
4144
if (cacheControl != null) {
4245
builder.cacheControl(cacheControl);

rxhttp/src/main/java/rxhttp/wrapper/utils/LogUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ public static void log(@NonNull Response response, String result) {
5151

5252
public static void log(@NonNull Param param) {
5353
if (!isDebug) return;
54-
String requestInfo = "------------------- request start " +
55-
param.getClass().getSimpleName() + " -------------------" +
54+
String requestInfo = "------------------- request start Method=" + param.getMethod().name() +
55+
" " + param.getClass().getSimpleName() + " -------------------" +
5656
" \nurl = " + param.getUrl() +
5757
"\n\nheaders = " + param.getHeaders();
5858

0 commit comments

Comments
 (0)