Content-disposition 속성

web 2009. 2. 13. 19:50

Content-Disposition 은 컨텐트 타입의 옵션이기도 하며 실제로 지정된 파일명을 지정함으로써 더 자세한 파일의 속성을 알려줄 수 있다.

 

http://www.ietf.org/rfc/rfc2183.txt 스펙을 보면..


2.1  The Inline Disposition Type

   A bodypart should be marked `inline' if it is intended to be
   displayed automatically upon display of the message.  Inline
   bodyparts should be presented in the order in which they occur,
   subject to the normal semantics of multipart messages.

2.2  The Attachment Disposition Type

   Bodyparts can be designated `attachment' to indicate that they are
   separate from the main body of the mail message, and that their
   display should not be automatic, but contingent upon some further
   action of the user.  The MUA might instead present the user of a
   bitmap terminal with an iconic representation of the attachments, or,
   on character terminals, with a list of attachments from which the
   user could select for viewing or storage.

 

이렇게 정의되어 있다.

 


즉  "Content-disposition: inline"은

브라우저 인식 파일확장자를 가진 파일들에 대해서는 웹브라우저 상에서 바로 파일을 자동으로 보여줄 수 있어서 의미상인 멀티파트 메시지를 표현하는데 있다. 그외의 파일들에 대해서는 "파일 다운로드" 대화상자가 뜨도록 하는 헤더속성이다.

"Content-disposition: attachment"은
브라우저 인식 파일확장자를 포함하여 모든 확장자의 파일들에 대해,  다운로드시 무조건 "파일 다운로드" 대화상자가 뜨도록 하는 헤더속성이라 할 수 있다.

 

스펙에 보면. 다음과 같은 BNF 는 이렇게 정의되어 있다.

 

     disposition := "Content-Disposition" ":"
                    disposition-type
                    *(";" disposition-parm)

     disposition-type := "inline"
                       / "attachment"
                       / extension-token
                       ; values are not case-sensitive

     disposition-parm := filename-parm
                       / creation-date-parm
                       / modification-date-parm
                       / read-date-parm
                       / size-parm
                       / parameter

     filename-parm := "filename" "=" value

     creation-date-parm := "creation-date" "=" quoted-date-time

     modification-date-parm := "modification-date" "=" quoted-date-time

     read-date-parm := "read-date" "=" quoted-date-time

     size-parm := "size" "=" 1*DIGIT

     quoted-date-time := quoted-string
                      ; contents MUST be an RFC 822 `date-time'
                      ; numeric timezones (+HHMM or -HHMM) MUST be used

 

 

 

샘플 예제는 다음과 같다. 게시판에서 자주 쓸 수 있다.

게시판 서버에서 html, htm, jsp은 보여주고 나머지는 attachment로 알려주는 것이다. 

    <Location  / >
        Header set Content-Disposition "attachment"
    </Location>

    <Location ~ "/.*(html|htm|jsp|)" >
        Header unset Content-Disposition
    </Location>

만약  swf 파일도 그냥 보여주고 싶다면, attachment 속성 대신 inline을 쓰면 되겠다.

Posted by '김용환'
,