googlearchive / web-push-encryption

[Deprecated] Encryption Utilities for Web Push protocol
Apache License 2.0
84 stars 23 forks source link

Custom headers #41

Open zaalbarxx opened 8 years ago

zaalbarxx commented 8 years ago

Hi! It would be great if there would be a chance to apply custom headers for given request. For example Firefox requires TTL header to be set when pushing to their push service so every request to them receives 400 status code if device is not currently connected to the internet. I think there may be some other cases where setting some custom headers could be potentially required.

RyanEwen commented 8 years ago

It looks like GCM suddenly requires this, too. I can't send any messages as of a day or two ago.

wibblymat commented 8 years ago

@zaalbarxx @RyanEwen in the case of TTL specifically, yes this was recently added to the spec and the push providers implemented it a lot quicker than I expected! I have snuck in a default TTL (of 0) into PR #17

For custom headers I'm not 100% sure what the best strategy is. In the Go version of the library you have the option of getting the HTTP Request object, so that you can change any headers - or anything else - you want to on it before sending it. Perhaps we could do something like that.