import java.io.*;
import java.net.*;
class MyIE
{
public static void main(String[] args) throws Exception
{
Socket s =new Socket("192.168.1.4",8080);
PrintWriter out =new PrintWriter(s.getOutputStream(),true);
out.println("GET /myweb/Demo.html HTTP/1.1");
out.println("Accept:");
out.println("Accept-Language:zh-cn");
out.println("Host 192.168.1.4:11000");
out.println("Connection:Keep-Alive");
out.println();
out.println();
BufferedReader bufr =new BufferedReader(new InputStreamReader(s.getInputStream()));
String line =null;
while((line=bufr.readLine())!=null)
{
System.out.println(line);
}
s.close();
}
}
编译能通过,但是运行时就会出现问题。
F:\java\day24>java MyIE
HTTP/1.1 400 Bad Request
Server: Apache-Coyote/1.1
Transfer-Encoding: chunked
Date: Sat, 05 Jan 2013 14:26:59 GMT
Connection: close
0
显示是400Bad Request,好像是Windows的IIS服务器的问题吧?我用xp系统装了一下IIS组件后,运行还是出现这个问题,求解。
|