问题描述
- 求教:java socket编程接受HTTP请求出问题
-
自己用Java scoket模拟编写接受http请求服务器,在浏览器中输入1次url地址,浏览器却会向服务器发送多次相同请求,这是什么原因?以下是eclipse控制台打印的结果,可以看到浏览器发送了多次 /1234567890 请求,浏览器中地址栏只输入1次 http://localhost:8080/1234567890
eclipse控制台打印的结果:
初始化线程池,线程池中拥有10个线程可使用
初始化 base-params.xml 数据
request---->GET /1234567890 HTTP/1.1
Accept: text/html, application/xhtml+xml, /
Accept-Language: zh-Hans-CN,zh-Hans;q=0.5
User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)
Accept-Encoding: gzip, deflate
Host: localhost:8080
DNT: 1
Connection: Keep-Aliveuri====>/1234567890
----------------将数据写入文件----------------
request---->GET /1234567890 HTTP/1.1
Accept: text/html, application/xhtml+xml, /
Accept-Language: zh-Hans-CN,zh-Hans;q=0.5
User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)
Accept-Encoding: gzip, deflate
Host: localhost:8080
DNT: 1
Connection: Keep-Aliveuri====>/1234567890
----------------将数据写入文件----------------
request---->GET /1234567890 HTTP/1.1
Accept: text/html, application/xhtml+xml, /
Accept-Language: zh-Hans-CN,zh-Hans;q=0.5
User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)
Accept-Encoding: gzip, deflate
Host: localhost:8080
DNT: 1
Connection: Keep-Aliveuri====>/1234567890
----------------将数据写入文件----------------
request---->
uri====>null