1
我在實現簡單Web服務器的程序中遇到問題。從Web服務器接收數據
當我發送HTTP請求到Web服務器,Web服務器發送HTTP代碼到客戶端,但我想收到=>我有錯誤「連接被重置!)
clientSocket = new Socket("localhost", 1234);
BufferedWriter out = new BufferedWriter(
new OutputStreamWriter(
new BufferedOutputStream(clientSocket.getOutputStream()), "UTF-8")
);
out.write(OUTPUT_HEADERS+"GET /"+"home.html" + " HTTP/1.1\nHost:"+clientSocket.getLocalAddress() +"\nUser-agent: Mozilla/5.0\nAccept-language: fa");
out.flush();
System.out.println(" waiting...");
InputStreamReader isr=new InputStreamReader(clientSocket.getInputStream());
BufferedReader br=new BufferedReader(isr);
while (br.ready()) {
System.out.println(br.readLine());
}
是什麼'OUTPUT_HEADERS'包含哪些內容? – 2015-04-25 13:29:03