有没有空"预期:"标题的意思是什么? [英] Does empty "Expect:" header mean anything?

查看:153
本文介绍了有没有空"预期:"标题的意思是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

许多图书馆包括期望:100-继续在所有HTTP 1.1 POST,默认情况下PUT请求

Many libraries include Expect: 100-continue on all HTTP 1.1 POST and PUT requests by default.

我打算通过删除,以减少感知延迟100,继续上那些我知道发送数据的时候了小于等待往返100-继续,即短请求的费用请求客户端的机制。

I intend to reduce perceived latency by removing 100-continue mechanism on the client side on those requests for which I know the expense of sending data right away is less than waiting a roundtrip for 100-continue, namely on short requests.

当然,我还是希望HTTP 1.1的所有其他伟大的功能,因此只我要杀了期望:100-继续头。我有两个选择:

Of course I still want all the other great features of HTTP 1.1, thus only I want to kill Expect: 100-continue header. I have two options:

  • 删除想到头完全,或
  • 发送空想到头,期待:\ r \ñ

是否有过两者之间有什么区别?

Is there ever any difference between the two?

这可能会破坏一个或其他任何软件?

Any software that might break for one or the other?

推荐答案

没事的的打破,如果你删除期望头,但我知道微软的IIS曾与问题100继续过去。例如, IIS5总是向100继续响应。所以,我不知道,至少有一些是在图书馆的用途可能是解决同样打破行为的服务器。

Nothing should break if you remove the Expect header, but I know that Microsoft IIS has had issues with 100 Continue in the past. For example, IIS5 always sends 100 continue responses. So, I wonder if at least some of the uses of it in libraries might be to work around similarly broken behaviour in servers.

许多图书馆似乎设置这个标题,然后没有真正处理 100继续正确 - 例如,他们开始要求身体立刻无需等待发送 100继续,然后不处理,该服务器可能会发回任何HTTP错误code,他们之前的事实'已经完成发送的请求体(第一部分的确定,它的第二部分而被打破 - 后来见我回答)。这使我相信,有一些学者抄袭它从其他地方没有完全理解的细微之处

Many libraries seem to set this header and then not actually handle 100 Continue properly - e.g. they begin to send the request body immediately without waiting for a 100 Continue and then don't handle the fact that the server might send back any HTTP error code before they've finished sending the request body (the first part's OK, it's the second part which is broken - see later in my answer). This leads me to believe that some authors have just copied it from elsewhere without fully understanding the subtleties.

我看不到任何理由包括空白期望标题 - 如果你不打算包括 100-继续(或一些其他期望条款)则省略头完全。唯一的原因有这将是解决破Web服务器,但我不知道有任何它们的行为以这种方式。

I can't see any reason to include a blank Expect header - if you're not going to include 100-continue (or some other Expect clause) then omit the header entirely. The only reason to include it would be to work around broken webservers, but I'm not aware of any which behave in this way.

最后,如果你只是希望减少往返延迟,在我看来,它实际上不会的不一致的与RFC简单地开始请求主体立即发送。你不应该无限期地等待发送请求体(按的RFC ),所以你的行为的规范 - 它只是你的超时反正在发送前为零

Finally, if you're just looking to reduce roundtrip latencies it seems to me that it wouldn't actually be inconsistent with the RFC to simply begin to transmit the request body immediately. You're not supposed to wait indefinitely to send the request body (as per the RFC), so you're behaving to the spec - it's just your timeout before sending anyway is zero.

您必须知道,服务器是自由地不发送 100继续反应,如果他们已经收到了一些请求主体的,所以你必须处理服务器其中发送 100继续,那些送什么,等待完整的请求和那些立即发出任何HTTP错误code(可能是417,但更可能是通用4XX code)。这样一来,你的短请求不应该有任何的开销(从预留期望头),但你不会有等待 100继续。当然,这种方法工作,你需要做的事情的方式,它可以让你一旦服务器返回一个错误,code中断请求(如非阻塞IO与民意调查()选择())。

You must be aware that servers are at liberty to not send the 100 Continue response if they've already received some of the request body, so you have to handle servers which send 100 Continue, those which send nothing and wait for the full request and those which immediately send any HTTP error code (which may be 417, but more likely a generic 4xx code). In this way, your short requests shouldn't have any overhead (aside from the Expect header) but you won't have to wait for the 100 Continue. Of course, for this approach to work you'll need to be doing things in a way which lets you interrupt the request as soon as the server returns an error code (e.g. non-blocking IO with poll() or select()).

做事这样可能有助于保持你的code大大小小的请求之间更加一致,同时减少延迟。缺点是,它也许不是RFC作者有什么想法,即使它没有明确违反任何规定。此外,它可能使你以后的code更复杂的,如果你没有这样做非阻塞IO或相似的。

Doing things this way might help keep your code more consistent between small and large requests while reducing the latency. The downside is that it's perhaps not what the RFC authors had in mind, even if it doesn't explicitly violate any of the requirements. Also, it might make your later code more complicated if you're not already doing non-blocking IO or similar.

这篇关于有没有空"预期:"标题的意思是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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