package p8.IE_Server;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;
import org.omg.PortableInterceptor.IORInterceptor;
public class MyBrowser {
public static void main(String[] args) throws UnknownHostException, IOException {
Socket s=new Socket("10.194.43.59",9090);
//模拟浏览器 给tomcat服务器 发送符合http协议的请求消息
PrintWriter out=new PrintWriter(s.getOutputStream());
out.println("GET a.html HTTP/1.1 ");
out.println("Accept: */*");
out.println("Host:10.194.43.59:9090");
out.println("Connection: Keep-Alive");
out.println();
InputStream in=s.getInputStream();
byte[]buf=new byte[1024];
int len=in.read(buf);
String str=new String(buf,0,len );
System.out.println(str);
s.close();
}
}
Java 模拟浏览器
最新推荐文章于 2023-04-10 12:06:20 发布