Set custom cookie in Retrofit

后端 未结 4 1301
南旧
南旧 2021-01-31 05:23

Is there a way to set a custom cookie on retrofit requests?

Either by using the RequestInterceptor or any other means?

4条回答
  •  说谎
    说谎 (楼主)
    2021-01-31 06:20

    Another way to set a cookie is this way:

    @Headers("Cookie: cookiename=cookievalue")
    @GET("widget/list")
    Call> widgetList();
    

    And here is a dynamic way:

    @GET("user")
    Call getUser(@Header("Cookie") String cookie)
    

提交回复
热议问题