Program: 47229
Project: 47229
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 e The {@link MessageEvent} object used to communicate with the client that sentthe request.
 * @param close Set to true to close the channel after sending the response. By default thechannel is not closed after sending.
 * @param startStopListenerDelegate The {@link StartStopListenerDelegate} object that is usedto notify plugins that the  {@link DLNAResource} is about to start playing.
 * @return The {@link ChannelFuture} object via which the response was sent.
 * @throws IOException
 */
public ChannelFuture answer(HttpResponse output,MessageEvent e,final boolean close,final StartStopListenerDelegate startStopListenerDelegate) throws IOException {
  ChannelFuture future=null;
  long CLoverride=-2;
  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.headers().set(HttpHeaders.Names.CONTENT_TYPE,"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(4);
    if (argument.substring(4).contains("String_Node_Str")) {
      id=argument.substring(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.headers().set("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.headers().set(HttpHeaders.Names.CONTENT_TYPE,dlna.getThumbnailContentType());
        output.headers().set(HttpHeaders.Names.ACCEPT_RANGES,"String_Node_Str");
        output.headers().set(HttpHeaders.Names.EXPIRES,getFUTUREDATE() + "String_Node_Str");
        output.headers().set(HttpHeaders.Names.CONNECTION,"String_Node_Str");
        if (mediaRenderer.isMediaParserV2()) {
          dlna.checkThumbnail();
        }
        inputStream=dlna.getThumbnailInputStream();
      }
 else       if (dlna.getMedia() != null && fileName.contains("String_Node_Str")) {
        output.headers().set(HttpHeaders.Names.CONTENT_TYPE,"String_Node_Str");
        output.headers().set(HttpHeaders.Names.EXPIRES,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 {
        Range.Time splitRange=dlna.getSplitRange();
        if (range.getStart() == null && splitRange.getStart() != null) {
          range.setStart(splitRange.getStart());
        }
        if (range.getEnd() == null && splitRange.getEnd() != null) {
          range.setEnd(splitRange.getEnd());
        }
        long totalsize=dlna.length(mediaRenderer);
        boolean ignoreTranscodeByteRangeRequests=mediaRenderer.ignoreTranscodeByteRangeRequests();
        if (!ignoreTranscodeByteRangeRequests || totalsize != DLNAMediaInfo.TRANS_SIZE || (ignoreTranscodeByteRangeRequests && lowRange == 0 && totalsize == DLNAMediaInfo.TRANS_SIZE)) {
          inputStream=dlna.getInputStream(Range.create(lowRange,highRange,range.getStart(),range.getEnd()),mediaRenderer);
          if (dlna.isResume()) {
            range.setStart(dlna.getResume().getTimeOffset() / (double)1000);
          }
        }
        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.headers().set(subtitleHttpHeader,subtitleUrl);
            }
          }
        }
        String name=dlna.getDisplayName(mediaRenderer);
        if (dlna.isNoName()) {
          name=dlna.getName() + "String_Node_Str" + dlna.getDisplayName(mediaRenderer);
        }
        if (inputStream == null) {
          if (!ignoreTranscodeByteRangeRequests) {
            LOGGER.error("String_Node_Str" + name);
          }
        }
 else {
          startStopListenerDelegate.start(dlna);
          String rendererMimeType=getRendererMimeType(dlna.mimeType(),mediaRenderer);
          if (rendererMimeType != null && !"String_Node_Str".equals(rendererMimeType)) {
            output.headers().set(HttpHeaders.Names.CONTENT_TYPE,rendererMimeType);
          }
          PMS.get().getFrame().setStatusLine("String_Node_Str" + name);
          boolean chunked=mediaRenderer.isChunkedTransfer();
          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.headers().set(HttpHeaders.Names.CONTENT_RANGE,"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;
          }
          highRange=lowRange + CLoverride - (CLoverride > 0 ? 1 : 0);
          if (contentFeatures != null) {
            output.headers().set("String_Node_Str",dlna.getDlnaContentFeatures());
          }
          output.headers().set(HttpHeaders.Names.ACCEPT_RANGES,"String_Node_Str");
          output.headers().set(HttpHeaders.Names.CONNECTION,"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.headers().set(HttpHeaders.Names.CONTENT_TYPE,"String_Node_Str");
    }
 else {
      output.headers().set(HttpHeaders.Names.CONTENT_TYPE,"String_Node_Str");
    }
    output.headers().set(HttpHeaders.Names.ACCEPT_RANGES,"String_Node_Str");
    output.headers().set(HttpHeaders.Names.CONNECTION,"String_Node_Str");
    output.headers().set(HttpHeaders.Names.EXPIRES,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"))) {
    output.headers().set(HttpHeaders.Names.CONTENT_TYPE,"String_Node_Str");
    output.headers().set(HttpHeaders.Names.CACHE_CONTROL,"String_Node_Str");
    output.headers().set(HttpHeaders.Names.EXPIRES,"String_Node_Str");
    output.headers().set(HttpHeaders.Names.ACCEPT_RANGES,"String_Node_Str");
    output.headers().set(HttpHeaders.Names.CONNECTION,"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());
      String profileName="String_Node_Str";
      if (configuration.isAppendProfileName()) {
        profileName="String_Node_Str" + configuration.getProfileName() + "String_Node_Str";
      }
      String serverName=configuration.getServerName();
      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);
      }
      response.append(s);
      inputStream=null;
    }
  }
 else   if (method.equals("String_Node_Str") && (argument.contains("String_Node_Str") || argument.contains("String_Node_Str"))) {
    output.headers().set(HttpHeaders.Names.CONTENT_TYPE,"String_Node_Str");
    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.BROWSERESPONSE_FOOTER);
    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.headers().set(HttpHeaders.Names.CONTENT_TYPE,"String_Node_Str");
    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.headers().set(HttpHeaders.Names.CONTENT_TYPE,"String_Node_Str");
    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.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.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.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);
      LOGGER.trace(response.toString());
    }
  }
 else   if (method.equals("String_Node_Str")) {
    output.headers().set("String_Node_Str",PMS.get().usn());
    output.headers().set("String_Node_Str","String_Node_Str");
    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();
        Socket sock=new Socket(addr,port);
        try (OutputStream out=sock.getOutputStream()){
          out.write(("String_Node_Str" + argument + "String_Node_Str").getBytes());
          out.write(CRLF.getBytes());
          out.write(("String_Node_Str" + PMS.get().usn()).getBytes());
          out.write(CRLF.getBytes());
          out.write(("String_Node_Str" + 0).getBytes());
          out.write(CRLF.getBytes());
          out.write(("String_Node_Str").getBytes());
          out.write(CRLF.getBytes());
          out.write(("String_Node_Str").getBytes());
          out.write(CRLF.getBytes());
          out.write(("String_Node_Str" + addr + "String_Node_Str"+ port).getBytes());
          out.write(CRLF.getBytes());
          out.flush();
          sock.close();
        }
       }
 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);
    }
  }
 else   if (method.equals("String_Node_Str")) {
    output.headers().set(HttpHeaders.Names.CONTENT_TYPE,"String_Node_Str");
    output.headers().set("String_Node_Str","String_Node_Str");
    output.headers().set("String_Node_Str","String_Node_Str");
    output.headers().set("String_Node_Str",PMS.get().usn());
    output.headers().set("String_Node_Str","String_Node_Str");
    response.append("String_Node_Str");
    response.append("String_Node_Str");
    response.append("String_Node_Str");
    response.append("String_Node_Str");
    response.append("String_Node_Str");
    response.append("String_Node_Str");
    response.append("String_Node_Str");
    response.append("String_Node_Str");
    response.append("String_Node_Str").append(DLNAResource.getSystemUpdateId()).append("String_Node_Str");
    response.append("String_Node_Str");
    response.append("String_Node_Str");
  }
  output.headers().set("String_Node_Str",PMS.get().getServerName());
  if (response.length() > 0) {
    byte responseData[]=response.toString().getBytes("String_Node_Str");
    output.headers().set(HttpHeaders.Names.CONTENT_LENGTH,"String_Node_Str" + responseData.length);
    if (!method.equals("String_Node_Str")) {
      ChannelBuffer buf=ChannelBuffers.copiedBuffer(responseData);
      output.setContent(buf);
    }
    future=e.getChannel().write(output);
    if (close) {
      future.addListener(ChannelFutureListener.CLOSE);
    }
  }
 else   if (inputStream != null) {
    if (CLoverride > -2) {
      if (CLoverride > -1 && CLoverride != DLNAMediaInfo.TRANS_SIZE) {
        output.headers().set(HttpHeaders.Names.CONTENT_LENGTH,"String_Node_Str" + CLoverride);
      }
    }
 else {
      int cl=inputStream.available();
      LOGGER.trace("String_Node_Str" + cl);
      output.headers().set(HttpHeaders.Names.CONTENT_LENGTH,"String_Node_Str" + cl);
    }
    if (range.isStartOffsetAvailable() && dlna != null) {
      String timeseekValue=StringUtil.convertTimeToString(range.getStartOrZero(),StringUtil.DURATION_TIME_FORMAT);
      String timetotalValue=dlna.getMedia().getDurationString();
      String timeEndValue=range.isEndLimitAvailable() ? StringUtil.convertTimeToString(range.getEnd(),StringUtil.DURATION_TIME_FORMAT) : timetotalValue;
      output.headers().set("String_Node_Str","String_Node_Str" + timeseekValue + "String_Node_Str"+ timeEndValue+ "String_Node_Str"+ timetotalValue);
      output.headers().set("String_Node_Str","String_Node_Str" + timeseekValue + "String_Node_Str"+ timeEndValue+ "String_Node_Str"+ timetotalValue);
    }
    future=e.getChannel().write(output);
    if (lowRange != DLNAMediaInfo.ENDFILE_POS && !method.equals("String_Node_Str")) {
      ChannelFuture chunkWriteFuture=e.getChannel().write(new ChunkedStream(inputStream,BUFFER_SIZE));
      chunkWriteFuture.addListener(new ChannelFutureListener(){
        @Override public void operationComplete(        ChannelFuture future){
          try {
            PMS.get().getRegistry().reenableGoToSleep();
            inputStream.close();
          }
 catch (          IOException e) {
            LOGGER.debug("String_Node_Str",e);
          }
          future.getChannel().close();
          startStopListenerDelegate.stop();
        }
      }
);
    }
 else {
      try {
        PMS.get().getRegistry().reenableGoToSleep();
        inputStream.close();
      }
 catch (      IOException ioe) {
        LOGGER.debug("String_Node_Str",ioe);
      }
      if (close) {
        future.addListener(ChannelFutureListener.CLOSE);
      }
      startStopListenerDelegate.stop();
    }
  }
 else {
    if (lowRange > 0 && highRange > 0) {
      output.headers().set(HttpHeaders.Names.CONTENT_LENGTH,"String_Node_Str" + (highRange - lowRange + 1));
    }
 else {
      output.headers().set(HttpHeaders.Names.CONTENT_LENGTH,"String_Node_Str");
    }
    future=e.getChannel().write(output);
    if (close) {
      future.addListener(ChannelFutureListener.CLOSE);
    }
  }
  Iterator<String> it=output.headers().names().iterator();
  while (it.hasNext()) {
    String headerName=it.next();
    LOGGER.trace("String_Node_Str" + headerName + "String_Node_Str"+ output.headers().get(headerName));
  }
  return future;
}

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 e The {@link MessageEvent} object used to communicate with the client that sentthe request.
 * @param close Set to true to close the channel after sending the response. By default thechannel is not closed after sending.
 * @param startStopListenerDelegate The {@link StartStopListenerDelegate} object that is usedto notify plugins that the  {@link DLNAResource} is about to start playing.
 * @return The {@link ChannelFuture} object via which the response was sent.
 * @throws IOException
 */
public ChannelFuture answer(HttpResponse output,MessageEvent e,final boolean close,final StartStopListenerDelegate startStopListenerDelegate) throws IOException {
  ChannelFuture future=null;
  long CLoverride=-2;
  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.headers().set(HttpHeaders.Names.CONTENT_TYPE,"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(4);
    if (argument.substring(4).contains("String_Node_Str")) {
      id=argument.substring(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.headers().set("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.headers().set(HttpHeaders.Names.CONTENT_TYPE,dlna.getThumbnailContentType());
        output.headers().set(HttpHeaders.Names.ACCEPT_RANGES,"String_Node_Str");
        output.headers().set(HttpHeaders.Names.EXPIRES,getFUTUREDATE() + "String_Node_Str");
        output.headers().set(HttpHeaders.Names.CONNECTION,"String_Node_Str");
        if (mediaRenderer.isMediaParserV2()) {
          dlna.checkThumbnail();
        }
        inputStream=dlna.getThumbnailInputStream();
      }
 else       if (dlna.getMedia() != null && fileName.contains("String_Node_Str")) {
        output.headers().set(HttpHeaders.Names.CONTENT_TYPE,"String_Node_Str");
        output.headers().set(HttpHeaders.Names.EXPIRES,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 {
        Range.Time splitRange=dlna.getSplitRange();
        if (range.getStart() == null && splitRange.getStart() != null) {
          range.setStart(splitRange.getStart());
        }
        if (range.getEnd() == null && splitRange.getEnd() != null) {
          range.setEnd(splitRange.getEnd());
        }
        long totalsize=dlna.length(mediaRenderer);
        boolean ignoreTranscodeByteRangeRequests=mediaRenderer.ignoreTranscodeByteRangeRequests();
        if (!ignoreTranscodeByteRangeRequests || totalsize != DLNAMediaInfo.TRANS_SIZE || (ignoreTranscodeByteRangeRequests && lowRange == 0 && totalsize == DLNAMediaInfo.TRANS_SIZE)) {
          inputStream=dlna.getInputStream(Range.create(lowRange,highRange,range.getStart(),range.getEnd()),mediaRenderer);
          if (dlna.isResume()) {
            range.setStart(dlna.getResume().getTimeOffset() / (double)1000);
          }
        }
        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.headers().set(subtitleHttpHeader,subtitleUrl);
            }
          }
        }
        String name=dlna.getDisplayName(mediaRenderer);
        if (dlna.isNoName()) {
          name=dlna.getName() + "String_Node_Str" + dlna.getDisplayName(mediaRenderer);
        }
        if (inputStream == null) {
          if (!ignoreTranscodeByteRangeRequests) {
            LOGGER.error("String_Node_Str" + name);
          }
        }
 else {
          startStopListenerDelegate.start(dlna);
          String rendererMimeType=getRendererMimeType(dlna.mimeType(),mediaRenderer);
          if (rendererMimeType != null && !"String_Node_Str".equals(rendererMimeType)) {
            output.headers().set(HttpHeaders.Names.CONTENT_TYPE,rendererMimeType);
          }
          PMS.get().getFrame().setStatusLine("String_Node_Str" + name);
          boolean chunked=mediaRenderer.isChunkedTransfer();
          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.headers().set(HttpHeaders.Names.CONTENT_RANGE,"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;
          }
          highRange=lowRange + CLoverride - (CLoverride > 0 ? 1 : 0);
          if (contentFeatures != null) {
            output.headers().set("String_Node_Str",dlna.getDlnaContentFeatures());
          }
          output.headers().set(HttpHeaders.Names.ACCEPT_RANGES,"String_Node_Str");
          output.headers().set(HttpHeaders.Names.CONNECTION,"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.headers().set(HttpHeaders.Names.CONTENT_TYPE,"String_Node_Str");
    }
 else {
      output.headers().set(HttpHeaders.Names.CONTENT_TYPE,"String_Node_Str");
    }
    output.headers().set(HttpHeaders.Names.ACCEPT_RANGES,"String_Node_Str");
    output.headers().set(HttpHeaders.Names.CONNECTION,"String_Node_Str");
    output.headers().set(HttpHeaders.Names.EXPIRES,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"))) {
    output.headers().set(HttpHeaders.Names.CONTENT_TYPE,"String_Node_Str");
    output.headers().set(HttpHeaders.Names.CACHE_CONTROL,"String_Node_Str");
    output.headers().set(HttpHeaders.Names.EXPIRES,"String_Node_Str");
    output.headers().set(HttpHeaders.Names.ACCEPT_RANGES,"String_Node_Str");
    output.headers().set(HttpHeaders.Names.CONNECTION,"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());
      String profileName="String_Node_Str";
      if (configuration.isAppendProfileName()) {
        profileName="String_Node_Str" + configuration.getProfileName() + "String_Node_Str";
      }
      String serverName=configuration.getServerName();
      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);
      }
      response.append(s);
      inputStream=null;
    }
  }
 else   if (method.equals("String_Node_Str") && (argument.contains("String_Node_Str") || argument.contains("String_Node_Str"))) {
    output.headers().set(HttpHeaders.Names.CONTENT_TYPE,"String_Node_Str");
    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.BROWSERESPONSE_FOOTER);
    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.headers().set(HttpHeaders.Names.CONTENT_TYPE,"String_Node_Str");
    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.headers().set(HttpHeaders.Names.CONTENT_TYPE,"String_Node_Str");
    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.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.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.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);
      LOGGER.trace(response.toString());
    }
  }
 else   if (method.equals("String_Node_Str")) {
    output.headers().set("String_Node_Str",PMS.get().usn());
    output.headers().set("String_Node_Str","String_Node_Str");
    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();
        Socket sock=new Socket(addr,port);
        try (OutputStream out=sock.getOutputStream()){
          out.write(("String_Node_Str" + argument + "String_Node_Str").getBytes());
          out.write(CRLF.getBytes());
          out.write(("String_Node_Str" + PMS.get().usn()).getBytes());
          out.write(CRLF.getBytes());
          out.write(("String_Node_Str" + 0).getBytes());
          out.write(CRLF.getBytes());
          out.write(("String_Node_Str").getBytes());
          out.write(CRLF.getBytes());
          out.write(("String_Node_Str").getBytes());
          out.write(CRLF.getBytes());
          out.write(("String_Node_Str" + addr + "String_Node_Str"+ port).getBytes());
          out.write(CRLF.getBytes());
          out.flush();
          sock.close();
        }
       }
 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);
    }
  }
 else   if (method.equals("String_Node_Str")) {
    output.headers().set(HttpHeaders.Names.CONTENT_TYPE,"String_Node_Str");
    output.headers().set("String_Node_Str","String_Node_Str");
    output.headers().set("String_Node_Str","String_Node_Str");
    output.headers().set("String_Node_Str",PMS.get().usn());
    output.headers().set("String_Node_Str","String_Node_Str");
    response.append("String_Node_Str");
    response.append("String_Node_Str");
    response.append("String_Node_Str");
    response.append("String_Node_Str");
    response.append("String_Node_Str");
    response.append("String_Node_Str");
    response.append("String_Node_Str");
    response.append("String_Node_Str");
    response.append("String_Node_Str").append(DLNAResource.getSystemUpdateId()).append("String_Node_Str");
    response.append("String_Node_Str");
    response.append("String_Node_Str");
  }
  output.headers().set("String_Node_Str",PMS.get().getServerName());
  if (response.length() > 0) {
    byte responseData[]=response.toString().getBytes("String_Node_Str");
    output.headers().set(HttpHeaders.Names.CONTENT_LENGTH,"String_Node_Str" + responseData.length);
    if (!method.equals("String_Node_Str")) {
      ChannelBuffer buf=ChannelBuffers.copiedBuffer(responseData);
      output.setContent(buf);
    }
    future=e.getChannel().write(output);
    if (close) {
      future.addListener(ChannelFutureListener.CLOSE);
    }
  }
 else   if (inputStream != null) {
    if (CLoverride > -2) {
      if (CLoverride > -1 && CLoverride != DLNAMediaInfo.TRANS_SIZE) {
        output.headers().set(HttpHeaders.Names.CONTENT_LENGTH,"String_Node_Str" + CLoverride);
      }
    }
 else {
      int cl=inputStream.available();
      LOGGER.trace("String_Node_Str" + cl);
      output.headers().set(HttpHeaders.Names.CONTENT_LENGTH,"String_Node_Str" + cl);
    }
    if (range.isStartOffsetAvailable() && dlna != null) {
      String timeseekValue=StringUtil.convertTimeToString(range.getStartOrZero(),StringUtil.DURATION_TIME_FORMAT);
      String timetotalValue=dlna.getMedia().getDurationString();
      String timeEndValue=range.isEndLimitAvailable() ? StringUtil.convertTimeToString(range.getEnd(),StringUtil.DURATION_TIME_FORMAT) : timetotalValue;
      output.headers().set("String_Node_Str","String_Node_Str" + timeseekValue + "String_Node_Str"+ timeEndValue+ "String_Node_Str"+ timetotalValue);
      output.headers().set("String_Node_Str","String_Node_Str" + timeseekValue + "String_Node_Str"+ timeEndValue+ "String_Node_Str"+ timetotalValue);
    }
    future=e.getChannel().write(output);
    if (lowRange != DLNAMediaInfo.ENDFILE_POS && !method.equals("String_Node_Str")) {
      ChannelFuture chunkWriteFuture=e.getChannel().write(new ChunkedStream(inputStream,BUFFER_SIZE));
      chunkWriteFuture.addListener(new ChannelFutureListener(){
        @Override public void operationComplete(        ChannelFuture future){
          try {
            PMS.get().getRegistry().reenableGoToSleep();
            inputStream.close();
          }
 catch (          IOException e) {
            LOGGER.debug("String_Node_Str",e);
          }
          future.getChannel().close();
          startStopListenerDelegate.stop();
        }
      }
);
    }
 else {
      try {
        PMS.get().getRegistry().reenableGoToSleep();
        inputStream.close();
      }
 catch (      IOException ioe) {
        LOGGER.debug("String_Node_Str",ioe);
      }
      if (close) {
        future.addListener(ChannelFutureListener.CLOSE);
      }
      startStopListenerDelegate.stop();
    }
  }
 else {
    if (lowRange > 0 && highRange > 0) {
      output.headers().set(HttpHeaders.Names.CONTENT_LENGTH,"String_Node_Str" + (highRange - lowRange + 1));
    }
 else {
      output.headers().set(HttpHeaders.Names.CONTENT_LENGTH,"String_Node_Str");
    }
    future=e.getChannel().write(output);
    if (close) {
      future.addListener(ChannelFutureListener.CLOSE);
    }
  }
  Iterator<String> it=output.headers().names().iterator();
  while (it.hasNext()) {
    String headerName=it.next();
    LOGGER.trace("String_Node_Str" + headerName + "String_Node_Str"+ output.headers().get(headerName));
  }
  return future;
}