我正在玩Netty示例org.jboss.netty.example.http.snoop
,我注意到了
Firefox执行4个请求,导致创建4个HttpRequestHandler
个实例,Internet Explorer 8/9执行2个请求,导致创建2个HttpRequestHandler
个实例。
我认为这是由HTTP 1.1流水线操作引起的,但即使在更改了FireFox的network.http.pipelining.*
键和IE的HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings
注册表项之后,Netty的行为也是一样的。
我的问题是,这是预期和正确的,还是我遗漏了一些东西,是否可以配置Netty以删除后续的幂等请求,或者这最终必须由HttpRequestHandler
实现?
答案 0 :(得分:1)
您应该打印出路径以找出FF正在请求的内容。由于Snoop示例发送的格式无效,我很确定是多次请求的favicon.ico(重试机制)。
修改。我验证了它,确实是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