I had a strange problem with a little relaxation service that I create as an exercise. It is assumed that the application will respond to some XML ( in particular TwiML , since it is designed for Twilio) on HTTP POST, and it works fine for standalone requests. However, at Twilio's request, the answer never ends and it expires. After comparing the traffic coming from Twilio to the one that works (using a fake HTML form), I highlighted the problem in the โConnection: closeโ header and can play it using only the curl command line. Here is a query that works:
curl -i -H 'Connection: keep-alive' -X POST -d "name=value" http:
and here is the one that just hangs:
curl -i -H 'Connection: close' -X POST -d "name=value" http:
If I kill the server, then the curl says: "(52) An empty response from the server." Here is the code I'm using in ServerResource:
@Post public Representation hello(Representation repr) { Representation result = new StringRepresentation(("<Response>\n"+ " <Say>Hello. This is a test.</Say>\n"+ "</Response>"), MediaType.APPLICATION_XML); return result; }
Is there something clearly wrong with what I'm doing here? I am using restlet-2.0, but also tried with 2.1m1 with the same result. I would really appreciate a quick response, as I am in a pinch to finish the exercise.
source share