Content-Disposition Header

 Content-Disposition 헤더는 브라우저에게 어떻게 특정 콘텐츠를 처리할지 지시한다.

만약 파일을 다운로드로 처리하려면, 이 헤더를 attachment로 설정한다.

 

1. Attachment

기능: 브라우저가 콘텐츠를 직접 표시하는 대신 사용자에게 파일을 다운로드하도록 지시한다.
사용 예시: Content-Disposition: attachment; filename="example.pdf"


2. Inline

기능: 콘텐츠가 브라우저에 직접 표시되어야 함을 나타낸다.

예를 들어, 이미지나 PDF 같은 파일을 브라우저에서 바로 볼 수 있다.
사용 예시: Content-Disposition: inline


3. Filename 매개변수

attachment 또는 inline 디렉티브와 함께 사용되어, 특정 파일 이름을 지정한다.
사용 예시: Content-Disposition: attachment; filename="example.txt"


4. Filename* 매개변수

파일 이름에 비ASCII 문자가 포함된 경우 이를 인코딩하기 위해 사용
사용 예시: Content-Disposition: attachment; filename*=UTF-8''%E2%82%ACrates

 

 

<정리>

Content-Disposition 헤더의 사용은 주로 다운로드를 제어하거나 특정 타입의 콘텐츠를 브라우저에서 직접 표시하는 데 초점을 맞추고 있다.