m_queryString = "";
    public synchronized void handle(byte[] buffer, int length)      throws IOException {      // String used to parse headers - header names are US-ASCII      // encoded and anchored to start of line.      final String asciiString = new String(buffer, 0, length, "US-ASCII");      debug("HTTP Request/Response :" + asciiString);      if (m_matcher.contains(asciiString, m_requestLinePattern)) {        // Packet is start of new request message.        final MatchResult matchResult = m_matcher.getMatch();        // Grab match results because endMessage plays with        // out Matcher.        final String newMethod = matchResult.group(1);        final String newURL = matchResult.group(2);        final String newQueryString = matchResult.group(3);        endMessage();        m_method = newMethod;        m_parsingHeaders = true;        if (m_method.equals("GET") ||            m_method.equals("HEAD")) {          m_handlingBody = false;          m_url = newURL;          m_queryString = newQueryString == null ? "" : newQueryString;        }        else if (m_method.equals("DELETE") ||                 m_method.equals("TRACE")) {          m_handlingBody = false;          if (newQueryString != null) {            m_url = newURL + newQueryString;            m_queryString = "";          }          else {            m_url = newURL;          }        }        else if (m_method.equals("OPTIONS") ||                 m_method.equals("PUT") ||                 m_method.equals("POST")) {          m_handlingBody = true;          m_entityBodyByteStream.reset();          m_contentLength = -1;          m_contentType = null;          if (newQueryString != null) {            m_url = newURL + newQueryString;            m_queryString = "";          }          else {            m_url = newURL;          }        }        else {          warn("Ignoring '" + m_method + "' from " + m_connectionDetails);          return;        }        if (!m_url.startsWith("http")) {          // Relative URL given, calculate absolute URL.          m_url = m_connectionDetails.getURLBase("http") + m_url;        }        // Stuff we do at start of request only.        m_time = s_lastResponseTime > 0 ?          System.currentTimeMillis() - s_lastResponseTime : 0;        m_headers.clear();      }      // Stuff we do whatever.      if (m_parsingHeaders) {        for (int i = 0; i < s_mirroredHeaders.length; i++) {          if (m_matcher.contains(asciiString,                                 m_mirroredHeaderPatterns[i])) {            m_headers.add(              new NVPair(s_mirroredHeaders[i],                         m_matcher.getMatch().group(1).trim()));          }        }        /*          if (m_matcher.contains(asciiString,          m_basicAuthorizationHeaderPattern)) {          final String decoded =          Codecs.base64Decode(          m_matcher.getMatch().group(1).trim());          final int colon = decoded.indexOf(":");          if (colon < 0) {          warn("Could not decode Authorization header");          }          else {          outputProperty(          "parameter.basicAuthenticationUser",          decoded.substring(0, colon));          outputProperty(          "parameter.basicAuthenticationPassword",          decoded.substring(colon+1));          outputProperty(          "parameter.basicAuthenticationRealm",          HTTPPluginTCPProxyResponseFilter.          getLastAuthenticationRealm());          }          }        */        if (m_handlingBody) {          // Look for the content length and type in the header.          if (m_matcher.contains(asciiString,                                 m_contentLengthPattern)) {            m_contentLength =              Integer.parseInt(                m_matcher.getMatch().group(1).trim());          }          if (m_matcher.contains(asciiString,                                 m_contentTypePattern)) {            m_contentType = m_matcher.getMatch().group(1).trim();            m_headers.add(              new NVPair("Content-Type", m_contentType));          }          if (m_matcher.contains(asciiString,                                 m_messageBodyPattern)) {            m_parsingHeaders = false;            final MatchResult matchResult = m_matcher.getMatch();            final int beginOffset = matchResult.beginOffset(1);            final int endOffset = matchResult.endOffset(1);            addToEntityBody(buffer, beginOffset, endOffset - beginOffset);          }        }      }      else {        if (m_handlingBody) {          addToEntityBody(buffer, 0, length);        }        else {          warn("UNEXPECTED - Not parsing headers or handling POST");        }      }    }