title: How to disable checking for WWW-Authenticate header on 401 in HttpUrlConnection on Android?
body: <p>I'm working with a web service that returns 401 when my auth cookie expires, which causes HttpUrlConnection to throw this error:</p>
  
  <pre><code>java.io.IOException: No authentication challenges found
      at libcore.net.http.HttpURLConnectionImpl.getAuthorizationCredentials(HttpURLConnectionImpl.java:427)
      at libcore.net.http.HttpURLConnectionImpl.processAuthHeader(HttpURLConnectionImpl.java:407)
      at libcore.net.http.HttpURLConnectionImpl.processResponseHeaders(HttpURLConnectionImpl.java:356)
      at ...
  </code></pre>
  
  <p>I know this is happening because the server isn't returning a WWW-Authenticate header, but that's out of my control. It's nice that HttpUrlConnection does this checking for me, but this is the real world and we don't always get to work with servers that perfectly follow the HTTP spec. I can't move away from HttpUrlConnection because of other code dependencies, so how do I disable the check so I can actually make use of the response?</p>