HttpStatus详解

常用HttpStatus状态:
HttpStatus.OK = 200;  
HttpStatus.BADREQUEST = 400;  
HttpStatus.FORBIDDEN = 403;  
HttpStatus.NOTFOUND = 404;  
HttpStatus.TIMEOUT = 408;  

HttpStatus.SERVERERROR = 500;  

  1. HttpStatus = {
  2. //Informational 1xx 信息
  3. '100' : 'Continue', //继续
  4. '101' : 'Switching Protocols', //交换协议
  5. //Successful 2xx 成功
  6. '200' : 'OK', //OK
  7. '201' : 'Created', //创建
  8. '202' : 'Accepted', //已接受
  9. '203' : 'Non-Authoritative Information', //非权威信息
  10. '204' : 'No Content', //没有内容
  11. '205' : 'Reset Content', //重置内容
  12. '206' : 'Partial Content', //部分内容
  13. //Redirection 3xx 重定向
  14. '300' : 'Multiple Choices', //多种选择
  15. '301' : 'Moved Permanently', //永久移动
  16. '302' : 'Found', //找到
  17. '303' : 'See Other', //参见其他
  18. '304' : 'Not Modified', //未修改
  19. '305' : 'Use Proxy', //使用代理
  20. '306' : 'Unused', //未使用
  21. '307' : 'Temporary Redirect', //暂时重定向
  22. //Client Error 4xx 客户端错误
  23. '400' : 'Bad Request', //错误的请求
  24. '401' : 'Unauthorized', //未经授权
  25. '402' : 'Payment Required', //付费请求
  26. '403' : 'Forbidden', //禁止
  27. '404' : 'Not Found', //没有找到
  28. '405' : 'Method Not Allowed', //方法不允许
  29. '406' : 'Not Acceptable', //不可接受
  30. '407' : 'Proxy Authentication Required', //需要代理身份验证
  31. '408' : 'Request Timeout', //请求超时
  32. '409' : 'Conflict', //指令冲突
  33. '410' : 'Gone', //文档永久地离开了指定的位置
  34. '411' : 'Length Required', //需要Content-Length头请求
  35. '412' : 'Precondition Failed', //前提条件失败
  36. '413' : 'Request Entity Too Large', //请求实体太大
  37. '414' : 'Request-URI Too Long', //请求URI太长
  38. '415' : 'Unsupported Media Type', //不支持的媒体类型
  39. '416' : 'Requested Range Not Satisfiable', //请求的范围不可满足
  40. '417' : 'Expectation Failed', //期望失败
  41. //Server Error 5xx 服务器错误
  42. '500' : 'Internal Server Error', //内部服务器错误
  43. '501' : 'Not Implemented', //未实现
  44. '502' : 'Bad Gateway', //错误的网关
  45. '503' : 'Service Unavailable', //服务不可用
  46. '504' : 'Gateway Timeout', //网关超时
  47. '505' : 'HTTP Version Not Supported' //HTTP版本不支持
  48. };
  • 1
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在Nginx的配置文件中,`http{}`节点是最为重要的节点之一,其中包含了Nginx的HTTP相关的配置信息。下面对`http{}`节点的常用配置进行详细解释: 1. `include`指令 通过`include`指令可以引入其他文件中的配置信息,从而实现配置文件的模块化。例如: ``` http { include /etc/nginx/mime.types; include /etc/nginx/conf.d/*.conf; } ``` 2. `default_type`指令 通过`default_type`指令可以设置默认的MIME类型,当Nginx无法从请求中获取MIME类型时,会使用该默认类型。例如: ``` http { default_type application/octet-stream; } ``` 3. `log_format`指令 通过`log_format`指令可以定义日志格式,其中可以包含多个变量。例如: ``` http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; } ``` 4. `access_log`指令 通过`access_log`指令可以配置访问日志的路径和格式。例如: ``` http { access_log /var/log/nginx/access.log main; } ``` 5. `server`指令 通过`server`指令可以配置虚拟主机,即多个域名共享同一个IP地址和端口。例如: ``` http { server { listen 80; server_name example.com; root /var/www/example.com; } } ``` 6. `location`指令 通过`location`指令可以配置请求的URI匹配规则,并定义如何处理请求。例如: ``` http { server { listen 80; server_name example.com; root /var/www/example.com; location / { index index.html; } location /images/ { root /var/www/example.com; } } } ``` 以上是`http{}`节点的一些常用配置信息,通过灵活的配置可以实现不同的业务需求。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值