mozilla-mobile / android-components

⚠️ This project moved to a new repository. It is now developed and maintained at: https://github.com/mozilla-mobile/firefox-android

Home Page:https://github.com/mozilla-mobile/firefox-android

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to modify headers

c2r1w opened this issue · comments

How to modify headers

or implement bellow code



val request = Request(
   url = "https://api.github.com/repos/mozilla-mobile/android-components/issues",
   headers = MutableHeaders(
       "User-Agent" to "AwesomeBrowser/1.0",
       "Accept" to "application/json; q=0.5",
       "Accept" to "application/vnd.github.v3+json"))

client.fetch(request).use { response ->
    val server = response.headers.get('Server')
    val result = response.body.string()
}

┆Issue is synchronized with this Jira Task

You can assign a MutableHeaders object to a val and modify it using the set method, e.g.,

 val headers = MutableHeaders()
 headers.set("Accept-Encoding", "gzip, deflate")
 headers.set("Connection", "keep-alive")
 headers.set("Accept-Encoding", "gzip")