public Map<String, Header> getChallenges(
     final HttpHost authhost, final HttpResponse response, final HttpContext context)
     throws MalformedChallengeException {
   Args.notNull(response, "HTTP response");
   final Header[] headers = response.getHeaders(this.headerName);
   final Map<String, Header> map = new HashMap<String, Header>(headers.length);
   for (final Header header : headers) {
     final CharArrayBuffer buffer;
     int pos;
     if (header instanceof FormattedHeader) {
       buffer = ((FormattedHeader) header).getBuffer();
       pos = ((FormattedHeader) header).getValuePos();
     } else {
       final String s = header.getValue();
       if (s == null) {
         throw new MalformedChallengeException("Header value is null");
       }
       buffer = new CharArrayBuffer(s.length());
       buffer.append(s);
       pos = 0;
     }
     while (pos < buffer.length() && HTTP.isWhitespace(buffer.charAt(pos))) {
       pos++;
     }
     final int beginIndex = pos;
     while (pos < buffer.length() && !HTTP.isWhitespace(buffer.charAt(pos))) {
       pos++;
     }
     final int endIndex = pos;
     final String s = buffer.substring(beginIndex, endIndex);
     map.put(s.toLowerCase(Locale.ENGLISH), header);
   }
   return map;
 }
 public boolean isAuthenticationRequested(
     final HttpHost authhost, final HttpResponse response, final HttpContext context) {
   Args.notNull(response, "HTTP response");
   final int status = response.getStatusLine().getStatusCode();
   return status == this.challengeCode;
 }