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

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

Open
ityulong opened this issue Jul 13, 2019 · 6 comments
Open

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

ityulong opened this issue Jul 13, 2019 · 6 comments

Comments

@ityulong
Copy link

看了源码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;
}
}

@lygttpod
Copy link
Owner

咋没设进去,有值哦

image

@ityulong
Copy link
Author

咋没设进去,有值哦

image
request里面并没有这些headers

@lygttpod
Copy link
Owner

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

image

@ityulong
Copy link
Author

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

image

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

@ityulong
Copy link
Author

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

image

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

@riveronly
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants