Some third party is sending an Http Post request whenever something changes in their DB (e.g. when a contact has been updated, they send the contactID and 'contact_updated'). I have build a socket listener that catches those requests and is able to parse the information. However, I just can't get it to work to send back a response with the status '200 - OK'. Thus, the server on the client side keeps on trying (four times or so) to re-send the request.
Is there any, simple way to just send the response status without the need of adding external libs etc.?
答案 0 :(得分:0)
将字符串HTTP/1.1 200 OK
发送回套接字侦听器中就足够了。
如果遇到问题,可以查看this answer,它显示了如何仅通过简单的JavaSE功能在Java中使用HttpServer。
答案 1 :(得分:0)
使用
response.setStatus(HttpServletResponse.SC_OK);
在响应标题中设置状态代码。
您还可以设置内容类型。
response.setContentType("text/html;charset=UTF-8");