`
wiisola
  • 浏览: 85748 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

HTTP状态码100的用法

阅读更多

The purpose of the 100 (Continue) status (see section 10.1.1) is to allow a client that is sending a request message with a request body to determine if the origin server is willing to accept the request (based on the request headers) before the client sends the request body. In some cases, it might either be inappropriate or highly inefficient for the client to send the body if the server will reject the message without looking at the body.

Requirements for HTTP/1.1 clients:

      - If a client will wait for a 100 (Continue) response before
        sending the request body, it MUST send an Expect request-header
        field (section 14.20) with the "100-continue" expectation.

      - A client MUST NOT send an Expect request-header field (section
        14.20) with the "100-continue" expectation if it does not intend
        to send a request body.


Because of the presence of older implementations, the protocol allows ambiguous situations in which a client may send "Expect: 100- continue" without receiving either a 417 (Expectation Failed) status or a 100 (Continue) status. Therefore, when a client sends this header field to an origin server (possibly via a proxy) from which it has never seen a 100 (Continue) status, the client SHOULD NOT wait for an indefinite period before sending the request body.

Requirements for HTTP/1.1 origin servers:

      - Upon receiving a request which includes an Expect request-header
        field with the "100-continue" expectation, an origin server MUST
        either respond with 100 (Continue) status and continue to read
        from the input stream, or respond with a final status code. The
        origin server MUST NOT wait for the request body before sending
        the 100 (Continue) response. If it responds with a final status
        code, it MAY close the transport connection or it MAY continue
        to read and discard the rest of the request.  It MUST NOT
        perform the requested method if it returns a final status code.

      - An origin server SHOULD NOT send a 100 (Continue) response if
        the request message does not include an Expect request-header
        field with the "100-continue" expectation, and MUST NOT send a
        100 (Continue) response if such a request comes from an HTTP/1.0
        (or earlier) client. There is an exception to this rule: for
        compatibility with RFC 2068, a server MAY send a 100 (Continue)
        status in response to an HTTP/1.1 PUT or POST request that does
        not include an Expect request-header field with the "100-
        continue" expectation. This exception, the purpose of which is
        to minimize any client processing delays associated with an
        undeclared wait for 100 (Continue) status, applies only to
        HTTP/1.1 requests, and not to requests with any other HTTP-
        version value.

      - An origin server MAY omit a 100 (Continue) response if it has
        already received some or all of the request body for the
        corresponding request.

      - An origin server that sends a 100 (Continue) response MUST
        ultimately send a final status code, once the request body is
        received and processed, unless it terminates the transport
        connection prematurely.

      - If an origin server receives a request that does not include an
        Expect request-header field with the "100-continue" expectation,
        the request includes a request body, and the server responds
        with a final status code before reading the entire request body
        from the transport connection, then the server SHOULD NOT close
        the transport connection until it has read the entire request,
        or until the client closes the connection. Otherwise, the client
        might not reliably receive the response message. However, this
        requirement is not be construed as preventing a server from
        defending itself against denial-of-service attacks, or from
        badly broken client implementations.

Requirements for HTTP/1.1 proxies:

      - If a proxy receives a request that includes an Expect request-
        header field with the "100-continue" expectation, and the proxy
        either knows that the next-hop server complies with HTTP/1.1 or
        higher, or does not know the HTTP version of the next-hop
        server, it MUST forward the request, including the Expect header
        field.

      - If the proxy knows that the version of the next-hop server is
        HTTP/1.0 or lower, it MUST NOT forward the request, and it MUST
        respond with a 417 (Expectation Failed) status.

      - Proxies SHOULD maintain a cache recording the HTTP version
        numbers received from recently-referenced next-hop servers.

      - A proxy MUST NOT forward a 100 (Continue) response if the
        request message was received from an HTTP/1.0 (or earlier)
        client and did not include an Expect request-header field with
        the "100-continue" expectation. This requirement overrides the
        general rule for forwarding of 1xx responses (see section 10.1).

转自:http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.2.3

不甚理解。

分享到:
评论

相关推荐

    axios 处理 302 状态码的解决方法

    比如说浏览器打开了一个单页面(SPA)应用,过了一段时间token(或者session)过期了,这个时候页面上发起 Ajax请求之后,后端返回302状态码跳转到login页面。 我这是使用的是 Vue + axios ,发现 axios 无法拦截到 ...

    Laravel中正确地返回HTTP状态码方法示例

    以前,我一般会使用不常用的 Integer 类型数字作为 HTTP 状态码 。看下面的这个例子: <?php namespace App\Http\Controllers; use App\Http\Controllers\Controller; use App\Post; Class PostsController ...

    HTTP服务器状态码定义.doc

    300 Multiple Choices 该状态码不被HTTP/1.0的应用程序直接使用,只是做为3xx类型回应的缺省解释。存在多 个可用的被请求资源。 除非是HEAD请求,否则回应的实体中必须包括这些资源的字符列表及位置信息,由用户 或...

    bigcoder84#study-notes#_17HTTP协议常见的状态码1

    该状态码表示由于请求对应的资源存在着另一个 URI,应使用 GET方法定向获取请求的资源.303 状态码和 302 Found 状态码有着相同的功能,但 303

    基于SpringBoot编写的RESTFul API,使用HTTP状态码与JSON作为响应规范+源代码+文档说明

    而本项目中充分结合了HTTP状态码规范,使用ResponseEntity + HttpStatus的方式完成我们的API。当然,你想做一个完全具有RESTFul风格的API,你需要具有良好的RESTFul风格的资源设计能力。 ## 全局异常处理 采用@...

    EthereumStatusCodes:以太坊智能合约的状态码

    用户反馈由于状态码是有限的并且事先已知,因此我们可以提供全局的,人类可读的状态消息集。 这些还可以翻译成任何语言,不同技术细节级别,作为revert消息,natspec等添加。 我们也在看到了对此的渴望,并且没有...

    AJAX、http传输协议、响应状态码、请求方式

    AJAX 不是新的编程语言,而是一种使用现有标准的新方法。 AJAX 最大的优点是在不重新加载整个页面的情况下,可以与服务器交换数据并更新部分网页内容。 AJAX 不需要任何浏览器插件,但需要用户允许 JavaScript 在...

    AJAX(XMLHttpRequest.status)状态码

    注意:其它 HTTP 请求方法,如 PUT 和 DELETE 也可以使用,但仅部分浏览器支持。 timeout Number 设置请求超时时间(毫秒)。此设置将覆盖全局设置。 async Boolean (默认: true) 默认设置下,所有请求均为异步...

    java Rest 接口

     REST是一套用来创建Web Service的方法。... REST式的Web Service使用HTTP状态码作为返回值。  REST式的Web Service调用产生的HTTP请求内容只是用于服务数据——不是用来指明调用方法,目标对象或返回值的。

    http-status-identifier-cli:my我的HTTP状态是什么...没有离开命令行

    一个命令行界面,用于从状态码(即200 )或状态名称(即I'm a teapot )中识别HTTP状态。 安装 通过安装( -g标志将在全局安装软件包): npm install http-status-identifier-cli -g 用法 识别HTTP状态的命令是hs ...

    good-status:这是用于简化状态码响应的快速中间件

    使用方法发送带有有效状态代码的响应 app . post ( "/" , ( req , res ) => { res . created ( { status : "success" , data : { name : "John Doe" } , } ) ; // { status: "success", data: {name: "John Doe...

    http方法:为HTTP请求方法提供常量

    HTTP响应状态码 以便开发人员可以使用命名常量而不是幻数或幻数字符串来引用它们。 以下是一些HTTP请求抽象的示例,这些示例为HTTP请求方法提供了常量: 以下是一些HTTP响应抽象示例,这些示例为HTTP响应状态代码...

    hscode:http HTTP状态代码的命令行参考工具

    Hscode是一个简单的HTTP状态代码查找工具。 在自己的终端机上舒适地查找该状态码。 :smiling_face_with_sunglasses: 安装 自己安装为: $ gem install hscode 或将此行添加到您的应用程序的Gemfile中: gem 'hs...

    sort编程语言+Web服务+RESTful API2

    sort编程语言+JAVAspring+Web服务+RESTful ...以及如何使用JAVAspring的Web服务来开发RESTful API,包括HTTP方法、URI、状态码、请求和响应的格式、JSON和XML的转换、异常处理等内容,以及一些配置文件和注解的用法。

    编程语言+JAVAspring+Web服务+RESTful API

    flutter编程语言+JAVAspring+Web服务+RESTful...以及如何使用JAVAspring的Web服务来开发RESTful API,包括HTTP方法、URI、状态码、请求和响应的格式、JSON和XML的转换、异常处理等内容,以及一些配置文件和注解的用法。

    RestTemplate的GET方法详解.docx

    RestTemplate可以发送HTTP GET请求,经常使用到的方法有...getForEntity()返回的是ResponseEntity,ResponseEntity是对HTTP响应的封装,除了包含响应体,还包含HTTP状态码、contentType、contentLength、Header等信息。

    该脚本是一个简单的软件测试脚本,主要用于自动化测试API端点

    它使用Bash编写,并通过curl命令行工具执行HTTP请求,从而验证API的功能和响应状态码。 脚本首先定义了一些测试环境变量,如测试环境和API的URL。接着,它定义了一个测试用例数组,包含了要测试的API端点和方法(如...

    koa-response2:用语义函数替换ctx.body,修改HTTP状态代码并轻松响应

    用法 import Koa , { ParameterizedContext } from 'koa' import koaReponse from 'koa-response2' const app = new Koa ( ) app . use ( koaReponse ( ) ) export default function ( ctx : ParameterizedContext )...

    sneezy:用于测试目的的不稳定模拟服务器

    打喷嚏 Sneezy是用于测试目的的不稳定...http://localhost:9000/200 返回HTTP状态码200 http://localhost:9000/500 返回HTTP状态码500 http://localhost:9000/sneezy 在大多数情况下,返回HTTP 200。 十分之一返回500

Global site tag (gtag.js) - Google Analytics