Get a.com
status code: 301
Location: b.com
// 下次用瀏覽器去 a.com ,瀏覽器不會再對 a.com 發送 request,而是直接帶去 b.com (因為知道永久移址)
302 Found(暫時轉址)
Get a.com
status code: 302
Location: b.com
// 瀏覽器則是還會再問一次是否要去 b.com
400 Bad Request(client 端有錯誤): 字太醜的例子,千千看不懂~
403 Forbidden(client 端沒有權限)
404 Not Found (崔無)
500 Internal Server Error (伺服器出了問題)
503 Service Unavailable(常出現在搶票頁面)
Request 與 Response
標準化很重要
有規格、標準後,才能被機器處理!
Request
在 Request Header 內可以看到:
Response:
在 Response Header 裡面可以看到:
HTTP Request Methods
GET
:最常見的 method,從伺服器端拿資料(例如:看網頁)POST
: 最常見的 method,從客戶端送資料去伺服器端(如:登入)PATCH
:增加或部分更改一筆新的資料PUT
:把整個資料都換新的DELETE
:刪除資料OPTIONS
:看伺服器支援哪些 methodHEAD
:跟GET
一樣,差別在於HEAD
的 response 沒有 body,只會取得 「HTTP header 資料」。HTTP Response Status Codes
以下為常見的 status codes:
200 OK 301 Moved Permanently(永久轉址)
302 Found(暫時轉址)
400 Bad Request(client 端有錯誤): 字太醜的例子,千千看不懂~ 403 Forbidden(client 端沒有權限) 404 Not Found (崔無) 500 Internal Server Error (伺服器出了問題) 503 Service Unavailable(常出現在搶票頁面)
代碼意義:
前端跟後端溝通的方法(怎麼從前端發 request ?)
引入:
<script src='...'/>
股溝追蹤 GA(Google Analytics): 在網頁上放一個股溝 Githubissues.