How do i use headers on Retrofit or OkHttp?

Viewed 145

Headers are used with request queries in a php script.

I want to use the same headers in retrofit or Okhttp in android, but I don't know what to write instead of headers written in php.

Here are the headers I want to use in android written in php:

function init_ch($u)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HEADER, TRUE);
    curl_setopt($ch, CURLOPT_NOBODY, TRUE);
    curl_setopt($ch, CURLOPT_URL, $u);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Mobile Safari/537.3");
    curl_setopt($ch, CURLOPT_REFERER, $u);
    curl_setopt($ch, CURLOPT_ACCEPT_ENCODING, "utf-8,cp1251");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_TIMEOUT, 5);
    return $ch;
}

I have no idea what to write instead of these headers, can you help with this?

0 Answers
Related