SJSSoft
SJSSoft

Reputation: 743

How to send Headers in Android

Thanks to all of you in advance :)

I want to send Headers in android to my shoutcast server. I need to connect this address:

 http://s7.voscast.com:8234

and get response. I response is

GET / HTTP/1.(0|1)

Then again send header pass=somePassword

And I want to check what will be the response for pass?

Upvotes: 0

Views: 2523

Answers (1)

erik
erik

Reputation: 4958

assuming that you are using import org.apache.http.client.*

it would be a simple:

HttpGet request = new HttpGet(url);
request.setHeader("X-AUTHORIZATION", token);

There are also methods like setEntity:

HttpPost request = new HttpPost(url);

            request.addHeader("X-AUTHORIZATION", token);
            request.addHeader("Content-Type", "application/json");

            StringEntity se = new StringEntity(jsonPost);
            request.setEntity(se);

see: http://developer.android.com/reference/org/apache/http/client/HttpClient.html

Upvotes: 1

Related Questions