Blockchain Nanodegree 预修知识之一:HTTP & Web Servers (1)

HTTP & Web Servers

https://classroom.udacity.com/courses/ud303

Lesson 1: Requests & Responses

Introduction

Before started
  • Terminal
  • Python 3
  • Git
  • NMap Tools/ncat
URL

Here is an example of a URI: https://en.wikipedia.org/wiki/Fish
This URI has three visible parts, separated by a little bit of punctuation:

  • https is the scheme;
  • en.wikipedia.org is the hostname;
  • and /wiki/Fish is the path.
Host names and Ports

host or nslookup

Start the server

py -m http.server 8000

HTTP GET requests

Example: 127.0.0.1 - - [03/Oct/2016 15:45:50] "GET /readme.png HTTP/1.1" 200 -

  • request line: "GET /readme.png HTTP/1.1"
  • method: "GET"
  • path: "/readme.png"
  • protocol: "HTTP/1.1"
Exercise: Send a request by hand
ncat 127.0.0.1 8000
GET / HTTP/1.1
Host: localhost

Result:

HTTP/1.0 200 OK
Server: SimpleHTTP/0.6 Python/3.7.1
Date: Mon, 12 Nov 2018 14:11:32 GMT
Content-type: text/html; charset=utf-8
Content-Length: 616

(The rest is HTML)

HTTP Responses

Status Line

https://en.wikipedia.org/wiki/List_of_HTTP_status_codes

  • 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.
Headers
Response body
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值