@Override
 public boolean startRequest(
     HttpMethod method, String methodString, ByteBuffer uri, HttpVersion httpVersion) {
   Connector connector = getConnector();
   String scheme =
       connector.getConnectionFactory(SslConnectionFactory.class) != null ? "https" : "http";
   headers.put(HTTPSPDYHeader.SCHEME.name(version), scheme);
   headers.put(HTTPSPDYHeader.METHOD.name(version), methodString);
   headers.put(
       HTTPSPDYHeader.URI.name(version),
       BufferUtil.toUTF8String(uri)); // TODO handle bad encodings
   headers.put(HTTPSPDYHeader.VERSION.name(version), httpVersion.asString());
   return false;
 }
    @Override
    public void reply(ReplyInfo replyInfo, Callback handler) {
      try {
        Fields headers = new Fields(replyInfo.getHeaders(), false);

        headers.remove(HTTPSPDYHeader.SCHEME.name(version));

        String status = headers.remove(HTTPSPDYHeader.STATUS.name(version)).value();
        Matcher matcher = statusRegexp.matcher(status);
        matcher.matches();
        int code = Integer.parseInt(matcher.group(1));
        String reason = matcher.group(2).trim();

        HttpVersion httpVersion =
            HttpVersion.fromString(headers.remove(HTTPSPDYHeader.VERSION.name(version)).value());

        // Convert the Host header from a SPDY special header to a normal header
        Fields.Field host = headers.remove(HTTPSPDYHeader.HOST.name(version));
        if (host != null) headers.put("host", host.value());

        HttpFields fields = new HttpFields();
        for (Fields.Field header : headers) {
          String name = camelize(header.name());
          fields.put(name, header.value());
        }

        // TODO: handle better the HEAD last parameter
        HttpGenerator.ResponseInfo info =
            new HttpGenerator.ResponseInfo(httpVersion, fields, -1, code, reason, false);
        send(info, null, replyInfo.isClose());

        if (replyInfo.isClose()) completed();

        handler.succeeded();
      } catch (IOException x) {
        handler.failed(x);
      }
    }