public RequestOrResponse getDecodedRequest(NetworkRequest networkRequest) throws IOException {
    RequestOrResponse request;
    if (!(networkRequest instanceof LocalRequestResponseChannel.LocalChannelRequest)) {
      InputStream is = networkRequest.getInputStream();
      DataInputStream dis = is instanceof DataInputStream ? (DataInputStream) is : new DataInputStream(is);
      RequestOrResponseType requestType = RequestOrResponseType.values()[dis.readShort()];
      switch (requestType) {
        case PutRequest:
          request = PutRequest.readFrom(dis, clusterMap);
          break;
        case GetRequest:
          request = GetRequest.readFrom(dis, clusterMap);
          break;
        case DeleteRequest:
          request = DeleteRequest.readFrom(dis, clusterMap);
          break;
        case TtlUpdateRequest:
          request = TtlUpdateRequest.readFrom(dis, clusterMap);
          break;
        case UndeleteRequest:
          request = UndeleteRequest.readFrom(dis, clusterMap);
          break;
        case ReplicaMetadataRequest:
          request = ReplicaMetadataRequest.readFrom(dis, clusterMap, findTokenHelper);
          break;
        case AdminRequest:
          request = AdminRequest.readFrom(dis, clusterMap);
          break;
        case ReplicateBlobRequest:
          request = ReplicateBlobRequest.readFrom(dis, clusterMap);
          break;
        case PurgeRequest:
          request = PurgeRequest.readFrom(dis, clusterMap);
          break;
        case FileCopyGetMetaDataRequest:
          request = FileCopyGetMetaDataRequest.readFrom(dis, clusterMap);
          break;
        case FileCopyGetChunkRequest:
          request = FileCopyGetChunkRequest.readFrom(dis, clusterMap);
          break;
        default:
          throw new UnsupportedOperationException("Request type not supported");
      }
    } else {
      request = (RequestOrResponse) ((LocalRequestResponseChannel.LocalChannelRequest) networkRequest).getRequestInfo()
          .getRequest();
      if (request.getRequestType() == RequestOrResponseType.PutRequest) {
        // For PutRequest sent via local channel, we have to create a new PutRequest object to wrap the data buffer as a
        // stream. Also, we need to set the crc value to null since the request is not coming over network.
        PutRequest receivedPutRequest = ((PutRequest) request);
        request = new PutRequest(receivedPutRequest.getCorrelationId(), receivedPutRequest.getClientId(),
            receivedPutRequest.getBlobId(), receivedPutRequest.getBlobProperties(),
            receivedPutRequest.getUsermetadata(), receivedPutRequest.getBlobSize(), receivedPutRequest.getBlobType(),
            receivedPutRequest.getBlobEncryptionKey(), new ByteBufInputStream(receivedPutRequest.getBlob()), null);
      }
    }
    return request;
  }
Get deserialized request
@param networkRequest incoming network request
@return deserialized request
ambry-network/src/main/java/com/github/ambry/network/ServerRequestResponseHelper.java