---
# System prepended metadata

title: 'HTTP, HTTPS'
tags: [Website]

---

# HTTP, HTTPS
###### tags: `Website`
![](https://i.imgur.com/ENpa1di.png)
:::info
**Transfer Protocol 通訊協定**
制定規則和標準，讓設備之間不但能認出彼此，也能夠根據不同情境選擇溝通的方式。而 HTTP 和 HTTPS 是專門用於瀏覽器與伺服器之間的通訊協定，差別在於加密與否。
:::

### HTTP vs HTTPS
|  | HTTP | HTTPS |
| -------- | -------- | -------- |
| 全文 | HyperText Transfer Protocol | HyperText Transfer Protocol **Secure** |
| 翻譯 | 超文本傳輸協定 | 超文本傳輸**安全**協定 |
| 說明 | Request 不加密（明文） | **==SSL / TLS 加密 Request==** |

### HTTP Methods
> HTTP 定義的執行特定操作的請求方法。

| 常見方法 | 說明 |
| -------- | -------- |
| GET | 拿取資料 |
| POST | 上傳資料 |
| PUT | 更新部分資料  |
| PATCH | 覆蓋資料  |
| DELETE | 刪除資料  |

### HTTP Request / Response
:::info
**Message Format 訊息格式** 
HTTP 就好像寄信一樣，寄出去的東西須符合其格式。包含 Start Line、Header（額外的附加資訊）、CRLF、Message-Body。
:::

#### HTTP Request
![](https://i.imgur.com/JLV2aRB.png)
- `Host` | 主機位置
- `User-Agent` | 從哪裡發送的
- `Accept` | 接受回傳回來的檔案類型
- `Content-Type` | 傳送出去的內容物資料型態
- `Content-Length` | 傳送出去的內容物資料長度
#### HTTP Response
![](https://i.imgur.com/62POyIu.png)
- `Server` | 伺服器位置
- `Date` | 接收到 Response 的時間
### HTTP Status Code 狀態碼

- `1XX` | information 收到請求了 需要繼續處理
- `2XX` | Successful 請求成功
- `3XX` | Redirects 重新定向、轉址
- `4XX` | Client Error 客戶端錯誤
- `5XX` | Server Error 伺服器端錯誤

---
#### 參考資料 💾
[HTTP MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP)
[什麼是 HTTP、HTTPS](https://www.youtube.com/watch?v=-tRp1IOlKkI&ab_channel=GrandmaCan-%E6%88%91%E9%98%BF%E5%AC%A4%E9%83%BD%E6%9C%83)
[訊息格式](https://notfalse.net/39/http-message-format)
