web-push-libs/web-push-csharp

202 HTTP response causes WebPushException

samfromlv opened this issue · 2 comments

Recently we observed that some calls to send push messages using Mozilla push service fail with WebPushException and status code 202.

Endpoint address starts with https://updates.push.services.mozilla.com/wpush/v2/....

According to specification https://tools.ietf.org/html/draft-ietf-webpush-protocol-12 HTTP status code 202 is valid response from endpoint.

According to Mozilla documentation https://autopush.readthedocs.io/en/latest/http.html#calls HTTP status code 202 is returned when "Message stored for delivery to client at a later time."

Expected behavior is not to throw WebPushException on 202 HTTP status in send push message response.

I'm experiencing the same probably since just a few days ago. See

if (response.StatusCode == HttpStatusCode.Created)
. Within HandleResponse, I suggest updating
if (response.StatusCode == HttpStatusCode.Created)
to
if (response.StatusCode == HttpStatusCode.Created || response.StatusCode == HttpStatusCode.Accepted)
I agree with samfromlv's statements about the specification, but I'm no Web push expert.

Thanks, this has been fixed and uploaded in the newest nuget build (v1.0.12)