HTTPQUERY
English

510 Not Extended

用法

510 Not Extended 状态码是 HTTP 扩展框架(HTTP Extension Framework)的一部分。IANA 现将 510 列为 “Not Extended (OBSOLETED)“,其规范已被移至 Historic 状态,意味着该协议不再被推荐使用。

该错误出现在客户端被要求使用扩展的 HTTP 请求但未这样做时。服务器响应包含如何扩展请求的信息,尽管协议中并未规定确切的格式。

SEO 影响

搜索引擎对 510 的处理与其他 5xx 服务器错误相同。持续的失败会降低抓取速率,并最终将受影响的 URL 从索引中移除。

示例

客户端发送了一个需要强制性 HTTP 扩展的请求。服务器返回 510 Not Extended,因为该请求未包含所需的 M- 前缀和扩展声明。

请求

GET /resource HTTP/1.1
Host: example.com

响应

HTTP/1.1 510 Not Extended
Content-Type: text/html; charset=UTF-8
Content-Length: 199

<html>
  <head>
    <title>Not Extended</title>
  </head>
  <body>
    <p>The request requires a mandatory HTTP
    extension. Resubmit with the required
    extension headers.</p>
  </body>
</html>

如何修复

服务器要求一个客户端未在请求中包含的 HTTP 扩展。510 响应体描述了需要哪个扩展。

在客户端:

在服务器端:

此状态码在实践中极少遇到。HTTP 扩展框架已被移至 Historic 状态,几乎没有被采用。大多数现代 API 和 Web 应用通过自定义头、查询参数或 API 版本控制来处理功能协商,而非扩展框架机制。

Service Worker 中的 510

拦截 fetch 请求的 Service Worker 有时会在其缺少源站所需的扩展或能力时呈现 510。修复方法相同:检查响应体中缺失的扩展,并更新 Service Worker 的 fetch 处理器以包含所需的头。

代码参考

.NET

HttpStatusCode.NotExtended

Rust

http::StatusCode::NOT_EXTENDED

Rails

:not_extended

Go

http.StatusNotExtended

Symfony

Response::HTTP_NOT_EXTENDED

Python3.5+

http.HTTPStatus.NOT_EXTENDED

Apache HttpComponents Core

org.apache.hc.core5.http.HttpStatus.SC_NOT_EXTENDED

Angular

@angular/common/http/HttpStatusCode.NotExtended