Netty ChannelUpstreamHandler 和 HTTP 管道

发布于 2024-12-18 06:45:24 字数 498 浏览 3 评论 0原文

我正在玩 Netty 示例 org.jboss.netty.example.http.snoop ,我注意到 Firefox 执行 4 个请求,导致创建 4 个 HttpRequestHandler 实例,而 Internet Explorer 8/9 执行 2 个请求,导致创建 2 个 HttpRequestHandler 实例。

我认为这是由于 HTTP 1.1 管道造成的,但是即使在更改 FireFox 的 network.http.pipelined.* 键和 HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings 后 IE 的注册表项,Netty 的行为方式相同。

我的问题是,这是预期的且正确的,还是我遗漏了一些东西,是否可以配置 Netty 来删除后续的幂等请求,或者这最终必须由 HttpRequestHandler 实现?

I was playing with the Netty example org.jboss.netty.example.http.snoop and I noticed that
Firefox does 4 requests leading to the creation of 4 HttpRequestHandler instances and Internet Explorer 8/9 does 2 request leading to the creation of 2 HttpRequestHandler instances.

I think this is due to the HTTP 1.1 pipelining, however even after changing the network.http.pipelining.* keys for FireFox and the HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings registry entries for IE, Netty behaves the same way.

My question is, is this expected and correct or am I missing something and is it possible to configure Netty to drop subsequent idempotent requests or this has to be implemented by the HttpRequestHandler eventually?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

咋地 2024-12-25 06:45:24

您应该打印出路径来找出 FF 所请求的内容。我很确定它是 favicon.ico,它被多次请求(重试机制),因为 Snoop 示例发送的格式无效。

编辑。我验证了一下,确实是请求了3次的favicon:

Thread[New I/O server worker #1-3,5,main] - [id: 0x57c52e72, /0:0:0:0:0:0:0:1:63056 => /0:0:0:0:0:0:0:1:8080] RECEIVED: DefaultHttpRequest(chunked: false) GET / HTTP/1.1 Host: localhost:8080 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip, deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Connection: keep-alive
Thread[New I/O server worker #1-3,5,main] - GET
Thread[New I/O server worker #1-3,5,main] - /

Thread[New I/O server worker #1-3,5,main] - [id: 0x57c52e72, /0:0:0:0:0:0:0:1:63056 => /0:0:0:0:0:0:0:1:8080] RECEIVED: DefaultHttpRequest(chunked: false) GET /favicon.ico HTTP/1.1 Host: localhost:8080 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0 Accept: image/png,image/*;q=0.8,*/*;q=0.5 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip, deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Connection: keep-alive
Thread[New I/O server worker #1-3,5,main] - GET
Thread[New I/O server worker #1-3,5,main] - /favicon.ico

Thread[New I/O server worker #1-3,5,main] - [id: 0x57c52e72, /0:0:0:0:0:0:0:1:63056 => /0:0:0:0:0:0:0:1:8080] RECEIVED: DefaultHttpRequest(chunked: false) GET /favicon.ico HTTP/1.1 Host: localhost:8080 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip, deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Connection: keep-alive
Thread[New I/O server worker #1-3,5,main] - GET
Thread[New I/O server worker #1-3,5,main] - /favicon.ico

Thread[New I/O server worker #1-3,5,main] - [id: 0x57c52e72, /0:0:0:0:0:0:0:1:63056 => /0:0:0:0:0:0:0:1:8080] RECEIVED: DefaultHttpRequest(chunked: false) GET /favicon.ico HTTP/1.1 Host: localhost:8080 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip, deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Connection: keep-alive
Thread[New I/O server worker #1-3,5,main] - GET
Thread[New I/O server worker #1-3,5,main] - /favicon.ico

You should print out the path to find out what FF is requesting. I am pretty sure it is favicon.ico which is requested multiple times (retry mechanism) because of invalid format being sent by Snoop example.

edit. I verified it, and it is indeed favicon which is requested three times:

Thread[New I/O server worker #1-3,5,main] - [id: 0x57c52e72, /0:0:0:0:0:0:0:1:63056 => /0:0:0:0:0:0:0:1:8080] RECEIVED: DefaultHttpRequest(chunked: false) GET / HTTP/1.1 Host: localhost:8080 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip, deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Connection: keep-alive
Thread[New I/O server worker #1-3,5,main] - GET
Thread[New I/O server worker #1-3,5,main] - /

Thread[New I/O server worker #1-3,5,main] - [id: 0x57c52e72, /0:0:0:0:0:0:0:1:63056 => /0:0:0:0:0:0:0:1:8080] RECEIVED: DefaultHttpRequest(chunked: false) GET /favicon.ico HTTP/1.1 Host: localhost:8080 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0 Accept: image/png,image/*;q=0.8,*/*;q=0.5 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip, deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Connection: keep-alive
Thread[New I/O server worker #1-3,5,main] - GET
Thread[New I/O server worker #1-3,5,main] - /favicon.ico

Thread[New I/O server worker #1-3,5,main] - [id: 0x57c52e72, /0:0:0:0:0:0:0:1:63056 => /0:0:0:0:0:0:0:1:8080] RECEIVED: DefaultHttpRequest(chunked: false) GET /favicon.ico HTTP/1.1 Host: localhost:8080 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip, deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Connection: keep-alive
Thread[New I/O server worker #1-3,5,main] - GET
Thread[New I/O server worker #1-3,5,main] - /favicon.ico

Thread[New I/O server worker #1-3,5,main] - [id: 0x57c52e72, /0:0:0:0:0:0:0:1:63056 => /0:0:0:0:0:0:0:1:8080] RECEIVED: DefaultHttpRequest(chunked: false) GET /favicon.ico HTTP/1.1 Host: localhost:8080 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip, deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Connection: keep-alive
Thread[New I/O server worker #1-3,5,main] - GET
Thread[New I/O server worker #1-3,5,main] - /favicon.ico
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文