版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/JerryWu145/article/details/84032189
用retrofit设置头信息:
通过@Header 或者@Headers 去添加
区别是 @Header 需要写到参数位置,用于指定可变的头信息
而@Headers 则作用于方法,用于指定固定的头信息
如:
//@Header写法:
@GET("goods")
Call<Goods> getGoods(@Header("Author") String author)
再比如
//@headers写法
@Headers("author=guaju")
@Get("goods")
Call<Goods> getGoods()
当然了,如果大家习惯使用通过OkHttpClient设置的话,也是可以的