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