网络编程(自定义图形界面浏览器-Tomcat服务端). 模拟IE 的请求

package netTest;
import java.io.*;
import java.net.*;
public class IE {
    public static void main(String[] args) throws Exception {
        Socket s = new Socket("127.0.0.1",8080);
        PrintWriter out = new PrintWriter(s.getOutputStream(),true);
        out.println("GET /myweb/demo.html HTTP/1.1");
        out.println("Accept: */*");
        out.println("Host: 127.0.0.1:11188");
        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);
        }
    }
    
}
package netTest;
import java.io.*;
import java.net.*;
public class IE {
    public static void main(String[] args) throws Exception {
        Socket s = new Socket("127.0.0.1",8080);
        PrintWriter out = new PrintWriter(s.getOutputStream(),true);
        out.println("GET /myweb/demo.html HTTP/1.1");
        out.println("Accept: */*");
        out.println("Host: 127.0.0.1:11188");
        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);
        }
    }
    
}

 

posted @ 2016-01-22 10:32  HuberyQian  阅读(356)  评论(0编辑  收藏  举报