程序员应注意哪些HTTP状态代码? [英] What HTTP Status Codes Should Programmers be Concerned With?

查看:54
本文介绍了程序员应注意哪些HTTP状态代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,如果您查看 HTTP状态代码列表,在编程时可能会有很多有用的地方.服务器可能会处理某些事情,例如协议,但是其中许多代码可能有助于告诉浏览器页面的实际状态.

So, if you look at the List of HTTP Status Codes, there are probably a number of them that would be useful while programming. The server might handle some things, like protocols, but a lot of these codes could be useful in telling the browser the actual status of the page.

所以,我的问题是我们应该关注哪些状态代码?我们应该检查发送哪一个,哪些最有可能永远不会在常规应用程序编程中使用.

So, my question is which of these status codes should we be concerned with? Which should we be checking to send, and which ones will most likely never be used in regular application programming.

如果您好奇的话,这属于PHP编程的范围,但它可能也适用于其他语言.

If you are curious, this is in the scope of PHP programming, but it would probably apply to other languages just as well.

推荐答案

其中许多对于REST风格的API使用本质上都是有用的.例如:

Many of these are intrinsically useful with REST-style API usage. For example:

  • 200(确定):您要求提供资源.在这里!

  • 200 (OK): You asked for a resource. Here it is!

201(已创建):您要求我提供新资源.我做到了!下次您可以在这里问我.

201 (Created): You asked me to make a new resource. I did! Here's where you can go to ask me for it next time.

202(接受)::您要我做点什么,但这需要一段时间,所以请不要等待.在这里您可以检查状态.

202 (Accepted): You asked me to do something, but it's going to take a while, so don't wait up. Here's where you can go to check up on the status.

300(多项选择):您要问一些问题,但不够具体.您是指哪一个?

300 (Multiple Choices): You asked for something, but you weren't specific enough. Which one of these did you mean?

301(永久移动)::您要的是东西,但现在在其他地方.就是这里了.

301 (Moved Permanently): You asked for something, but it's somewhere else now. Here's where it went.

302(找到)::您要的东西,但目前不在其他地方.在这里.

302 (Found): You asked for something, but it's somewhere else for the moment. Here it is.

304(未修改)::您在此之前要求提供某些东西,但是自上次问我以来,它一直没有改变.

304 (Not Modified): You asked for something before this, but it hasn't changed since the last time you asked me.

400(错误请求):您要求我执行的操作有问题.改正您所说的内容,然后重试.

400 (Bad Request): Something is wrong about what you asked me to do. Fix what you said and try again.

401(未经授权):在完成此请求之前,我需要您先证明自己的身份. [注意:这是更不幸命名的标题之一.它的真正标题应该是未经身份验证的; 403更像是未经授权的.]

401 (Unauthorized): I need you to identify yourself before I can finish this request. [Note: This is one of the more unfortunately named headers. It should really be titled Unauthenticated; 403 is more like Unauthorized.]

403(禁止访问):您要求提供一些您不允许拥有的东西.

403 (Forbidden): You asked for something you're not allowed to have.

404(未找到)::您要的是资源,但找不到与您的描述相符的资源.

404 (Not Found): You asked for a resource, but there isn't one that matches your description.

500(服务器错误):出了点问题,所以我现在不能满足您的要求.抱歉.

500 (Server Error): Something went wrong, so I can't give you what you asked for right now. Sorry about that.

501(未实现):我目前不支持这种请求.

501 (Not Implemented): I don't support that kind of request right now.

503(服务不可用)::我现在无法回复请求.

503 (Service Unavailable): I'm not able to respond to requests right now.

这篇关于程序员应注意哪些HTTP状态代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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