How to specify a default user agent for okhttp 2.x requests

后端 未结 6 1498
心在旅途
心在旅途 2021-01-31 02:01

I am using okhttp 2.0 in my Android app and didn\'t find a way to set some common User Agent for all outgoing requests.

I thought I could do something like



        
6条回答
  •  耶瑟儿~
    2021-01-31 02:24

    OkHttp v2.1 which is set to be released in the next few weeks will automatically set a User-Agent header if one is not already set.

    As of now there isn't a good way to add this header to every request in a centralized way. The only workaround is to include the header manually for every Request that is created.

提交回复
热议问题