HTTP & Web Servers
程序员文章站
2022-03-24 10:46:18
...
- ncat
tcp层通话 ncat -l 9999 //监听端口9999,服务端 ncat localhost 9999//连接至端口9999,客户端
- python 开本地服务器
python -m http.server 8000(python3.0)
- 服务器:接收网络上其他程序发过来的连接
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.
-
URI : Uniform Resource Identifier, a name for a resource.
https://en.wikipedia.org/wiki/Fish https==>scheme en.wikipedia.org==>hostname /wiki/Fish==>path
- scheme
常见有http/https/file/data/mailto file告诉客户端从本地文件系统访问文件 http/https:从网络*问文件 data:直接将hardcoded数据放入网页,如图片 magnet: is used for links to some file-sharing services such as BitTorrent.
- hostname:告诉客户端连接哪个服务器
不是每个URI都有hostname,如mailto:aaa@qq.com 也可以说明 : 是放在协议后面的,//是放在hostname前面的,mailto没有hostname,因此没有//
-
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/
- 其他常见URI组成
http://baidu.com/search?q=jier ?q=jier 叫query,会发送至server https://bd.com/wiki/Oxygen#Discovery Discovery 叫fragment,不会发送至server,本地浏览器会自动滚动到页面id为Discovery的部分
- 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
- 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端口
- 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
- HTTP responses
status line:告诉客户端服务器是否理解了请求,是否有请求的资源,下一步的反应及当前protocol版本号 some headers==>告诉客户端一些response的信息,不会在网页中显示出来 a response body 本例中:状态码301表示重定向redirection,告诉客户端如果想获得谷歌主页需要去访问:http://www.google.com.==>浏览器会自动重定向到该网址
- 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: 它告诉客户端响应体的长度(以字节为单位)。如果服务器发送此消息,那么客户端在读取第一响应后可以重用该连接发送另一个请求。浏览器使用这一点,这样就可以在不必重新连接服务器的情况下获取多个数据(例如网页上的图像)。
上一篇: python WSGI
下一篇: IIS上传文件大小限制和上传时间限制
推荐阅读
-
关于css 样式表的基本问题,菜鸟求教_html/css_WEB-ITnose
-
这个问题应该如何解决?_html/css_WEB-ITnose
-
HTML中object,classid记录十_html/css_WEB-ITnose
-
如何设置网页中的一段文字,使它的宽度是页面宽度的62%且能自动换行?_html/css_WEB-ITnose
-
关于图片的PNG与JPG、JIF格式_html/css_WEB-ITnose
-
为什么我添加的那条线跑到顶端去了_html/css_WEB-ITnose
-
html 编码规范_html/css_WEB-ITnose
-
基于CSS3自定义美化复选框Checkbox组合_html/css_WEB-ITnose
-
取值,并赋值到相应的文本框中_html/css_WEB-ITnose
-
如何正则出HTTP开头的JPG图片?