RxHttpUtils icon indicating copy to clipboard operation
RxHttpUtils copied to clipboard

添加公共请求头 setHeaders方法无效

Open ityulong opened this issue 5 years ago • 6 comments

看了源码header没有设置进去 private Headers buildHeaders(Request request, Map<String, String> headerMap) { Headers headers = request.headers(); if (headers != null) { Headers.Builder builder = headers.newBuilder(); for (String key : headerMap.keySet()) { builder.add(key, headerMap.get(key)); } return builder.build(); } else { return headers; } }

ityulong avatar Jul 13 '19 09:07 ityulong

咋没设进去,有值哦

image

lygttpod avatar Jul 13 '19 12:07 lygttpod

咋没设进去,有值哦

image request里面并没有这些headers

ityulong avatar Jul 13 '19 15:07 ityulong

抓包也能看到,如还有问题请描述操作步骤及配置代码

image

lygttpod avatar Jul 14 '19 06:07 lygttpod

抓包也能看到,如还有问题请描述操作步骤及配置代码

image

嗯 我去配置这些header也能看到有,但是我配置Content-type(hashMap.put("Content-Type", "application/json;charset=UTF-8");) 无效 。 request 的 Content-Type一直是: application/x-www-form-urlencoded。 用注解的形式配置 Content-Type 可以。

ityulong avatar Jul 15 '19 01:07 ityulong

抓包也能看到,如还有问题请描述操作步骤及配置代码

image

补充一句 我的是post请求 // @Headers("Content-Type: application/json;charset=UTF-8") @FormUrlEncoded @POST("custom/user/login") Observable<MBaseData<LoginInfo>> login(@Field("username") String username, @Field("password") String password, @Field("kaptchaCode") String kaptchaCode, @Field("remember") boolean remember, @Field("userLoginType") int userLoginType

ityulong avatar Jul 15 '19 01:07 ityulong

配置Content-type(hashMap.put("Content-Type", "application/json;charset=UTF-8");) 无效 。 request 的 Content-Type一直是: application/x-www-form-urlencoded。

riveronly avatar Oct 06 '23 04:10 riveronly