2025-01-24T01:44:03
This commit is contained in:
70
doc/etc/Webmention.md
Normal file
70
doc/etc/Webmention.md
Normal file
@@ -0,0 +1,70 @@
|
||||
# Webmention
|
||||
|
||||
만일 CMS에 다음과 같은 글이 작성되었다고 가정해 봅시다.
|
||||
|
||||
```html
|
||||
<article>
|
||||
<p>
|
||||
<a href="http://example.com/some-post">여기</a> 완전 좋아요.
|
||||
</p>
|
||||
</article>
|
||||
```
|
||||
|
||||
## 엔드포인트 찾기
|
||||
|
||||
CMS 소프트웨어에서는 작성된 글에서 외부 링크들을 추출해서 각각의 링크마다 HTTP HEAD/GET으로 조회를 합니다. 그러면 다음과 유사한 응답을 받을 겁니다.
|
||||
|
||||
```
|
||||
GET /some-post HTTP/1.1
|
||||
Host: example.com
|
||||
|
||||
------
|
||||
HTTP/1.1 200 OK
|
||||
Link: <http://example.com/webmention>; rel="webmention"
|
||||
|
||||
<html><head> ...
|
||||
<link href="http://example.com/webmention" rel="webmention" /> ...
|
||||
```
|
||||
|
||||
HTTP 헤더 혹은 `link` 태그에서 웹 멘션 주소를 찾을 수 있습니다.
|
||||
|
||||
## 서버 엔드포인트로 메시지 전송
|
||||
|
||||
CMS에서는 대상 서버의 엔드 포인트로 `application/x-www-form-urlencoded` 형식의 POST 메시지를 전송합니다. 메시지에는 `source`와 `target`이 포함되어야 합니다.
|
||||
|
||||
```
|
||||
POST /http://example.com/webmention HTTP/1.1
|
||||
Host: example.com
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
|
||||
source=https://client.example.com/new-post&target=http://example.com/some-post
|
||||
|
||||
------
|
||||
HTTP/1.1 202 Accepted
|
||||
```
|
||||
|
||||
메시지를 받은 서버는 `201 Created` 혹은 `202 Accepted`를 응답합니다.
|
||||
|
||||
## 한편, 메시지를 받은 서버에서는
|
||||
|
||||
전달 받은 데이터를 작업 큐에 등록하고, 작업 진행 내역을 보여주는 포에지 주소를 포함하는 `201` 또는 `202`를 응답합니다.
|
||||
|
||||
```
|
||||
HTTP/1.1 201 Created
|
||||
Location: http://aaronpk.example/webmention/DEhB9Jme
|
||||
```
|
||||
|
||||
```
|
||||
HTTP/1.1 202 Accepted
|
||||
```
|
||||
|
||||
검증에 실패한 경우에는 `400 Bad Request`를 응답합니다.
|
||||
|
||||
## 검증
|
||||
|
||||
- source와 target이 모두 유효한 Url인지 여부 확인
|
||||
- source와 target이 동일하면 거부
|
||||
|
||||
https://en.wikipedia.org/wiki/Linkback
|
||||
|
||||
https://www.w3.org/TR/webmention/
|
||||
Reference in New Issue
Block a user