title: Getting headers and status-code from Volley?
body: <p>Given any arbitrary volley request, how do I capture response headers and statusCode, regardless of success/failure?</p>
  
  <p>Attempts/ideas:</p>
  
  <ul>
  <li><code>JsonResponseRequest</code> (<a href="https://gist.github.com/AlecTaylor/e1fbc2c1545b5a48557ca5b6b677e428" rel="nofollow">gist</a>, minor <a href="https://github.com/mcxiaoke/android-volley/issues/83#issuecomment-127554054" rel="nofollow">edit of this</a>)</li>
  <li>Tried following <a href="https://groups.google.com/d/topic/volley-users/rNTlV-LORzY" rel="nofollow">Accessing all response headers</a> on volley-users from 2013, including github repo: <a href="https://github.com/selecsosi/android-volley/tree/add_response_headers" rel="nofollow">android-volley/add_response_headers</a></li>
  <li>Investigated use of <code>getHeaders</code>, but that seems to be just for requests</li>
  <li><a href="https://developer.android.com/training/volley/request-custom.html" rel="nofollow"><code>GsonRequest</code></a> example from the Android tutorial</li>
  <li><p><a href="http://www.b2cloud.com.au/tutorial/getting-a-server-response-status-200-from-android-volley-library/" rel="nofollow"><code>ServerStatusRequestObject</code></a> blog post</p>
  
  <ul>
  <li>Perhaps there's some way of rewriting this to return a tuple of <code>response.data</code>, headers and <code>response.statusCode</code>?</li>
  </ul></li>
  </ul>
  
  <p>: </p>
  
  <pre><code>@Override
  protected Response parseNetworkResponse(NetworkResponse response) {
      return Response.success(response.statusCode,
                              HttpHeaderParser.parseCacheHeaders(response));
  }
  </code></pre>
  
  <hr>
  
  <p>Edit: to clarify, I've got a simple <code>tuple</code> class:</p>
  
  <pre><code>public final class ErrResStatusHeaders&lt;E, R&gt; {
      public final E error;
      public final R result;
      public final int statusCode;
      public final Map&lt;String, String&gt; headers;
  </code></pre>
  
  <p>And in my <code>Activity</code>:</p>
  
  <pre><code>@Override
  protected ErrResStatusHeaders&lt;String,JSONObject&gt; doInBackground(Void... params) {
      // futures instantiated and utility function(s) called here
  
  [...]
  
  @Override
  protected void onPostExecute(final ErrResStatusHeaders&lt;String,JSONObject&gt; er_res)
  </code></pre>
  
  <p>Example utility function signature:</p>
  
  <pre><code>public ErrResStatusHeaders&lt;String, JSONObject&gt; register_or_login(
                                   final HashMap&lt;String, String&gt; data,
                                   final RequestFuture&lt;JSONObject&gt; register_future,
                                   final RequestFuture&lt;JSONObject&gt; login_future) {
  </code></pre>