Program: 47228
Project: 47228
Buggy source:
/** 
 * Construct a proper HTTP response to a received request. After the response has been created, it is sent and the resulting   {@link ChannelFuture} object is returned.See <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html">RFC-2616</a> for HTTP header field definitions.
 * @param output The {@link HttpResponse} object that will be used to construct the response.
 * @param startStopListenerDelegate The {@link StartStopListenerDelegate} object that is usedto notify plugins that the  {@link DLNAResource} is about to start playing.
 * @throws IOException
 */
public void answer(OutputStream output,StartStopListenerDelegate startStopListenerDelegate) throws IOException {
  this.output=output;
  long CLoverride=-2;
  if (lowRange != 0 || highRange != 0) {
    output(output,http10 ? HTTP_206_OK_10 : HTTP_206_OK);
  }
 else {
    if (soapaction != null && soapaction.contains("String_Node_Str")) {
      output(output,HTTP_500);
    }
 else {
      output(output,http10 ? HTTP_200_OK_10 : HTTP_200_OK);
    }
  }
  StringBuilder response=new StringBuilder();
  DLNAResource dlna=null;
  boolean xbox=mediaRenderer.isXBOX();
  if (argument.startsWith("String_Node_Str")) {
    LOGGER.trace("String_Node_Str" + argument);
    argument=argument.substring(1);
  }
  if ((method.equals("String_Node_Str") || method.equals("String_Node_Str")) && argument.startsWith("String_Node_Str")) {
    output(output,"String_Node_Str");
    response.append(HTMLConsole.servePage(argument.substring(8)));
  }
 else   if ((method.equals("String_Node_Str") || method.equals("String_Node_Str")) && argument.startsWith("String_Node_Str")) {
    String id=argument.substring(argument.indexOf("String_Node_Str") + 4,argument.lastIndexOf('/'));
    id=id.replace("String_Node_Str","String_Node_Str");
    List<DLNAResource> files=PMS.get().getRootFolder(mediaRenderer).getDLNAResources(id,false,0,0,mediaRenderer);
    if (transferMode != null) {
      output(output,"String_Node_Str" + transferMode);
    }
    if (files.size() == 1) {
      dlna=files.get(0);
      String fileName=argument.substring(argument.lastIndexOf('/') + 1);
      if (fileName.startsWith("String_Node_Str")) {
        output(output,"String_Node_Str" + dlna.getThumbnailContentType());
        output(output,"String_Node_Str");
        output(output,"String_Node_Str" + getFUTUREDATE() + "String_Node_Str");
        output(output,"String_Node_Str");
        if (mediaRenderer.isMediaParserV2()) {
          dlna.checkThumbnail();
        }
        inputStream=dlna.getThumbnailInputStream();
      }
 else       if (dlna.getMedia() != null && fileName.contains("String_Node_Str")) {
        output(output,"String_Node_Str");
        output(output,"String_Node_Str" + getFUTUREDATE() + "String_Node_Str");
        DLNAMediaSubtitle sub=dlna.getMediaSubtitle();
        if (sub != null) {
          try {
            if (sub.isExternal()) {
              inputStream=new FileInputStream(sub.getExternalFile());
            }
          }
 catch (          NullPointerException npe) {
            LOGGER.trace("String_Node_Str" + sub);
          }
        }
      }
 else {
        String name=dlna.getDisplayName(mediaRenderer);
        if (dlna.isNoName()) {
          name=dlna.getName() + "String_Node_Str" + dlna.getDisplayName(mediaRenderer);
        }
        inputStream=dlna.getInputStream(Range.create(lowRange,highRange,timeseek,timeRangeEnd),mediaRenderer);
        if (dlna.isResume()) {
          timeseek=dlna.getResume().getTimeOffset() / (double)1000;
        }
        if (inputStream == null) {
          LOGGER.error("String_Node_Str" + name);
        }
 else {
          startStopListenerDelegate.start(dlna);
          output(output,"String_Node_Str" + getRendererMimeType(dlna.mimeType(),mediaRenderer));
          if (dlna.getMedia() != null && !configuration.isDisableSubtitles()) {
            String subtitleHttpHeader=mediaRenderer.getSubtitleHttpHeader();
            if (subtitleHttpHeader != null && !"String_Node_Str".equals(subtitleHttpHeader)) {
              List<DLNAMediaSubtitle> subs=dlna.getMedia().getSubtitleTracksList();
              if (subs != null && !subs.isEmpty()) {
                DLNAMediaSubtitle sub=subs.get(0);
                String subtitleUrl;
                String subExtension=sub.getType().getExtension();
                if (isNotBlank(subExtension)) {
                  subExtension="String_Node_Str" + subExtension;
                }
                subtitleUrl="String_Node_Str" + PMS.get().getServer().getHost() + ':'+ PMS.get().getServer().getPort()+ "String_Node_Str"+ id+ "String_Node_Str"+ subExtension;
                output(output,subtitleHttpHeader + "String_Node_Str" + subtitleUrl);
              }
            }
          }
          PMS.get().getFrame().setStatusLine("String_Node_Str" + name);
          boolean chunked=mediaRenderer.isChunkedTransfer();
          long totalsize=dlna.length(mediaRenderer);
          if (chunked && totalsize == DLNAMediaInfo.TRANS_SIZE) {
            totalsize=-1;
          }
          long remaining=totalsize - lowRange;
          long requested=highRange - lowRange;
          if (requested != 0) {
            long bytes=remaining > -1 ? remaining : inputStream.available();
            if (requested > 0 && bytes > requested) {
              bytes=requested + 1;
            }
            highRange=lowRange + bytes - (bytes > 0 ? 1 : 0);
            LOGGER.trace((chunked ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str" + bytes+ "String_Node_Str");
            output(output,"String_Node_Str" + lowRange + "String_Node_Str"+ (highRange > -1 ? highRange : "String_Node_Str")+ "String_Node_Str"+ (totalsize > -1 ? totalsize : "String_Node_Str"));
            if (chunked && requested < 0 && totalsize < 0) {
              CLoverride=-1;
            }
 else {
              CLoverride=bytes;
            }
          }
 else {
            CLoverride=remaining;
          }
          if (contentFeatures != null) {
            output(output,"String_Node_Str" + dlna.getDlnaContentFeatures());
          }
          if (dlna.getPlayer() == null || xbox) {
            output(output,"String_Node_Str");
          }
          output(output,"String_Node_Str");
        }
      }
    }
  }
 else   if ((method.equals("String_Node_Str") || method.equals("String_Node_Str")) && (argument.toLowerCase().endsWith("String_Node_Str") || argument.toLowerCase().endsWith("String_Node_Str") || argument.toLowerCase().endsWith("String_Node_Str"))) {
    if (argument.toLowerCase().endsWith("String_Node_Str")) {
      output(output,"String_Node_Str");
    }
 else {
      output(output,"String_Node_Str");
    }
    output(output,"String_Node_Str");
    output(output,"String_Node_Str");
    output(output,"String_Node_Str" + getFUTUREDATE() + "String_Node_Str");
    inputStream=getResourceInputStream(argument);
  }
 else   if ((method.equals("String_Node_Str") || method.equals("String_Node_Str")) && (argument.equals("String_Node_Str") || argument.endsWith("String_Node_Str"))) {
    String profileName="String_Node_Str";
    if (configuration.isAppendProfileName()) {
      profileName="String_Node_Str" + configuration.getProfileName() + "String_Node_Str";
    }
    String serverName=configuration.getServerName();
    output(output,CONTENT_TYPE);
    output(output,"String_Node_Str");
    output(output,"String_Node_Str");
    output(output,"String_Node_Str");
    output(output,"String_Node_Str");
    inputStream=getResourceInputStream((argument.equals("String_Node_Str") ? "String_Node_Str" : argument));
    if (argument.equals("String_Node_Str")) {
      byte b[]=new byte[inputStream.available()];
      inputStream.read(b);
      String s=new String(b);
      s=s.replace("String_Node_Str",PMS.get().usn());
      if (PMS.get().getServer().getHost() != null) {
        s=s.replace("String_Node_Str",PMS.get().getServer().getHost());
        s=s.replace("String_Node_Str","String_Node_Str" + PMS.get().getServer().getPort());
      }
      if (xbox) {
        LOGGER.debug("String_Node_Str");
        s=s.replace("String_Node_Str",serverName + profileName + "String_Node_Str");
        s=s.replace("String_Node_Str","String_Node_Str");
        s=s.replace("String_Node_Str","String_Node_Str" + CRLF + "String_Node_Str"+ CRLF+ "String_Node_Str"+ CRLF+ "String_Node_Str"+ CRLF+ "String_Node_Str"+ CRLF+ "String_Node_Str"+ CRLF+ "String_Node_Str"+ CRLF);
      }
 else {
        s=s.replace("String_Node_Str",serverName + profileName);
      }
      inputStream=new ByteArrayInputStream(s.getBytes());
    }
  }
 else   if (method.equals("String_Node_Str") && (argument.contains("String_Node_Str") || argument.contains("String_Node_Str"))) {
    output(output,CONTENT_TYPE_UTF8);
    response.append(HTTPXMLHelper.XML_HEADER);
    response.append(CRLF);
    response.append(HTTPXMLHelper.SOAP_ENCODING_HEADER);
    response.append(CRLF);
    if (soapaction != null && soapaction.contains("String_Node_Str")) {
      response.append(HTTPXMLHelper.XBOX_2);
      response.append(CRLF);
    }
 else     if (soapaction != null && soapaction.contains("String_Node_Str")) {
      response.append(HTTPXMLHelper.XBOX_1);
      response.append(CRLF);
    }
    response.append(HTTPXMLHelper.SOAP_ENCODING_FOOTER);
    response.append(CRLF);
  }
 else   if (method.equals("String_Node_Str") && argument.endsWith("String_Node_Str")) {
    output(output,CONTENT_TYPE_UTF8);
    if (soapaction != null && soapaction.contains("String_Node_Str")) {
      response.append(HTTPXMLHelper.XML_HEADER);
      response.append(CRLF);
      response.append(HTTPXMLHelper.SOAP_ENCODING_HEADER);
      response.append(CRLF);
      response.append(HTTPXMLHelper.PROTOCOLINFO_RESPONSE);
      response.append(CRLF);
      response.append(HTTPXMLHelper.SOAP_ENCODING_FOOTER);
      response.append(CRLF);
    }
  }
 else   if (method.equals("String_Node_Str") && argument.endsWith("String_Node_Str")) {
    output(output,CONTENT_TYPE_UTF8);
    if (soapaction != null && soapaction.contains("String_Node_Str")) {
      response.append(HTTPXMLHelper.XML_HEADER);
      response.append(CRLF);
      response.append(HTTPXMLHelper.SOAP_ENCODING_HEADER);
      response.append(CRLF);
      response.append(HTTPXMLHelper.GETSYSTEMUPDATEID_HEADER);
      response.append(CRLF);
      response.append("String_Node_Str").append(DLNAResource.getSystemUpdateId()).append("String_Node_Str");
      response.append(CRLF);
      response.append(HTTPXMLHelper.GETSYSTEMUPDATEID_FOOTER);
      response.append(CRLF);
      response.append(HTTPXMLHelper.SOAP_ENCODING_FOOTER);
      response.append(CRLF);
    }
 else     if (soapaction != null && soapaction.contains("String_Node_Str")) {
      response.append(HTTPXMLHelper.XML_HEADER);
      response.append(CRLF);
      response.append(HTTPXMLHelper.SOAP_ENCODING_HEADER);
      response.append(CRLF);
      response.append(HTTPXMLHelper.SORTCAPS_RESPONSE);
      response.append(CRLF);
      response.append(HTTPXMLHelper.SOAP_ENCODING_FOOTER);
      response.append(CRLF);
    }
 else     if (soapaction != null && soapaction.contains("String_Node_Str")) {
      response.append(HTTPXMLHelper.XML_HEADER);
      response.append(CRLF);
      response.append(HTTPXMLHelper.SOAP_ENCODING_HEADER);
      response.append(CRLF);
      response.append(HTTPXMLHelper.SAMSUNG_ERROR_RESPONSE);
      response.append(CRLF);
      response.append(HTTPXMLHelper.SOAP_ENCODING_FOOTER);
      response.append(CRLF);
    }
 else     if (soapaction != null && soapaction.contains("String_Node_Str")) {
      response.append(HTTPXMLHelper.XML_HEADER);
      response.append(CRLF);
      response.append(HTTPXMLHelper.SOAP_ENCODING_HEADER);
      response.append(CRLF);
      response.append(HTTPXMLHelper.SEARCHCAPS_RESPONSE);
      response.append(CRLF);
      response.append(HTTPXMLHelper.SOAP_ENCODING_FOOTER);
      response.append(CRLF);
    }
 else     if (soapaction != null && (soapaction.contains("String_Node_Str") || soapaction.contains("String_Node_Str"))) {
      objectID=getEnclosingValue(content,"String_Node_Str","String_Node_Str");
      String containerID=null;
      if ((objectID == null || objectID.length() == 0)) {
        containerID=getEnclosingValue(content,"String_Node_Str","String_Node_Str");
        if (containerID == null || !containerID.contains("String_Node_Str")) {
          objectID="String_Node_Str";
        }
 else {
          objectID=containerID;
          containerID=null;
        }
      }
      Object sI=getEnclosingValue(content,"String_Node_Str","String_Node_Str");
      Object rC=getEnclosingValue(content,"String_Node_Str","String_Node_Str");
      browseFlag=getEnclosingValue(content,"String_Node_Str","String_Node_Str");
      if (sI != null) {
        startingIndex=Integer.parseInt(sI.toString());
      }
      if (rC != null) {
        requestCount=Integer.parseInt(rC.toString());
      }
      response.append(HTTPXMLHelper.XML_HEADER);
      response.append(CRLF);
      response.append(HTTPXMLHelper.SOAP_ENCODING_HEADER);
      response.append(CRLF);
      if (soapaction != null && soapaction.contains("String_Node_Str")) {
        response.append(HTTPXMLHelper.SEARCHRESPONSE_HEADER);
      }
 else {
        response.append(HTTPXMLHelper.BROWSERESPONSE_HEADER);
      }
      response.append(CRLF);
      response.append(HTTPXMLHelper.RESULT_HEADER);
      response.append(HTTPXMLHelper.DIDL_HEADER);
      if (soapaction != null && soapaction.contains("String_Node_Str")) {
        browseFlag="String_Node_Str";
      }
      String searchCriteria=null;
      if (xbox && configuration.getUseCache() && PMS.get().getLibrary() != null && containerID != null) {
        if (containerID.equals("String_Node_Str") && PMS.get().getLibrary().getAlbumFolder() != null) {
          objectID=PMS.get().getLibrary().getAlbumFolder().getResourceId();
        }
 else         if (containerID.equals("String_Node_Str") && PMS.get().getLibrary().getArtistFolder() != null) {
          objectID=PMS.get().getLibrary().getArtistFolder().getResourceId();
        }
 else         if (containerID.equals("String_Node_Str") && PMS.get().getLibrary().getGenreFolder() != null) {
          objectID=PMS.get().getLibrary().getGenreFolder().getResourceId();
        }
 else         if (containerID.equals("String_Node_Str") && PMS.get().getLibrary().getPlaylistFolder() != null) {
          objectID=PMS.get().getLibrary().getPlaylistFolder().getResourceId();
        }
 else         if (containerID.equals("String_Node_Str") && PMS.get().getLibrary().getAllFolder() != null) {
          objectID=PMS.get().getLibrary().getAllFolder().getResourceId();
        }
 else         if (containerID.equals("String_Node_Str")) {
          String artist=getEnclosingValue(content,"String_Node_Str","String_Node_Str");
          if (artist != null) {
            objectID=PMS.get().getLibrary().getArtistFolder().getResourceId();
            searchCriteria=artist;
          }
        }
      }
 else       if (soapaction.contains("String_Node_Str")) {
        searchCriteria=getEnclosingValue(content,"String_Node_Str","String_Node_Str");
      }
      List<DLNAResource> files=PMS.get().getRootFolder(mediaRenderer).getDLNAResources(objectID,browseFlag != null && browseFlag.equals("String_Node_Str"),startingIndex,requestCount,mediaRenderer,searchCriteria);
      if (searchCriteria != null && files != null) {
        UMSUtils.postSearch(files,searchCriteria);
        if (xbox) {
          if (files.size() > 0) {
            files=files.get(0).getChildren();
          }
        }
      }
      int minus=0;
      if (files != null) {
        for (        DLNAResource uf : files) {
          if (xbox && containerID != null) {
            uf.setFakeParentId(containerID);
          }
          if (uf.isCompatible(mediaRenderer) && (uf.getPlayer() == null || uf.getPlayer().isPlayerCompatible(mediaRenderer))) {
            response.append(uf.getDidlString(mediaRenderer));
          }
 else {
            minus++;
          }
        }
      }
      response.append(HTTPXMLHelper.DIDL_FOOTER);
      response.append(HTTPXMLHelper.RESULT_FOOTER);
      response.append(CRLF);
      int filessize=0;
      if (files != null) {
        filessize=files.size();
      }
      response.append("String_Node_Str").append(filessize - minus).append("String_Node_Str");
      response.append(CRLF);
      DLNAResource parentFolder=null;
      if (files != null && filessize > 0) {
        parentFolder=files.get(0).getParent();
      }
      if (browseFlag != null && browseFlag.equals("String_Node_Str") && mediaRenderer.isMediaParserV2() && mediaRenderer.isDLNATreeHack()) {
        int totalCount=startingIndex + requestCount + 1;
        if (filessize - minus <= 0) {
          totalCount=startingIndex;
        }
        response.append("String_Node_Str").append(totalCount).append("String_Node_Str");
      }
 else       if (browseFlag != null && browseFlag.equals("String_Node_Str")) {
        response.append("String_Node_Str").append(((parentFolder != null) ? parentFolder.childrenNumber() : filessize) - minus).append("String_Node_Str");
      }
 else {
        response.append("String_Node_Str");
      }
      response.append(CRLF);
      response.append("String_Node_Str");
      if (parentFolder != null) {
        response.append(parentFolder.getUpdateId());
      }
 else {
        response.append("String_Node_Str");
      }
      response.append("String_Node_Str");
      response.append(CRLF);
      if (soapaction != null && soapaction.contains("String_Node_Str")) {
        response.append(HTTPXMLHelper.SEARCHRESPONSE_FOOTER);
      }
 else {
        response.append(HTTPXMLHelper.BROWSERESPONSE_FOOTER);
      }
      response.append(CRLF);
      response.append(HTTPXMLHelper.SOAP_ENCODING_FOOTER);
      response.append(CRLF);
    }
  }
 else   if (method.equals("String_Node_Str")) {
    if (soapaction == null) {
      return;
    }
    output(output,CONTENT_TYPE_UTF8);
    output(output,"String_Node_Str");
    output(output,"String_Node_Str");
    output(output,"String_Node_Str" + PMS.get().usn());
    output(output,"String_Node_Str" + PMS.get().getServerName());
    output(output,"String_Node_Str");
    output(output,"String_Node_Str");
    output.flush();
    if (soapaction != null) {
      String cb=soapaction.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
      try {
        URL soapActionUrl=new URL(cb);
        String addr=soapActionUrl.getHost();
        int port=soapActionUrl.getPort();
        try (Socket sock=new Socket(addr,port)){
          OutputStream out=sock.getOutputStream();
          output(out,"String_Node_Str" + argument + "String_Node_Str");
          output(out,"String_Node_Str" + PMS.get().usn());
          output(out,"String_Node_Str" + 0);
          output(out,"String_Node_Str");
          output(out,"String_Node_Str");
          output(out,"String_Node_Str" + addr + "String_Node_Str"+ port);
          output(out,CONTENT_TYPE_UTF8);
        }
       }
 catch (      MalformedURLException ex) {
        LOGGER.debug("String_Node_Str" + soapaction + "String_Node_Str",ex);
      }
    }
 else {
      LOGGER.debug("String_Node_Str");
    }
    if (argument.contains("String_Node_Str")) {
      response.append(HTTPXMLHelper.eventHeader("String_Node_Str"));
      response.append(HTTPXMLHelper.eventProp("String_Node_Str"));
      response.append(HTTPXMLHelper.eventProp("String_Node_Str"));
      response.append(HTTPXMLHelper.eventProp("String_Node_Str"));
      response.append(HTTPXMLHelper.EVENT_FOOTER);
    }
 else     if (argument.contains("String_Node_Str")) {
      response.append(HTTPXMLHelper.eventHeader("String_Node_Str"));
      response.append(HTTPXMLHelper.eventProp("String_Node_Str"));
      response.append(HTTPXMLHelper.eventProp("String_Node_Str"));
      response.append(HTTPXMLHelper.eventProp("String_Node_Str","String_Node_Str" + DLNAResource.getSystemUpdateId()));
      response.append(HTTPXMLHelper.EVENT_FOOTER);
    }
  }
  output(output,"String_Node_Str" + PMS.get().getServerName());
  if (response.length() > 0) {
    byte responseData[]=response.toString().getBytes("String_Node_Str");
    output(output,"String_Node_Str" + responseData.length);
    output(output,"String_Node_Str");
    if (!method.equals("String_Node_Str")) {
      output.write(responseData);
    }
  }
 else   if (inputStream != null) {
    if (CLoverride > -2) {
      if (CLoverride > -1 && CLoverride != DLNAMediaInfo.TRANS_SIZE) {
        output(output,"String_Node_Str" + CLoverride);
      }
    }
 else {
      int cl=inputStream.available();
      LOGGER.trace("String_Node_Str" + cl);
      output(output,"String_Node_Str" + cl);
    }
    if (timeseek > 0 && dlna != null) {
      String timeseekValue=StringUtil.convertTimeToString(timeseek,StringUtil.DURATION_TIME_FORMAT);
      String timetotalValue=dlna.getMedia().getDurationString();
      output(output,"String_Node_Str" + timeseekValue + "String_Node_Str"+ timetotalValue+ "String_Node_Str"+ timetotalValue);
      output(output,"String_Node_Str" + timeseekValue + "String_Node_Str"+ timetotalValue+ "String_Node_Str"+ timetotalValue);
    }
    output(output,"String_Node_Str");
    long sendB=0;
    if (lowRange != DLNAMediaInfo.ENDFILE_POS && !method.equals("String_Node_Str")) {
      sendB=sendBytes(inputStream);
    }
    LOGGER.trace("String_Node_Str" + sendB + "String_Node_Str"+ argument);
    PMS.get().getFrame().setStatusLine(null);
  }
 else {
    if (lowRange > 0 && highRange > 0) {
      output(output,"String_Node_Str" + (highRange - lowRange + 1));
    }
 else {
      output(output,"String_Node_Str");
    }
    output(output,"String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Construct a proper HTTP response to a received request. After the response has been created, it is sent and the resulting   {@link ChannelFuture} object is returned.See <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html">RFC-2616</a> for HTTP header field definitions.
 * @param output The {@link HttpResponse} object that will be used to construct the response.
 * @param startStopListenerDelegate The {@link StartStopListenerDelegate} object that is usedto notify plugins that the  {@link DLNAResource} is about to start playing.
 * @throws IOException
 */
public void answer(OutputStream output,StartStopListenerDelegate startStopListenerDelegate) throws IOException {
  this.output=output;
  long CLoverride=-2;
  if (lowRange != 0 || highRange != 0) {
    output(output,http10 ? HTTP_206_OK_10 : HTTP_206_OK);
  }
 else {
    if (soapaction != null && soapaction.contains("String_Node_Str")) {
      output(output,HTTP_500);
    }
 else {
      output(output,http10 ? HTTP_200_OK_10 : HTTP_200_OK);
    }
  }
  StringBuilder response=new StringBuilder();
  DLNAResource dlna=null;
  boolean xbox=mediaRenderer.isXBOX();
  if (argument.startsWith("String_Node_Str")) {
    LOGGER.trace("String_Node_Str" + argument);
    argument=argument.substring(1);
  }
  if ((method.equals("String_Node_Str") || method.equals("String_Node_Str")) && argument.startsWith("String_Node_Str")) {
    output(output,"String_Node_Str");
    response.append(HTMLConsole.servePage(argument.substring(8)));
  }
 else   if ((method.equals("String_Node_Str") || method.equals("String_Node_Str")) && argument.startsWith("String_Node_Str")) {
    String id=argument.substring(argument.indexOf("String_Node_Str") + 4,argument.lastIndexOf('/'));
    id=id.replace("String_Node_Str","String_Node_Str");
    List<DLNAResource> files=PMS.get().getRootFolder(mediaRenderer).getDLNAResources(id,false,0,0,mediaRenderer);
    if (transferMode != null) {
      output(output,"String_Node_Str" + transferMode);
    }
    if (files.size() == 1) {
      dlna=files.get(0);
      String fileName=argument.substring(argument.lastIndexOf('/') + 1);
      if (fileName.startsWith("String_Node_Str")) {
        output(output,"String_Node_Str" + dlna.getThumbnailContentType());
        output(output,"String_Node_Str");
        output(output,"String_Node_Str" + getFUTUREDATE() + "String_Node_Str");
        output(output,"String_Node_Str");
        if (mediaRenderer.isMediaParserV2()) {
          dlna.checkThumbnail();
        }
        inputStream=dlna.getThumbnailInputStream();
      }
 else       if (dlna.getMedia() != null && fileName.contains("String_Node_Str")) {
        output(output,"String_Node_Str");
        output(output,"String_Node_Str" + getFUTUREDATE() + "String_Node_Str");
        List<DLNAMediaSubtitle> subs=dlna.getMedia().getSubtitleTracksList();
        if (subs != null && !subs.isEmpty()) {
          DLNAMediaSubtitle sub=subs.get(0);
          try {
            if (sub.isExternal()) {
              inputStream=new FileInputStream(sub.getExternalFile());
            }
          }
 catch (          NullPointerException npe) {
            LOGGER.trace("String_Node_Str" + sub);
          }
        }
      }
 else {
        String name=dlna.getDisplayName(mediaRenderer);
        if (dlna.isNoName()) {
          name=dlna.getName() + "String_Node_Str" + dlna.getDisplayName(mediaRenderer);
        }
        inputStream=dlna.getInputStream(Range.create(lowRange,highRange,timeseek,timeRangeEnd),mediaRenderer);
        if (dlna.isResume()) {
          timeseek=dlna.getResume().getTimeOffset() / (double)1000;
        }
        if (inputStream == null) {
          LOGGER.error("String_Node_Str" + name);
        }
 else {
          startStopListenerDelegate.start(dlna);
          output(output,"String_Node_Str" + getRendererMimeType(dlna.mimeType(),mediaRenderer));
          if (dlna.getMedia() != null && !configuration.isDisableSubtitles()) {
            String subtitleHttpHeader=mediaRenderer.getSubtitleHttpHeader();
            if (subtitleHttpHeader != null && !"String_Node_Str".equals(subtitleHttpHeader)) {
              List<DLNAMediaSubtitle> subs=dlna.getMedia().getSubtitleTracksList();
              if (subs != null && !subs.isEmpty()) {
                DLNAMediaSubtitle sub=subs.get(0);
                String subtitleUrl;
                String subExtension=sub.getType().getExtension();
                if (isNotBlank(subExtension)) {
                  subExtension="String_Node_Str" + subExtension;
                }
                subtitleUrl="String_Node_Str" + PMS.get().getServer().getHost() + ':'+ PMS.get().getServer().getPort()+ "String_Node_Str"+ id+ "String_Node_Str"+ subExtension;
                output(output,subtitleHttpHeader + "String_Node_Str" + subtitleUrl);
              }
            }
          }
          PMS.get().getFrame().setStatusLine("String_Node_Str" + name);
          boolean chunked=mediaRenderer.isChunkedTransfer();
          long totalsize=dlna.length(mediaRenderer);
          if (chunked && totalsize == DLNAMediaInfo.TRANS_SIZE) {
            totalsize=-1;
          }
          long remaining=totalsize - lowRange;
          long requested=highRange - lowRange;
          if (requested != 0) {
            long bytes=remaining > -1 ? remaining : inputStream.available();
            if (requested > 0 && bytes > requested) {
              bytes=requested + 1;
            }
            highRange=lowRange + bytes - (bytes > 0 ? 1 : 0);
            LOGGER.trace((chunked ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str" + bytes+ "String_Node_Str");
            output(output,"String_Node_Str" + lowRange + "String_Node_Str"+ (highRange > -1 ? highRange : "String_Node_Str")+ "String_Node_Str"+ (totalsize > -1 ? totalsize : "String_Node_Str"));
            if (chunked && requested < 0 && totalsize < 0) {
              CLoverride=-1;
            }
 else {
              CLoverride=bytes;
            }
          }
 else {
            CLoverride=remaining;
          }
          if (contentFeatures != null) {
            output(output,"String_Node_Str" + dlna.getDlnaContentFeatures());
          }
          if (dlna.getPlayer() == null || xbox) {
            output(output,"String_Node_Str");
          }
          output(output,"String_Node_Str");
        }
      }
    }
  }
 else   if ((method.equals("String_Node_Str") || method.equals("String_Node_Str")) && (argument.toLowerCase().endsWith("String_Node_Str") || argument.toLowerCase().endsWith("String_Node_Str") || argument.toLowerCase().endsWith("String_Node_Str"))) {
    if (argument.toLowerCase().endsWith("String_Node_Str")) {
      output(output,"String_Node_Str");
    }
 else {
      output(output,"String_Node_Str");
    }
    output(output,"String_Node_Str");
    output(output,"String_Node_Str");
    output(output,"String_Node_Str" + getFUTUREDATE() + "String_Node_Str");
    inputStream=getResourceInputStream(argument);
  }
 else   if ((method.equals("String_Node_Str") || method.equals("String_Node_Str")) && (argument.equals("String_Node_Str") || argument.endsWith("String_Node_Str"))) {
    String profileName="String_Node_Str";
    if (configuration.isAppendProfileName()) {
      profileName="String_Node_Str" + configuration.getProfileName() + "String_Node_Str";
    }
    String serverName=configuration.getServerName();
    output(output,CONTENT_TYPE);
    output(output,"String_Node_Str");
    output(output,"String_Node_Str");
    output(output,"String_Node_Str");
    output(output,"String_Node_Str");
    inputStream=getResourceInputStream((argument.equals("String_Node_Str") ? "String_Node_Str" : argument));
    if (argument.equals("String_Node_Str")) {
      byte b[]=new byte[inputStream.available()];
      inputStream.read(b);
      String s=new String(b);
      s=s.replace("String_Node_Str",PMS.get().usn());
      if (PMS.get().getServer().getHost() != null) {
        s=s.replace("String_Node_Str",PMS.get().getServer().getHost());
        s=s.replace("String_Node_Str","String_Node_Str" + PMS.get().getServer().getPort());
      }
      if (xbox) {
        LOGGER.debug("String_Node_Str");
        s=s.replace("String_Node_Str",serverName + profileName + "String_Node_Str");
        s=s.replace("String_Node_Str","String_Node_Str");
        s=s.replace("String_Node_Str","String_Node_Str" + CRLF + "String_Node_Str"+ CRLF+ "String_Node_Str"+ CRLF+ "String_Node_Str"+ CRLF+ "String_Node_Str"+ CRLF+ "String_Node_Str"+ CRLF+ "String_Node_Str"+ CRLF);
      }
 else {
        s=s.replace("String_Node_Str",serverName + profileName);
      }
      inputStream=new ByteArrayInputStream(s.getBytes());
    }
  }
 else   if (method.equals("String_Node_Str") && (argument.contains("String_Node_Str") || argument.contains("String_Node_Str"))) {
    output(output,CONTENT_TYPE_UTF8);
    response.append(HTTPXMLHelper.XML_HEADER);
    response.append(CRLF);
    response.append(HTTPXMLHelper.SOAP_ENCODING_HEADER);
    response.append(CRLF);
    if (soapaction != null && soapaction.contains("String_Node_Str")) {
      response.append(HTTPXMLHelper.XBOX_2);
      response.append(CRLF);
    }
 else     if (soapaction != null && soapaction.contains("String_Node_Str")) {
      response.append(HTTPXMLHelper.XBOX_1);
      response.append(CRLF);
    }
    response.append(HTTPXMLHelper.SOAP_ENCODING_FOOTER);
    response.append(CRLF);
  }
 else   if (method.equals("String_Node_Str") && argument.endsWith("String_Node_Str")) {
    output(output,CONTENT_TYPE_UTF8);
    if (soapaction != null && soapaction.contains("String_Node_Str")) {
      response.append(HTTPXMLHelper.XML_HEADER);
      response.append(CRLF);
      response.append(HTTPXMLHelper.SOAP_ENCODING_HEADER);
      response.append(CRLF);
      response.append(HTTPXMLHelper.PROTOCOLINFO_RESPONSE);
      response.append(CRLF);
      response.append(HTTPXMLHelper.SOAP_ENCODING_FOOTER);
      response.append(CRLF);
    }
  }
 else   if (method.equals("String_Node_Str") && argument.endsWith("String_Node_Str")) {
    output(output,CONTENT_TYPE_UTF8);
    if (soapaction != null && soapaction.contains("String_Node_Str")) {
      response.append(HTTPXMLHelper.XML_HEADER);
      response.append(CRLF);
      response.append(HTTPXMLHelper.SOAP_ENCODING_HEADER);
      response.append(CRLF);
      response.append(HTTPXMLHelper.GETSYSTEMUPDATEID_HEADER);
      response.append(CRLF);
      response.append("String_Node_Str").append(DLNAResource.getSystemUpdateId()).append("String_Node_Str");
      response.append(CRLF);
      response.append(HTTPXMLHelper.GETSYSTEMUPDATEID_FOOTER);
      response.append(CRLF);
      response.append(HTTPXMLHelper.SOAP_ENCODING_FOOTER);
      response.append(CRLF);
    }
 else     if (soapaction != null && soapaction.contains("String_Node_Str")) {
      response.append(HTTPXMLHelper.XML_HEADER);
      response.append(CRLF);
      response.append(HTTPXMLHelper.SOAP_ENCODING_HEADER);
      response.append(CRLF);
      response.append(HTTPXMLHelper.SORTCAPS_RESPONSE);
      response.append(CRLF);
      response.append(HTTPXMLHelper.SOAP_ENCODING_FOOTER);
      response.append(CRLF);
    }
 else     if (soapaction != null && soapaction.contains("String_Node_Str")) {
      response.append(HTTPXMLHelper.XML_HEADER);
      response.append(CRLF);
      response.append(HTTPXMLHelper.SOAP_ENCODING_HEADER);
      response.append(CRLF);
      response.append(HTTPXMLHelper.SAMSUNG_ERROR_RESPONSE);
      response.append(CRLF);
      response.append(HTTPXMLHelper.SOAP_ENCODING_FOOTER);
      response.append(CRLF);
    }
 else     if (soapaction != null && soapaction.contains("String_Node_Str")) {
      response.append(HTTPXMLHelper.XML_HEADER);
      response.append(CRLF);
      response.append(HTTPXMLHelper.SOAP_ENCODING_HEADER);
      response.append(CRLF);
      response.append(HTTPXMLHelper.SEARCHCAPS_RESPONSE);
      response.append(CRLF);
      response.append(HTTPXMLHelper.SOAP_ENCODING_FOOTER);
      response.append(CRLF);
    }
 else     if (soapaction != null && (soapaction.contains("String_Node_Str") || soapaction.contains("String_Node_Str"))) {
      objectID=getEnclosingValue(content,"String_Node_Str","String_Node_Str");
      String containerID=null;
      if ((objectID == null || objectID.length() == 0)) {
        containerID=getEnclosingValue(content,"String_Node_Str","String_Node_Str");
        if (containerID == null || !containerID.contains("String_Node_Str")) {
          objectID="String_Node_Str";
        }
 else {
          objectID=containerID;
          containerID=null;
        }
      }
      Object sI=getEnclosingValue(content,"String_Node_Str","String_Node_Str");
      Object rC=getEnclosingValue(content,"String_Node_Str","String_Node_Str");
      browseFlag=getEnclosingValue(content,"String_Node_Str","String_Node_Str");
      if (sI != null) {
        startingIndex=Integer.parseInt(sI.toString());
      }
      if (rC != null) {
        requestCount=Integer.parseInt(rC.toString());
      }
      response.append(HTTPXMLHelper.XML_HEADER);
      response.append(CRLF);
      response.append(HTTPXMLHelper.SOAP_ENCODING_HEADER);
      response.append(CRLF);
      if (soapaction != null && soapaction.contains("String_Node_Str")) {
        response.append(HTTPXMLHelper.SEARCHRESPONSE_HEADER);
      }
 else {
        response.append(HTTPXMLHelper.BROWSERESPONSE_HEADER);
      }
      response.append(CRLF);
      response.append(HTTPXMLHelper.RESULT_HEADER);
      response.append(HTTPXMLHelper.DIDL_HEADER);
      if (soapaction != null && soapaction.contains("String_Node_Str")) {
        browseFlag="String_Node_Str";
      }
      String searchCriteria=null;
      if (xbox && configuration.getUseCache() && PMS.get().getLibrary() != null && containerID != null) {
        if (containerID.equals("String_Node_Str") && PMS.get().getLibrary().getAlbumFolder() != null) {
          objectID=PMS.get().getLibrary().getAlbumFolder().getResourceId();
        }
 else         if (containerID.equals("String_Node_Str") && PMS.get().getLibrary().getArtistFolder() != null) {
          objectID=PMS.get().getLibrary().getArtistFolder().getResourceId();
        }
 else         if (containerID.equals("String_Node_Str") && PMS.get().getLibrary().getGenreFolder() != null) {
          objectID=PMS.get().getLibrary().getGenreFolder().getResourceId();
        }
 else         if (containerID.equals("String_Node_Str") && PMS.get().getLibrary().getPlaylistFolder() != null) {
          objectID=PMS.get().getLibrary().getPlaylistFolder().getResourceId();
        }
 else         if (containerID.equals("String_Node_Str") && PMS.get().getLibrary().getAllFolder() != null) {
          objectID=PMS.get().getLibrary().getAllFolder().getResourceId();
        }
 else         if (containerID.equals("String_Node_Str")) {
          String artist=getEnclosingValue(content,"String_Node_Str","String_Node_Str");
          if (artist != null) {
            objectID=PMS.get().getLibrary().getArtistFolder().getResourceId();
            searchCriteria=artist;
          }
        }
      }
 else       if (soapaction.contains("String_Node_Str")) {
        searchCriteria=getEnclosingValue(content,"String_Node_Str","String_Node_Str");
      }
      List<DLNAResource> files=PMS.get().getRootFolder(mediaRenderer).getDLNAResources(objectID,browseFlag != null && browseFlag.equals("String_Node_Str"),startingIndex,requestCount,mediaRenderer,searchCriteria);
      if (searchCriteria != null && files != null) {
        UMSUtils.postSearch(files,searchCriteria);
        if (xbox) {
          if (files.size() > 0) {
            files=files.get(0).getChildren();
          }
        }
      }
      int minus=0;
      if (files != null) {
        for (        DLNAResource uf : files) {
          if (xbox && containerID != null) {
            uf.setFakeParentId(containerID);
          }
          if (uf.isCompatible(mediaRenderer) && (uf.getPlayer() == null || uf.getPlayer().isPlayerCompatible(mediaRenderer))) {
            response.append(uf.getDidlString(mediaRenderer));
          }
 else {
            minus++;
          }
        }
      }
      response.append(HTTPXMLHelper.DIDL_FOOTER);
      response.append(HTTPXMLHelper.RESULT_FOOTER);
      response.append(CRLF);
      int filessize=0;
      if (files != null) {
        filessize=files.size();
      }
      response.append("String_Node_Str").append(filessize - minus).append("String_Node_Str");
      response.append(CRLF);
      DLNAResource parentFolder=null;
      if (files != null && filessize > 0) {
        parentFolder=files.get(0).getParent();
      }
      if (browseFlag != null && browseFlag.equals("String_Node_Str") && mediaRenderer.isMediaParserV2() && mediaRenderer.isDLNATreeHack()) {
        int totalCount=startingIndex + requestCount + 1;
        if (filessize - minus <= 0) {
          totalCount=startingIndex;
        }
        response.append("String_Node_Str").append(totalCount).append("String_Node_Str");
      }
 else       if (browseFlag != null && browseFlag.equals("String_Node_Str")) {
        response.append("String_Node_Str").append(((parentFolder != null) ? parentFolder.childrenNumber() : filessize) - minus).append("String_Node_Str");
      }
 else {
        response.append("String_Node_Str");
      }
      response.append(CRLF);
      response.append("String_Node_Str");
      if (parentFolder != null) {
        response.append(parentFolder.getUpdateId());
      }
 else {
        response.append("String_Node_Str");
      }
      response.append("String_Node_Str");
      response.append(CRLF);
      if (soapaction != null && soapaction.contains("String_Node_Str")) {
        response.append(HTTPXMLHelper.SEARCHRESPONSE_FOOTER);
      }
 else {
        response.append(HTTPXMLHelper.BROWSERESPONSE_FOOTER);
      }
      response.append(CRLF);
      response.append(HTTPXMLHelper.SOAP_ENCODING_FOOTER);
      response.append(CRLF);
    }
  }
 else   if (method.equals("String_Node_Str")) {
    if (soapaction == null) {
      return;
    }
    output(output,CONTENT_TYPE_UTF8);
    output(output,"String_Node_Str");
    output(output,"String_Node_Str");
    output(output,"String_Node_Str" + PMS.get().usn());
    output(output,"String_Node_Str" + PMS.get().getServerName());
    output(output,"String_Node_Str");
    output(output,"String_Node_Str");
    output.flush();
    if (soapaction != null) {
      String cb=soapaction.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
      try {
        URL soapActionUrl=new URL(cb);
        String addr=soapActionUrl.getHost();
        int port=soapActionUrl.getPort();
        try (Socket sock=new Socket(addr,port)){
          OutputStream out=sock.getOutputStream();
          output(out,"String_Node_Str" + argument + "String_Node_Str");
          output(out,"String_Node_Str" + PMS.get().usn());
          output(out,"String_Node_Str" + 0);
          output(out,"String_Node_Str");
          output(out,"String_Node_Str");
          output(out,"String_Node_Str" + addr + "String_Node_Str"+ port);
          output(out,CONTENT_TYPE_UTF8);
        }
       }
 catch (      MalformedURLException ex) {
        LOGGER.debug("String_Node_Str" + soapaction + "String_Node_Str",ex);
      }
    }
 else {
      LOGGER.debug("String_Node_Str");
    }
    if (argument.contains("String_Node_Str")) {
      response.append(HTTPXMLHelper.eventHeader("String_Node_Str"));
      response.append(HTTPXMLHelper.eventProp("String_Node_Str"));
      response.append(HTTPXMLHelper.eventProp("String_Node_Str"));
      response.append(HTTPXMLHelper.eventProp("String_Node_Str"));
      response.append(HTTPXMLHelper.EVENT_FOOTER);
    }
 else     if (argument.contains("String_Node_Str")) {
      response.append(HTTPXMLHelper.eventHeader("String_Node_Str"));
      response.append(HTTPXMLHelper.eventProp("String_Node_Str"));
      response.append(HTTPXMLHelper.eventProp("String_Node_Str"));
      response.append(HTTPXMLHelper.eventProp("String_Node_Str","String_Node_Str" + DLNAResource.getSystemUpdateId()));
      response.append(HTTPXMLHelper.EVENT_FOOTER);
    }
  }
  output(output,"String_Node_Str" + PMS.get().getServerName());
  if (response.length() > 0) {
    byte responseData[]=response.toString().getBytes("String_Node_Str");
    output(output,"String_Node_Str" + responseData.length);
    output(output,"String_Node_Str");
    if (!method.equals("String_Node_Str")) {
      output.write(responseData);
    }
  }
 else   if (inputStream != null) {
    if (CLoverride > -2) {
      if (CLoverride > -1 && CLoverride != DLNAMediaInfo.TRANS_SIZE) {
        output(output,"String_Node_Str" + CLoverride);
      }
    }
 else {
      int cl=inputStream.available();
      LOGGER.trace("String_Node_Str" + cl);
      output(output,"String_Node_Str" + cl);
    }
    if (timeseek > 0 && dlna != null) {
      String timeseekValue=StringUtil.convertTimeToString(timeseek,StringUtil.DURATION_TIME_FORMAT);
      String timetotalValue=dlna.getMedia().getDurationString();
      output(output,"String_Node_Str" + timeseekValue + "String_Node_Str"+ timetotalValue+ "String_Node_Str"+ timetotalValue);
      output(output,"String_Node_Str" + timeseekValue + "String_Node_Str"+ timetotalValue+ "String_Node_Str"+ timetotalValue);
    }
    output(output,"String_Node_Str");
    long sendB=0;
    if (lowRange != DLNAMediaInfo.ENDFILE_POS && !method.equals("String_Node_Str")) {
      sendB=sendBytes(inputStream);
    }
    LOGGER.trace("String_Node_Str" + sendB + "String_Node_Str"+ argument);
    PMS.get().getFrame().setStatusLine(null);
  }
 else {
    if (lowRange > 0 && highRange > 0) {
      output(output,"String_Node_Str" + (highRange - lowRange + 1));
    }
 else {
      output(output,"String_Node_Str");
    }
    output(output,"String_Node_Str");
  }
}