processResponse method

  1. @override
HandlerResponse processResponse(
  1. Buffer response
)
override

Parses a Buffer containing the response to the command. Returns a _HandlerResponse. The default implementation returns a finished _HandlerResponse with a result which is obtained by calling checkResponse

Implementation

@override
HandlerResponse processResponse(Buffer response) {
  var packet;
  if (_cancelled) {
    _streamController?.close();
    return HandlerResponse(finished: true);
  }
  if (_state == STATE_HEADER_PACKET) {
    packet = checkResponse(response);
  }
  if (packet == null) {
    if (response[0] == PACKET_EOF) {
      log.fine('Got an EOF');
      if (_state == STATE_FIELD_PACKETS) {
        return _handleEndOfFields();
      } else if (_state == STATE_ROW_PACKETS) {
        return _handleEndOfRows();
      }
    } else {
      switch (_state) {
        case STATE_HEADER_PACKET:
          _handleHeaderPacket(response);
          break;
        case STATE_FIELD_PACKETS:
          _handleFieldPacket(response);
          break;
        case STATE_ROW_PACKETS:
          _handleRowPacket(response);
          break;
      }
    }
  } else if (packet is OkPacket) {
    _okPacket = packet;
    if ((packet.serverStatus & SERVER_MORE_RESULTS_EXISTS) == 0) {
      return HandlerResponse(
          finished: true,
          result: ResultsStream(
              _okPacket.insertId, _okPacket.affectedRows, null));
    }
  }
  return HandlerResponse.notFinished;
}