I dont know why Retrofit is adding "HTTP_" before every custom header I try to add.
public interface UserService {
@POST("api/users/details/bio/update/")
Call<User> updateBio(@Header("Authorization") String text,@Body User user);
}
When I execute this code, on my server it shows header as "HTTP_AUTHORIZATION".
Here are the logs when I send the request to the server
12-29 07:41:46.528 3207-3207/com.application.university V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@cd0612c
12-29 07:41:46.528 3207-3207/com.application.university V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@65cf7f5
12-29 07:41:46.543 3207-3207/com.application.university V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@312bfb
12-29 07:41:46.544 3207-3207/com.application.university V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@f786418
12-29 07:41:46.638 3207-3212/com.application.university I/art: Do partial code cache collection, code=457KB, data=386KB
12-29 07:41:46.639 3207-3212/com.application.university I/art: After code cache collection, code=457KB, data=386KB
12-29 07:41:46.639 3207-3212/com.application.university I/art: Increasing code cache capacity to 2MB
12-29 07:41:46.639 3207-3212/com.application.university I/art: Compiler allocated 7MB to compile void android.widget.TextView.<init>(android.content.Context, android.util.AttributeSet, int, int)
12-29 07:41:47.055 3207-3207/com.application.university I/Toast: Show toast from OpPackageName:com.application.university, PackageName:com.application.university
--------- beginning of system
I also tried it with an Interceptor class. And it still doesn't show any difference.
public class AuthenticationInterceptor implements Interceptor {
private String authToken;
public AuthenticationInterceptor(String token) {
this.authToken = token;
}
@Override
public Response intercept(Chain chain) throws IOException {
Request original = chain.request();
Request.Builder builder = original.newBuilder().header("Authorization", authToken);
Request request = builder.build();
return chain.proceed(request);
}
}