go-ssdp
go-ssdp copied to clipboard
Advertise messages do not have HOST: field
The missing field is causing SmartThings to ignore the advertisements from go-ssdp.. Not sure which one is not following the spec, but all the other devices on my network do include that field. only the go-ssdp responses do not. The field missing is..
HOST: 239.255.255.250:1900
Looks like the Alive messages do have the field though
This fix makes it work for SmartThings..
https://github.com/koron/go-ssdp/commit/66a093adc08534002c1896cc4a97fbdaf08202c8
https://datatracker.ietf.org/doc/html/draft-cai-ssdp-v1-03 doens't mentioned about HOST header.
But examples include HOST header.
- M-SEARCH https://datatracker.ietf.org/doc/html/draft-cai-ssdp-v1-03#section-4.2.1.1
- NOTIFY https://datatracker.ietf.org/doc/html/draft-cai-ssdp-v1-03#section-5.2.1.1
- NOTIFY https://datatracker.ietf.org/doc/html/draft-cai-ssdp-v1-03#section-5.2.2.1
Ex:
NOTIFY * HTTP/1.1
Host: 239.255.255.250:reservedSSDPport
It looks like reasonable that adding HOST header.
The first article just says that responses for M-SEARCH don't have HOST header.
There are HOST header for requests. It is a natural comparison with HTTP/1.1, which is the basis of SSDP.
But HTTP/1.1 don't require HOST header in responses. Is there a specification or something that requires a HOST header in the response?
Quote last paragrph 4.2 SSDP Discovery Requests > Proposed Solution
Response to ssdp:discover requests SHOULD contain a cache-control: max-age or Expires header. If both are present then they are to be processed in the order specified by HTTP/1.1, that is, the cache- control header takes precedence of the Expires header. If neither the cache-control nor the Expires header is provided on the response to a ssdp:discover request then the information contained in that response MUST NOT be cached by SSDP clients.
AdvertiserOptionAddHost() will support this case.
It is add with #38
Example:
a, err := ssdp.Advertise("st", "usn", "location", "server", maxAge, ssdp.AdvertiseOptionAddHost())
...