ToothlessGear / node-gcm

A NodeJS wrapper library port to send data to Android devices via Google Cloud Messaging
https://github.com/ToothlessGear/node-gcm
Other
1.31k stars 206 forks source link

Gcm 302 error #114

Open guytuboul opened 9 years ago

guytuboul commented 9 years ago

Hey, I saw recently that the library return an error with 302,meaning 'Found' and this is a common way of performing URL redirection. Is this library support such response from gcm? Thanks, guy

hypesystem commented 9 years ago

You are correct, currently anything other than a code 200 is treated as an error.

From W3Cs documentation on status codes:

The requested resource resides temporarily under a different URI. Since the redirection might be altered on occasion, the client SHOULD continue to use the Request-URI for future requests. [...] If the 302 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.

We send POST requests, so I am assuming that we shouldn't use the alternate URL (given in the Location header).

I have not experienced this issue, but I would be very interested in details on how to handle it.

hypesystem commented 9 years ago

This seems to be a previously reported issue (with GCM):

I don't see any documentation on how to handle it. I assume we could just re-run the request to the provided (temporary, alternate) URL, but I would like confirmation of this.