0

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);
    }
}

1 Answers1

0

It isn't the client. Are you using CGI as your server or something similar? IIRC this is how headers turn.

https://www.rfc-editor.org/rfc/rfc3875#section-4.1.18

How do I access the HTTP Header of request in a CGI script?

Community
  • 1
  • 1
Yuri Schimke
  • 12,435
  • 3
  • 35
  • 69