I'm getting started working with Android Studio, and I'd like to make a simple application to grab raw HTML from a URL. I've set up Volley to do this using the basic example at http://developer.android.com/training/volley/simple.html, which works fine for public URLs.
The URL I want to access requires specific headers and cookies, which I have the static values of on hand. How can I assign these values to my request?
public void grabHTML(View view) {
RequestQueue queue = Volley.newRequestQueue(this);
String url = getString(R.string.urlpath);
StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
mTextView.setText(response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
mTextView.setText(error.getMessage());
}
});
queue.add(stringRequest);
}
EDIT:
I was able to apply the solution from How are cookies passed in the HTTP protocol? to manually set my request headers.