I send some values to another url and about that

我的梦境 提交于 2019-12-20 07:41:16

问题


I send some values using spring httpClient to other url. And about that question as I know if I send name=mister age=30 values, received page get that values not http status values, right? Http status values are for sending page's not receive page's. I mean, if I send those values, receiving page gets http values. If receiving page want to get that values, I have send that values, is that right?

My team manager said to me that http has request and response so, if you send some values to other url, other url gets http status values. But as I thought that is little bit anyway I can't understand my team manager's saying, please let me know, receiving page gets http status when I send some values.


回答1:


Your team manager's statement is correct. ("the http status have to be written.", "http has request and response. so there should have that http status value result"). What he/she mentioned is HTTP response status code, which should be returned (with correct code) whatever the response is.

No matter your result (name=mister and age =30 etc.) is a static page or an Ajax response, the response code should be 200 OK when the result is generated successfully (correct business logic, no error happens). But when something bad happens, it is important to let client know why server failed to return result -- maybe it is because the request format is incorrect (400 Bad Request), there is a typo in request url (404 Not Found) or some error in server code (500 Internal Server Error). Send name=null and age=null to client with 200 OK is incorrect and bug prone. Without definition of these error status code in document, backend engineer have to communicate with frontend engineer during the development, API by API, case by case, which is very time consuming and inefficient.

I think your TODO is: for the API that accepts name=mister and age =30, define success case and different failure case, then assign correct response code to them.



来源:https://stackoverflow.com/questions/43462707/i-send-some-values-to-another-url-and-about-that

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!