koron / go-ssdp

SSDP library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Advertise messages do not have HOST: field

schwark opened this issue · comments

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..

66a093a

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())
...