[1] [DFN[[CODE(HTTP)@en[[[Slug]]:]] [[頭欄]]]]は、
作成される[[資源]]の [[URL]] の決定時のヒントを表します。

* 仕様書

[REFS[
- [2] [CITE@en[RFC 5023 - The Atom Publishing Protocol]] 
-- <https://tools.ietf.org/html/rfc5023#section-9.7>
-- <https://tools.ietf.org/html/rfc5023#section-16.3>
]REFS]

* 意味

[3] [CODE(HTTP)@en[[[Slug]]:]] [[欄]]が [CODE(HTTP)@en[[[POST]]]]
[[要求]]に含まれている場合、その値は作成される[[エントリー資源]]や[[媒体資源]]が通常[[取り出し]]される際に使われる
[[URI]] の一部分として[[クライアント]]が望む値を表します。
[SRC@en[[[AtomPub]]]]

* 構文

[5] [[AtomPub]] より:

>
       LWS      = <defined in Section 2.2 of [RFC2616]>
       slugtext = %x20-7E | LWS
       Slug     = "Slug" ":" *slugtext


[6] 値は [[RFC 3629]] [[UTF-8]] で[[符号化]]し、 [[RFC 3986]] [[百分率符号化]]を施した値とされています。
[SRC@en[[[AtomPub]]]]

* 文脈

[12] [[AtomPub]] の[[要求]]で使われます。

[13] それ以外でも稀に使われるようです (>>8、>>10)。

* 処理

[4] [[鯖]]は新しく作成する[[資源]]の[[成員URI]] を作成する時にこの[[欄]]の値を使って[['''構いません''']]。
例えば、その値の一部または全部を [[URI]] の最後の [[segment]] に使うことができます。
[[鯖]]は [CODE(XMLe)@en[atom:[[id]]]] や[[媒体リンク・エントリー]]の [CODE(XML)@en[[[title]]]]
にも使って[['''構いません''']]。[[鯖]]はこの[[欄]]を無視しても[['''構いません''']]。
値の一部の[[文字]]を置き換えるなど変形させても[['''構いません''']]。
[SRC@en[[[AtomPub]]]]

* 例

[7] [[AtomPub]] より

[PRE(HTTP example code)[
       POST /myblog/entries HTTP/1.1
       Host: example.org
       Content-Type: image/png
       Slug: The Beach at S%C3%A8te
       Authorization: Basic ZGFmZnk6c2VjZXJldA==
       Content-Length: nnn

       ...binary data...
]PRE]

* 関連

[11] [[フォーム提出]]など [CODE(MIME)@en[multipart/form-data]] で[[ファイル]]を送信する場合には、
[CODE(MIME)@en[Content-Disposition]] [[ヘッダー]]の [CODE(MIME)@en[filename]]
[[引数]]で[[ファイル名]]が指定されますから、[[サーバー]]はそれを[[ヒント]]に使えます。

[14] [[ダウンロード]]の[[ファイル名]]の指定には、[[応答]]の
[CODE(HTTP)@en[Content-Disposition:]] [[ヘッダー]]の
[CODE(MIME)@en[filename]] [[引数]]や、[[リンク元]]の [[HTML]]
の [CODE(HTMLe)@en[a]] [[要素]]の [CODE(HTMLa)@en[download]]
[[属性]]が使えます。

* メモ

[8] [CITE[Protocol Guide (v3.0) - Google Documents List Data API v3.0 - Google Code]]
([TIME[2009-10-10 03:25:53 +09:00]] 版)
<http://code.google.com/intl/ja-JP/apis/documents/docs/3.0/developers_guide_protocol.html>

[9] [CITE@en[Developer's Guide: JSON-C / JavaScript - YouTube — Google Developers]]
( ([TIME[2013-09-12 18:53:20 +09:00]] 版))
<https://developers.google.com/youtube/2.0/developers_guide_jsonc?hl=ja&csw=1>

[FIG(quote)[
[FIGCAPTION[
[10] [CITE@en[Linked Data Platform 1.0]]
([TIME[2015-02-27 16:17:29 +09:00]] 版)
<https://dvcs.w3.org/hg/ldpwg/raw-file/default/ldp.html#h-ldpc-post-slug>
]FIGCAPTION]

> 5.2.3.10 LDP servers may allow clients to suggest the URI for a resource created through POST, using the HTTP Slug header as defined in '''['''RFC5023''']'''. LDP adds no new requirements to this usage, so its presence functions as a client hint to the server providing a desired string to be incorporated into the server's final choice of resource URI.

]FIG]


[FIG(quote)[
[FIGCAPTION[
[15] [CITE@en[Web Annotation Protocol]]
([TIME[2017-02-24 02:14:26 +09:00]])
<https://w3c.github.io/web-annotation/protocol/wd/#h-suggesting-an-iri-for-an-annotation>
]FIGCAPTION]

> The IRI path segment that is appended to the Container IRI for a resource may be suggested by the Annotation Client by using the Slug HTTP header on the request when the resource is created. The server should use this name, so long as it does not already identify an existing resource, but may  ignore it and use an automatically assigned name.

]FIG]


[FIG(quote)[
[FIGCAPTION[
[16] [CITE@en[OSLC Core Version 3.0. Part 5: Attachments]]
([TIME[2017-04-05 01:00:00 +09:00]])
<http://docs.oasis-open.org/oslc-core/oslc-core/v3.0/cs01/part5-attachments/oslc-core-v3.0-cs01-part5-attachments.html>
]FIGCAPTION]

> 5.4.2 Clients may use the HTTP Slug request header '''['''RFC5023''']''' to suggest a name when creating an attachment. If present, the Slug header should not include a file extension.

]FIG]
