Unable to send successful response to push alert


#1

I’m using a Python JSON server to receive push alerts and am currently using the test page to get it set up. I am able to successfully receive and print the alert but I can’t send back a successful response, thus every test try shows an error. The error I’m seeing is: “Failed during POST with status=eof, ncode={‘return’:’‘ok’}, duration=xxxms”, the ncode is the response I’m trying to send back but it apparently doesn’t read that as a success. That is, my code is self.request.sendall(json.dumps({‘return’:‘ok’})). I’ve also tried sending back just an integer or just a string but that doesn’t work either. Could you please let me know what I should be returning for a successful response? I read it should be “Content-type” of “text/plain” but I’m not sure exactly how to do this.


#2

It sounds like you’re implementing your own HTTP server and that you’re possibly not sending a proper HTTP/1.x response.

If you are unfamiliar with the format of HTTP responses, then check the RFCs or at least wikipedia for a summary:
en.wikipedia.org/wiki/Hypertext_ … se_message


#3

I’m now sending an HTTP response like so: “”“HTTP/1.0 200 OK\r Content-Type: text/plain;”"" and for the error I see, failed during POST and it shows that ncode=200. So it seems to be reading the code I’m sending back, not sure why it still has an error.


#4

You probably want: "HTTP/1.0 200 OK
Content-Type: text/plain
Content-Length: " + body.length() + "

" + body


#5

Nice, that works! Thanks for your help.