Direct Known Subclasses:
SSDPSearchResponse

public class SSDPResponseextends HTTPResponse
Represents an SSDP response message.

This class extends HTTPResponse to handle SSDP (Simple Service Discovery Protocol) response messages used in UPnP device discovery. It manages the creation and parsing of responses to M-SEARCH requests from control points.

Key features:

  • SSDP response header management
  • ST (Search Target) header handling
  • USN (Unique Service Name) header management
  • MYNAME header support for Intel compatibility
  • HTTP/1.1 version compliance

This class is used by UPnP devices to respond to discovery searches from control points, providing information about device capabilities and availability. It handles both standard UPnP responses and vendor-specific extensions.

  • Constructor Details

    • SSDPResponse

      public SSDPResponse()
      Creates an empty response declaring HTTP 1.1.
    • SSDPResponse

      public SSDPResponse(InputStream in)
      Creates a response whose headers are parsed from a stream.
      Parameters:
      in - the response stream to parse the headers from
  • Method Details

    • setST

      public void setST(String value)
      Sets the search target header.
      Parameters:
      value - the search target, identifying which service answered
    • getST

      public String getST()
      Gets the search target header.
      Returns:
      the ST header, or null if this response carries none
    • setLocation

      public void setLocation(String value)
      Sets the Location header to a device description URL.
      Parameters:
      value - the URL of the device description document that was searched
    • getLocation

      public String getLocation()
      Gets the Location header.
      Returns:
      the Location header, or null if this response carries none
    • setUSN

      public void setUSN(String value)
      Sets the unique service name header.
      Parameters:
      value - the unique service name identifying the answering device
    • getUSN

      public String getUSN()
      Gets the unique service name header.
      Returns:
      the USN header, or null if this response carries none
    • setMYNAME

      public void setMYNAME(String value)
      Sets the MYNAME header, Intel's friendly-name extension.
      Parameters:
      value - the friendly device name, for Intel's MYNAME extension
    • getMYNAME

      public String getMYNAME()
      Gets the MYNAME header.
      Returns:
      the MYNAME header, or null if this response carries none
    • setLeaseTime

      public void setLeaseTime(int len)
      Sets the CACHE-CONTROL max-age header from a lifetime in seconds.
      Parameters:
      len - the advertisement lifetime in seconds, advertised as max-age
    • getLeaseTime

      public int getLeaseTime()
      Gets the advertisement lifetime from the CACHE-CONTROL header.
      Returns:
      the max-age value in seconds, 0 if the header is absent or unparsable
    • setBootId

      public void setBootId(int bootId)
      Sets the boot identifier header.
      Parameters:
      bootId - the device's boot identifier, bumped on each reboot
    • getBootId

      public int getBootId()
      Gets the boot identifier header.
      Returns:
      the BOOTID.UPNP.ORG value, 0 if this response carries none
    • getHeader

      public String getHeader()
      Renders the whole response as a status line, headers and blank line.
      Overrides:
      getHeader in class HTTPResponse
      Returns:
      the header string