#?SuikaWiki/0.9 page-icon="HTTP" [4] [[HTTP]] で[[実体]]に対してどんな[[内容符号化]]が施されているのかを示すのが、 [DFN[[CODE(HTTP)[Content-Encoding:]] 欄]]です。 この欄は名前こそ [CODE[Content-]] がつきますが、 [[MIME]] では規定されておらず、 HTTP 独自のものです。 [2] 内容符号化は MIME の[[内容転送符号化]]や HTTP の[[転送符号化]]よりも上 (データ側) の層に当たります。 MIME への[[関門]]では[[媒体型]]の指定に変換することが良いとされています。 (例: HTTP: [SAMP(HTTP)[Content-Encoding: gzip]] → MIME: [SAMP(HTTP)[Content-Type: [[application/x-gzip]]]]) - [9] [CODE(HTTP)[Content-Encoding: gzip]] かつ [CODE(HTTP)[[[Content-Type:]] application/x-gzip]] で送ってくるサーバーがありますが、ほとんど間違いなく間違いなので(謎)、止めた方がいいですね。 -- [10] >>9 の問題の原因は実は [[Apache]] を [[distro]] 配布の [[RPM]] で入れたりした場合に、システム共用の [CODE(file)[[[/etc]]/[[mime.types]]]] が使われて、そのファイルに [CODE[application/x-gzip .gz]] って書いてある、って話だったりします。ちょっと困ったもんです。 - [16] [CODE(HTTP)[Content-Encoding: gzip]] かつ [CODE(HTTP)[[[Content-Type:]] application/x-gzip]] というレスポンスは、 [CODE[*.tar.gz]] などの形式で配布しているアーカイブのためなのでは無いのですか? ([[ten]] [WEAK[2004-06-02 11:43:03 +00:00]]) [17] >>16 そのような応答は、 まず [CODE(HTTP)[Content-Encoding]] を復号して生に戻した状態で [CODE(MIME)[application/x-gzip]] として解釈するのが正解です。 [CODE(file)[[VAR[*]].tar.gz]] を更にもう一度 gzip で圧縮しているのであれば >>16 の通りで何ら問題ありませんが、 [CODE(file)[[VAR[*]].tar.gz]] をそのまま送っているのであれば問題です ([CODE(MIME)[application/x-tar]] にでもなっていないと)。 ([[名無しさん]] [WEAK[2004-06-03 00:24:16 +00:00]]) [18] wf4jl4z-hvazctg-tw6qce63-0 http://worstever.net/forum/topic.asp?TOPIC_ID=236#1 online casino [url=http://snipurl.com/1frpp#3]phentermine online[/url] [url]http://worstever.net/forum/topic.asp?TOPIC_ID=236#4[/url] ([[viagra]] [d5s_test62@hotmail.com]) [19] wf4jl4z-hvazctg-tw6qce63-0 http://worstever.net/forum/topic.asp?TOPIC_ID=236#1 online casino [url=http://snipurl.com/1frpp#3]phentermine online[/url] [url]http://worstever.net/forum/topic.asp?TOPIC_ID=236#4[/url] ([[viagra]] [d5s_test62@hotmail.com]) [20] wf4jl4z-hvazctg-tw6qce63-0 http://worstever.net/forum/topic.asp?TOPIC_ID=236#1 online casino [url=http://snipurl.com/1frpp#3]phentermine online[/url] [url]http://worstever.net/forum/topic.asp?TOPIC_ID=236#4[/url] ([[viagra]] [d5s_test62@hotmail.com]) [21] wf4jl4z-hvazctg-tw6qce63-0 http://worstever.net/forum/topic.asp?TOPIC_ID=236#1 online casino [url=http://snipurl.com/1frpp#3]phentermine online[/url] [url]http://worstever.net/forum/topic.asp?TOPIC_ID=236#4[/url] ([[viagra]] [d5s_test62@hotmail.com]) [22] wf4jl4z-hvazctg-tw6qce63-0 http://worstever.net/forum/topic.asp?TOPIC_ID=236#1 online casino [url=http://snipurl.com/1frpp#3]phentermine online[/url] [url]http://worstever.net/forum/topic.asp?TOPIC_ID=236#4[/url] ([[viagra]] [d5s_test62@hotmail.com]) [23] wf4jl4z-hvazctg-tw6qce63-0 http://worstever.net/forum/topic.asp?TOPIC_ID=236#1 online casino [url=http://snipurl.com/1frpp#3]phentermine online[/url] [url]http://worstever.net/forum/topic.asp?TOPIC_ID=236#4[/url] ([[viagra]] [d5s_test62@hotmail.com]) [24] wf4jl4z-hvazctg-tw6qce63-0 http://worstever.net/forum/topic.asp?TOPIC_ID=236#1 online casino [url=http://snipurl.com/1frpp#3]phentermine online[/url] [url]http://worstever.net/forum/topic.asp?TOPIC_ID=236#4[/url] ([[viagra]] [d5s_test62@hotmail.com]) [25] wf4jl4z-hvazctg-tw6qce63-0 http://worstever.net/forum/topic.asp?TOPIC_ID=236#1 online casino [url=http://snipurl.com/1frpp#3]phentermine online[/url] [url]http://worstever.net/forum/topic.asp?TOPIC_ID=236#4[/url] ([[viagra]] [d5s_test62@hotmail.com]) [26] wf4jl4z-hvazctg-tw6qce63-0 http://worstever.net/forum/topic.asp?TOPIC_ID=236#1 online casino [url=http://snipurl.com/1frpp#3]phentermine online[/url] [url]http://worstever.net/forum/topic.asp?TOPIC_ID=236#4[/url] ([[viagra]] [d5s_test62@hotmail.com]) [27] wf4jl4z-hvazctg-tw6qce63-0 http://worstever.net/forum/topic.asp?TOPIC_ID=236#1 online casino [url=http://snipurl.com/1frpp#3]phentermine online[/url] [url]http://worstever.net/forum/topic.asp?TOPIC_ID=236#4[/url] ([[viagra]] [d5s_test62@hotmail.com]) [28] wf4jl4z-hvazctg-tw6qce63-0 http://worstever.net/forum/topic.asp?TOPIC_ID=236#1 online casino [url=http://snipurl.com/1frpp#3]phentermine online[/url] [url]http://worstever.net/forum/topic.asp?TOPIC_ID=236#4[/url] ([[viagra]] [d5s_test62@hotmail.com]) [29] wf4jl4z-hvazctg-tw6qce63-0 http://worstever.net/forum/topic.asp?TOPIC_ID=236#1 online casino [url=http://snipurl.com/1frpp#3]phentermine online[/url] [url]http://worstever.net/forum/topic.asp?TOPIC_ID=236#4[/url] ([[viagra]] [d5s_test62@hotmail.com]) [30] wf4jl4z-hvazctg-tw6qce63-0 http://worstever.net/forum/topic.asp?TOPIC_ID=236#1 online casino [url=http://snipurl.com/1frpp#3]phentermine online[/url] [url]http://worstever.net/forum/topic.asp?TOPIC_ID=236#4[/url] ([[viagra]] [d5s_test62@hotmail.com]) [31] wf4jl4z-hvazctg-tw6qce63-0 http://worstever.net/forum/topic.asp?TOPIC_ID=236#1 online casino [url=http://snipurl.com/1frpp#3]phentermine online[/url] [url]http://worstever.net/forum/topic.asp?TOPIC_ID=236#4[/url] ([[viagra]] [d5s_test62@hotmail.com]) [32] Hello, Your site is great. Regards, Valintino Guxxi ([[Valintino]] [valintino@qmail.com]) [33] Hello, I just started my blog! [PRE[ http://buy-levitra.blog.drecom.jp/ Buy Levitra [URL=http://buy-levitra.blog.drecom.jp/]levitra[/URL] ([[Levitra]] [seodvizh@gmail.com]) ]PRE] [34] nice site! ([[norwegion cruise]] [asdasd@asdasd.com] [WEAK[2007-06-18 19:56:38 +00:00]]) [35] buy levitra online buy levitra online buy levitra online [URL=http://freewebs.com/buy-levitrarx/generic-levitra.html]buy levitra online[/URL] http://freewebs.com/buy-levitrarx/generic-levitra.html ([[Jenny]] [rudffgdfvb@yahoo.com]) [36] The mission of the your site. buy zoloft buy bontril oxycodone [url=http://licia.artov.isc.cnr.it/twiki/pub/Main/ValentinoRossini/oxycodone.htm] oxycodone [/url] [url=http://licia.artov.isc.cnr.it/twiki/pub/Main/ValentinoRossini/didrex.htm] didrex [/url] ([[Milos]] [AchillesJolivity61@gawab.com]) [[#comment]] * 値 →[[内容転送符号化]>>1]参照。 * RFC 2616 の3.5 Content Codings [PRE[ Content coding values indicate an encoding transformation that has been or can be applied to an entity. Content codings are primarily used to allow a document to be compressed or otherwise usefully transformed without losing the identity of its underlying media type and without loss of information. Frequently, the entity is stored in coded form, transmitted directly, and only decoded by the recipient. ]PRE] - content-coding = token [PRE[ All content-coding values are case-insensitive. HTTP/1.1 uses content-coding values in the Accept-Encoding (section 14.3) and Content-Encoding (section 14.11) header fields. Although the value describes the content-coding, what is more important is that it indicates what decoding mechanism will be required to remove the encoding. ]PRE] [PRE[ The Internet Assigned Numbers Authority (IANA) acts as a registry for content-coding value tokens. Initially, the registry contains the following tokens: ]PRE] [PRE[ gzip An encoding format produced by the file compression program "gzip" (GNU zip) as described in RFC 1952 [25]. This format is a Lempel-Ziv coding (LZ77) with a 32 bit CRC. ]PRE] ファイル圧縮プログラム「gzip」(GNU zip) で生成される符号化形式で、 RFC 1952 で説明されているもの。この形式は Lempel-Ziv 符号化 (LZ77) と 32ビット [[CRC]] を使っています。 [PRE[ compress The encoding format produced by the common UNIX file compression program "compress". This format is an adaptive Lempel-Ziv-Welch coding (LZW). ]PRE] 共通 UNIX ファイル圧縮プログラム「compress」で生成される符号化形式。 この形式は Lempel-Ziv-Welch 符号化 (LZW) の一応用です。 [PRE[ Use of program names for the identification of encoding formats is not desirable and is discouraged for future encodings. Their use here is representative of historical practice, not good design. For compatibility with previous implementations of HTTP, applications SHOULD consider "x-gzip" and "x-compress" to be equivalent to "gzip" and "compress" respectively. ]PRE] 符号化形式にプログラム名を使うのは望ましいことではなく、 将来の符号化方式には推奨されません。ここで使っているのは 歴史的習慣表現であって、良い設計とはいえません。 HTTP の古い実装との互換性のため、応用は "x-gzip" と "x-compress" をそれぞれ "gzip" および "compress" と同様に解釈するのが '''望ましい'''です。 [PRE[ deflate The "zlib" format defined in RFC 1950 [31] in combination with the "deflate" compression mechanism described in RFC 1951 [29]. ]PRE] RFC 1950 で定義された「zlib」形式と RFC 1951 で説明されている 「deflate」 (収縮) 形式を組み合わせたものです。 [PRE[ identity The default (identity) encoding; the use of no transformation whatsoever. This content-coding is used only in the Accept- Encoding header, and SHOULD NOT be used in the Content-Encoding header. ]PRE] 規定 (同等) 符号化方式。無変形に使います。この内容符号化は Accept-Encoding (承認符号化方式) 頭にのみ使われ、 Content-Encoding (内容符号化方式) 頭に使う'''べきではありません'''。 [PRE[ New content-coding value tokens SHOULD be registered; to allow interoperability between clients and servers, specifications of the content coding algorithms needed to implement a new value SHOULD be publicly available and adequate for independent implementation, and conform to the purpose of content coding defined in this section. ]PRE] * HTTP/1.0 (RFC 1945) から抜粋 [PRE[ content-coding = "x-gzip" | "x-compress" | token ]PRE] [PRE[ Note: For future compatibility, HTTP/1.0 applications should consider "gzip" and "compress" to be equivalent to "x-gzip" and "x-compress", respectively. * 仕様書から ** RFC 1945 (HTTP/1.0) 10.3; RFC 2068 14.12・2616 14.11 (HTTP/1.1) Content-Encoding > The Content-Encoding entity-header field is used as a modifier to the media-type. When present, its value indicates what additional content codings have been applied to the entity-body, and thus what decoding mechanism[INS[s [INS[{2068}]]]] [DEL[[INS[{1945}]] must]] [INS[[INS[{2068}]] MUST]] [INS[[INS[{2616}]] must]] be applied in order to obtain the media-type referenced by the Content-Type header field. [DEL[[INS[{1945}]] The]] Content-Encoding is primarily used to allow a document to be compressed without losing the identity of its underlying media type. ]PRE] [CODE(HTTP)[Content-Encoding]] 実体頭欄は、媒体型の修飾子として使います。 示されている時、その値は何の追加の内容符号化が [CODE(ABNF)[entity-body]] に適用されており、ゆえに [CODE(HTTP)[[[Content-Type]]]] 頭欄で参照している媒体型を得るためには何の復号機構を適用しなければならないかを示します。 [CODE(HTTP)[Content-Encoding]] は主として元々の媒体型の識別を失うことなく文書を圧縮することを可能とするのに使います。 > - Content-Encoding = "Content-Encoding" ":" [INS[[INS[{2068}]] 1#]]content-coding > Content codings are defined in [DEL[[INS[{1945}]] Section]] [INS[[INS[{2068}]] section]] 3.5. An example of its use is > - Content-Encoding: [DEL[[INS[{1945}]] x-]]gzip > The [DEL[[INS[{1945,2068}]] Content-Encoding]] [INS[[INS[{2616}]] [CODE(ABNF)[content-coding]]]] is a characteristic of the [DEL[[INS[{1945}]] resource]] [INS[[INS[{2068}]] entity]] identified by the Request-URI. Typically, the [DEL[[INS[{1945}]] resource]] [INS[[INS[{2068}]] entity-body]] is stored with this encoding and is only decoded before rendering or analogous usage. [INS[[INS[{2616}]] However, a non-transparent proxy MAY modify the content-coding if the new coding is known to be acceptable to the recipient, unless the "no-transform" cache-control directive is present in the message.]] [CODE(ABNF)[content-coding]] は、 [CODE(ABNF)[[[Request-URI]]]]] で識別される実体の特徴です。典型的には、 [CODE(ABNF)[[[entity-bnody]]]] はこの符号化で蓄積され、レンダリングや同様の使用の前にだけ復号されます。 [INS[しかし、非透過串は、メッセージに [CODE(HTTP)[[[no-transform]]]] [CODE(ABNF)[cache-control]] 指令が示されていない限り、新しい符号化が受信者に受入れ可能であると分かっているなら、 [CODE(ABNF)[content-coding]] を修正しても'''構いません'''。]] [INS[ > [INS[{2616}]] If the content-coding of an entity is not "identity", then the response MUST include a Content-Encoding entity-header (section 14.11) that lists the non-identity content-coding(s) used. 実体の [CODE(ABNF)[content-coding]] が [CODE(HTTP)[[[identity]]]] でないなら、応答は使用した非 identity [CODE(ABNF)[content-coding]] を列挙した [CODE(HTTP)[Content-Encoding]] 実体頭欄を含めなければ'''なりません'''。 > If the content-coding of an entity in a request message is not acceptable to the origin server, the server SHOULD respond with a status code of 415 (Unsupported Media Type). 要求メッセージ中の実体の [CODE(ABNF)[content-coding]] が起源サーバーに受け入れ可能でないときには、サーバーは状態符号 [CODE(HTTP)[[[415]]]] (未対応媒体型) で反応する'''べきです'''。 ]INS] [INS[ > [INS[{2068,2616}]] If multiple encodings have been applied to an entity, the content codings MUST be listed in the order in which they were applied. > Additional information about the encoding parameters MAY be provided by other entity-header fields not defined by this specification. 複数の符号化が実体に適用されている時は、内容符号化はそれが適用された順に列挙しなければ'''なりません'''。 符号化引数についての追加情報をこの仕様書で定義していない他の実体頭欄で提供しても'''構いません'''。 ]INS] ** RFC 1945 (HTTP/1.0) C.3; RFC 2068 (HTTP/1.1) 19.4.3; RFC 2616 (HTTP/1.1) 19.4.4 Introduction of Content-Encoding > [DEL[[DEL[RFC 1521]] [INS[MIME]]]] [INS[RFC 2045]] does not include any concept equivalent to [DEL[HTTP/1.0]] [INS[HTTP/1.1]]'s Content-Encoding header field. Since this acts as a modifier on the media type, proxies and gateways from HTTP to MIME-compliant protocols [DEL[must]] [INS[MUST]] either change the value of the Content-Type header field or decode the [DEL[Entity-Body]] [INS[entity-body]] before forwarding the message. (Some experimental applications of Content-Type for Internet mail have used a media-type parameter of ";conversions=" to perform [DEL[an equivalent function as]] [INS[[INS[{2616}]] a function equivalent to]] Content-Encoding. However, this parameter is not part of [DEL[[DEL[RFC 1521]] [INS[MIME]]]] [INS[RFC 2045]].) [13] RFC 2045 は HTTP/1.1 の Content-Encoding 頭欄に相当する概念を持っていません。 この行為は媒体型を編集するものなので、 HTTP から MIME に従ったプロトコルへの串と関門は Content-Type 頭欄の値を変えるか、[[実体本体]]をメッセージ転送の前に復号するかし'''なければなりません'''。 (Internet メイルの実験的 Content-Type 応用には媒体型パラメーター ";conversions=" を Content-Encoding に相当する機能に使っているものもあります。 しかし、このパラメーターは RFC 2045 の一部ではありません。) [INS[ [14] 訳注: [[application/octet-stream]]の [CODE[conversions]] パラメーターのことかな? ]INS] [INS[ 注意: 注記のない修正点は RFC 1945 → RFC 2068 もの。 ]INS] ** RFC の部分の License [[RFCのライセンス]] * メモ - [11] [[mod_gzip]] とか流行ってるわけですが、ほんとは転送上の圧縮は [CODE(HTTP)[Content-Encoding]] じゃなくて [CODE(HTTP)[[[Transfar-Encoding]]]] 使うべきじゃないんですかね。もっとも、主要 [[UA]] で対応しているのは [[Opera]] だけという有様ですが。。。 (一方内容符号化はほとんどの主要 UA で扱えるから。。。) [15] ファイルとして保存する時に UA が [CODE(HTTP)[Content-Encoding]] (特に [CODE(HTTP)[gzip]] を展開してしまい、利用者は圧縮したものを受取ったつもりでいて混乱するという問題が多発していまして、 内容折衝するのでもなければ [CODE(HTTP)[Content-Encoding]] は使うべきではないという意見すらありますね。 本当は保存時に展開するかどうかを UA が利用者に尋ねるのが良いのでしょう。 転送のためだけの圧縮も、 >>11 の言うように [CODE(HTTP)[Content-Encoding]] は使わずに [CODE(HTTP)[Transfer-Encoding]] にした方がいいでしょう。 [CODE(HTTP)[Transfer-Encoding]] に [CODE(HTTP)[gzip]] などが追加されたのはこの問題もたぶん考えてのことでしょう [WEAK[(という理由もあったのかどうかは調べてみないと分かりませんが)]]。 ([[名無しさん]])