我将一些值发送到另一个URL并且关于那个 [英] I send some values to another url and about that

查看:135
本文介绍了我将一些值发送到另一个URL并且关于那个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用spring httpClient将一些值发送到其他url。关于这个问题我知道如果我发送 name = mister age = 30 values ,收到的页面得到的值不是http状态值,对吧?
Http状态值用于发送页面不接收页面。
我的意思是,如果我发送这些值,接收页面将获得http值。
如果接收页面想要获取该值,我已发送该值,是吗?

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?

我的团队经理告诉我,http有请求和响应因此,如果您向其他网址发送一些值,则其他网址会获取http状态值。
但是我认为这有点无论如何我无法理解我的团队经理的说法,请告诉我,当我发送一些值时,接收页面会获得http状态。

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.

推荐答案

您的团队经理的陈述是正确的。 (必须写入http状态。,http有请求和响应。所以应该有http状态值结果)。他/她提到的是 HTTP响应状态代码,应该返回(使用正确的代码)无论回应如何。

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.

无论你的结果如何( name = mister and age = 30 etc。)都是静态页面或Ajax响应,当成功生成结果时,响应代码应为 200 OK (正确的业务逻辑,不会发生错误)。但是当发生不好的事情时,让客户知道服务器无法返回结果的原因很重要 - 可能是因为请求格式不正确( 400 Bad Request ),那里是请求URL中的拼写错误( 404 Not Found )或服务器代码中的某些错误( 500内部服务器错误)。将 name = null和age = null 发送到客户端 200 OK 不正确且容易出错。如果没有在文档中定义这些错误状态代码,后端工程师必须在开发期间与前端工程师进行通信,API由API逐个进行通信,这非常耗时且效率低下。

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.

我认为你的TODO是:对于接受 name = mister和age = 30 的API,定义成功案例和不同的失败案例,然后为他们分配正确的响应代码。

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.

这篇关于我将一些值发送到另一个URL并且关于那个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆