-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fullstack 1st course #41
Comments
环境准备Python3这里有几种安装方式 brew install python3 或者 brew install pyenv
pyenv install 3.6.3
#不过感觉这个python version manager 不是特表好用,配置了半天结果最后 install 还是抛 error,遂放弃 或者直接去官网下安装包。 nmap
brew install nmap 我们主要使用 ncat -l 9999 ncat localhost 9999 这时双方就能通信了,随意输入任意的信息可以在另一边看到消息,此消息传输是建立在 TCP 协议上。 启动第一个 Serverterminal 中进入任意有文件的目录,运行: python3 -m http.server 8000 开启浏览器,能看到一个类似浏览 ftp 的 page 出现了,并且还能通过点击文件夹跳转。 URI全程是 Uniform Resource Identifier,用户只会关心它是一串字符串。 我们也会经常听到 URL: Uniform Resource Locator 和 URI 的区别主要是 URL 是指在 network 中的资源,而 URI 范围会广些。 我们用一个简单的 URI 做示范
Schemescheme还有一些其他的,常用的主要是3种
hostnamehostname 是紧跟在 scheme之后的部分,以 path基本没啥好说的,都很熟悉了,需要注意的是借位的 DNS全称 Domain Name Service, 在互联网中 client 和 server 通信时都是通过 ip, 但是 ip 对于人类来说没有太多的语义,所以我们通过域名访问 server, 这个域名到 ip 的转换就是通过 DNS 来的。互联网上的 DNS 是通过 ISPs (Internet Service Providers) 提供。 可以通过 Portshttp 的默认端口是 Http request关于http request 要点是各个 mehtod, 用的最多的就是
分别对应 backend 的 CRUD (Create, Read, Update, Delete)。 Http response服务器的返回叫做 response, 这时服务器向客户端通信的方式。我们用 ncat www.360buy.com 80 然后发送一个 GET 请求 GET / HTTP/1.1
Host: www.360buy.com 中间换行通过 HTTP/1.1 301 Moved Permanently
Server: JDWS/2.0
Date: Sat, 09 Dec 2017 15:30:27 GMT
Content-Type: text/html
Content-Length: 272
Connection: keep-alive
Location: http://www.jd.com/
Via: BJ-H-NX-112(), http/1.1 CD-CT-1-JCS-31 ( [cRs f ])
Age: 752
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<h1>301 Moved Permanently</h1>
<p>The requested resource has been assigned a new permanent URI.</p>
<hr/>Server: JDWS</body>
</html> 该返回由3部分组成: status line,headers,response body。 Status line顾名思义,status line 就是告诉 client, server 端对这个 request 的理解。其中最主要的部分就是 status code. HTTP/1.1 301 Moved Permanently 这个行代表 server 基于 HTTP/1.1 的协议通信,该请求的结果是 301 状态,表示资源永久移走了。一般的 status code 理解如下:
关于 status code的详细解释,可以参考Status Code Definitions headersheaders 是由多个 header 组成的数据。主要有以下特性:
Content-type headerContent-type 指定当前 response 返回的种类。他包含两个主要信息:
Content-Lengthresponse bodyheaders 接一行空行之后的所有数据都是 response body,是http request 对应请求数据的一份 copy。 |
No description provided.
The text was updated successfully, but these errors were encountered: