我正在尝试覆盖框架的默认行为,以便在发送带有 expect:100-continue 的请求后始终返回 100 continue。无论我尝试什么,我仍然看到服务器总是响应 100 continue。我找到的唯一文档解释了如何从客户端(通过 ServicePointManager)禁用 100 continue 标头。
我尝试这样做的原因是首先验证标头,然后返回 417 或其他一些最终状态以回复发布请求。
RFC 指出:
HTTP/1.1 源服务器的要求:
Run Code Online (Sandbox Code Playgroud)- 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.
卷曲的结果: