0

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

message = reader.readLine();
while (!((message == null) || (message == ""))) {
    message = reader.readLine();
}
client.close();

但是在这里它并没有消失!(message == "")

标题:

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)
4

1 回答 1

1

在java中,您将字符串与equals

message.equals("")
于 2013-07-04T16:38:06.843 回答