http 프로 토 콜 클 라 이언 트 가 서버 측 에 요청 할 때 일반적으로 보 내야 할 내용

2667 단어 http 프로 토 콜
out.println("GET /shopping/index.html HTTP/1.1");//          ,    , http    (  )
.... out.println(
"Aceept: */*");// ( ) out.println("Host: 192.168.1.111:8080");// ( ), 400( ) out.println("Connection: close");// ( ) out.println();// ( )
....

 
  URL URLConnection        
       //
URL URLConnection ( :java +socket) // ,Socket DatagramSocket , URL URLConnection // URL ( , ) URL url = new URL("http://localhost:8080/shopping/login.html?name=HAHA"); URLConnection con = url.openConnection(); System.out.println(con); System.out.println(url.getProtocol()); System.out.println(url.getPort()); System.out.println(url.getPath()); System.out.println(url.getFile()); System.out.println(url.getQuery()); /* http 8080 /shopping/login.html /shopping/login.html?name=HAHA ( path + query ) name=HAHA ( ) */ InputStream in = con.getInputStream(); byte[] bt = new byte[1024*2]; int len = in.read(bt); System.out.println(new String(bt, 0, len, "utf-8"));

좋은 웹페이지 즐겨찾기