Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 当浏览器正在等待时_Java_Sockets_Browser_Http Headers - Fatal编程技术网

Java 当浏览器正在等待时

Java 当浏览器正在等待时,java,sockets,browser,http-headers,Java,Sockets,Browser,Http Headers,我有一个java程序,可以从浏览器(使用HTTP代理)读取请求头,然后响应它。 我的程序如何理解浏览器在未关闭连接的情况下等待响应。 我知道当浏览器在等待时,他会在标题末尾发送“”(我不知道是什么!)。但它不是空的,当我检查它时,它不起作用。 见下面的代码: message = reader.readLine(); while (!((message == null) || (message == ""))) { message = reader.readLine(); } client

我有一个java程序,可以从浏览器(使用HTTP代理)读取请求头,然后响应它。
我的程序如何理解浏览器在未关闭连接的情况下等待响应。
我知道当浏览器在等待时,他会在标题末尾发送“”(我不知道是什么!)。但它不是空的,当我检查它时,它不起作用。
见下面的代码:

message = reader.readLine();
while (!((message == null) || (message == ""))) {
    message = reader.readLine();
}
client.close();
但是在这里,
并没有过时!(消息==“”)

标题:

GET http://localhost/ HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.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
Connection: keep-alive
(waiting for respond)
null (for closing connection)

在java中,将字符串与
相等进行比较:

message.equals("")
Yip
(message==“”)
将返回false。。。即使
消息
是空字符串
”。