HTTP & Web Servers

  1. ncat
    tcp层通话
    ncat -l 9999 //监听端口9999,服务端
    
    ncat localhost 9999//连接至端口9999,客户端
  2. python 开本地服务器
    python -m http.server 8000(python3.0)
  3. 服务器:接收网络上其他程序发过来的连接
    A server is just a program that accepts connections from other programs on the network.
    
    When you start a server program, it waits for clients to connect to it — like the demo server waiting for your web browser to ask it for a page. 
    Then when a connection comes in, the server runs a piece of code — like calling a function — to handle each incoming connection. 
    A connection in this sense is like a phone call: it's a channel through which the client and server can talk to each other. Web clients send requests over these connections, and servers send responses back.
  4. URI : Uniform Resource Identifier, a name for a resource.
    https://en.wikipedia.org/wiki/Fish
     https==>scheme
     en.wikipedia.org==>hostname
     /wiki/Fish==>path
  5. scheme
    常见有http/https/file/data/mailto
    file告诉客户端从本地文件系统访问文件
    http/https:从网络上访问文件
    data:直接将hardcoded数据放入网页,如图片
    magnet: is used for links to some file-sharing services such as BitTorrent. 
  6. hostname:告诉客户端连接哪个服务器
    不是每个URI都有hostname,如mailto:spam@example.net
    
    也可以说明 : 是放在协议后面的,//是放在hostname前面的,mailto没有hostname,因此没有//
  7. path : identifie a particular resource on a server, tell the server which resource the client is looking for

    当没写path时,如http://baidu.com,浏览器会自动填充,在后面加个/,http://baidu.com/
  8. 其他常见URI组成
    http://baidu.com/search?q=jier
       ?q=jier 叫query,会发送至server
    https://bd.com/wiki/Oxygen#Discovery
       Discovery 叫fragment,不会发送至server,本地浏览器会自动滚动到页面id为Discovery的部分
  9. host/nslookup
    host google.com
     google.com has address 111.67.201.52
     google.com has IPv6 address 2404:6800:4012::200e
    nslookup google.com
     Server: 123.207.137.88
     Address: 123.207.137.88#53
    
     Name: google.com
     Address: 111.67.201.52
  10. port
    Each packet has the IP addresses of the computer that sent it, and the computer that receives it. 
    And (with the exception of some low-level packets, such as ping) it also has the port number for the sender and recipient. 
    IP addresses distinguish computers; port numbers distinguish programs on those computers.
    
    http 默认80端口
    https 默认443端口
  11. HTTP GET REQUESTS
    GET / HTTP/1.1
    GET /1.png HTTP/1.1
    
    GET==>method or a HTTP Verb that clients use when they want a server to send a resource
    /1.png==>path of the resource being requested
    HTTP/1.1==>protocol of the request
  12. HTTP responses
    status line:告诉客户端服务器是否理解了请求,是否有请求的资源,下一步的反应及当前protocol版本号
    some headers==>告诉客户端一些response的信息,不会在网页中显示出来
    a response body
    本例中:状态码301表示重定向redirection,告诉客户端如果想获得谷歌主页需要去访问:http://www.google.com.==>浏览器会自动重定向到该网址
    
    
    

  1. status code : 状态码 
1xx — Informational. The request is in progress or there's another step to take.
2xx — Success! The request succeeded. The server is sending the data the client asked for.
3xx — Redirection. The server is telling the client a different URI it should redirect to. The headers will usually contain a Location header with the updated URI. Different codes tell the client whether a redirect is permanent or temporary.
4xx — Client error. The server didn't understand the client's request, or can't or won't fill it. Different codes tell the client whether it was a bad URI, a permissions problem, or another sort of error.
5xx — Server error. Something went wrong on the server side

2.head

keyword: value. 
Localtion: www.baidu.com  
Content-type: text/html; charset=UTF-8
Content-type: image/png //图片格式
Content-length: 它告诉客户端响应体的长度(以字节为单位)。如果服务器发送此消息,那么客户端在读取第一响应后可以重用该连接发送另一个请求。浏览器使用这一点,这样就可以在不必重新连接服务器的情况下获取多个数据(例如网页上的图像)。


















评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值