HTTP和大数据

正常访问网址,windows会在host文件中找域名对应的服务器ip地址。没有再去DNS服务器上解析域名得到IP;

HTTP协议:超文本传输协议。终端和服务器通信

物理层:网线、网卡

网络层:IP协议

传输层:建立连接-----TCP(安全、可靠)/UDP

应用层:自定义协议

TCP

UDP

import java.io.IOException;
import java.io.InputStream;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;

public class Http通信 {
    public static void main(String[] args) throws IOException {
        ServerSocket server = new ServerSocket();
        server.bind(new InetSocketAddress(8888));
        System.out.println("开始监听啦,我就在这监听,有动静我就告诉你哦");

        Socket accept = server.accept();
        System.out.println("收到了某些信息,我读出来了,你看一下哦,哈哈");
        InputStream inputStream = accept.getInputStream();
        byte[] buffer = new byte[2048];
        int len = inputStream.read(buffer);
        System.out.println(new String(buffer,0,len));
    }
}
开始监听啦
收到了某些信息。哈哈
GET / HTTP/1.1 --------------------请求行
Host: localhost:8888        --------------请求头
Connection: keep-alive     ---
Cache-Control: max-age=0---
Upgrade-Insecure-Requests: 1---
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36 Edg/83.0.478.37
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Sec-Fetch-Site: cross-site
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6--------请求头结束

name=XX  ------空一行 请求体

 

展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客
应支付0元
点击重新获取
扫码支付

支付成功即可阅读