code: protected URI createRedirectUri(String servletpath, UserGroupInformation ugi,
        DatanodeID host, HttpServletRequest request, NameNode nn) throws URISyntaxException {
      final String hostname = host instanceof DatanodeInfo?
          ((DatanodeInfo)host).getHostName(): host.getHost();
      final String scheme = request.getScheme();
      final int port = "https".equals(scheme)?
          (Integer)getServletContext().getAttribute("datanode.https.port")
          : host.getInfoPort();
      // Add namenode address to the URL params
      final String nnAddr = NetUtils.toIpPort(nn.getNameNodeAddress());
      final String filename = request.getPathInfo();
      return new URI(scheme, null, hostname, port, servletpath,
          "filename=" + filename + "&ugi=" + ugi +
          JspHelper.getUrlParam(JspHelper.NAMENODE_ADDRESS, nnAddr), null);
    }
docs: Create a URI for redirecting request to a datanode