Android Retrofit2 设置请求头Header

@Headers设置固定请求头

1
2
3
4
5
6
7
8
9
public interface HttpService {
@Headers({
"header1:headerValue1",
"header2:headerValue2",
"header3:headerValue3",
})
@POST("Login")
Call<Account> login(@Body ReqLogin body);
}

Click and drag to move

@Header设置上可变请求头

1
2
3
4
public interface HttpService {
@POST("login")
Call<Account> login(@Body ReqLogin body, @Header("token") String token);
}

Click and drag to move