code: private static CouchbaseResponse handleCommonResponseMessages(BinaryRequest request, FullBinaryMemcacheResponse msg,
          ResponseStatus status, boolean seqOnMutation) {
          CouchbaseResponse response = null;
          ByteBuf content = msg.content();
          long cas = msg.getCAS();
          short statusCode = msg.getStatus();
          String bucket = request.bucket();
  
          if (request instanceof GetRequest || request instanceof ReplicaGetRequest) {
              int flags = msg.getExtrasLength() > 0 ? msg.getExtras().getInt(0) : 0;
              response = new GetResponse(status, statusCode, cas, flags, bucket, content, request);
          } else if (request instanceof GetBucketConfigRequest) {
              response = new GetBucketConfigResponse(status, statusCode, bucket, content,
                      ((GetBucketConfigRequest) request).hostname());
          } else if (request instanceof InsertRequest) {
              MutationToken descr = extractToken(bucket, seqOnMutation, status.isSuccess(), msg.getExtras(), request.partition());
              response = new InsertResponse(status, statusCode, cas, bucket, content, descr, request);
          } else if (request instanceof UpsertRequest) {
              MutationToken descr = extractToken(bucket, seqOnMutation, status.isSuccess(), msg.getExtras(), request.partition());
              response = new UpsertResponse(status, statusCode, cas, bucket, content, descr, request);
          } else if (request instanceof ReplaceRequest) {
              MutationToken descr = extractToken(bucket, seqOnMutation, status.isSuccess(), msg.getExtras(), request.partition());
              response = new ReplaceResponse(status, statusCode, cas, bucket, content, descr, request);
          } else if (request instanceof RemoveRequest) {
              MutationToken descr = extractToken(bucket, seqOnMutation, status.isSuccess(), msg.getExtras(), request.partition());
              response = new RemoveResponse(status, statusCode, cas, bucket, content, descr, request);
          }
  
          return response;
      }
docs: Helper method to decode all common response messages.
  
  @param request the current request.
  @param msg the current response message.
  @param status the response status code.
  @return the decoded response or null if none did match.