spring-projects / spring-framework

Spring Framework
https://spring.io/projects/spring-framework
Apache License 2.0
56.63k stars 38.14k forks source link

Introduce HttpHeaders getContentDisposition() and setContentDisposition() [SPR-14408] #18979

Closed spring-projects-issues closed 6 years ago

spring-projects-issues commented 8 years ago

Oliver Drotbohm opened SPR-14408 and commented

The HTTP 1.1 spec defines the Content-Disposition header to contain a filename attribute that servers can use to indicate the name of the file served. Currently, users of HttpHeaders manually have to lookup the Content-Disposition header and then parse the value to extract the filename.

It would be cool if the filename was either available directly or HttpHeaders allowed to get access to a ContentDisposition object, that provides access to the filename contained in it.


Affects: 4.3 GA

Issue Links:

Referenced from: commits https://github.com/spring-projects/spring-framework/commit/99a8510ace46af9b05b822e7c65f08aae885ca98

spring-projects-issues commented 8 years ago

Rossen Stoyanchev commented

Sébastien Deleuze I'm assigning this to you since Content-Disposition also comes up in multipart requests and you already have #19114 as well as #19108 for the reactive alternative of FormHttpMessageConverter. Note that HttpHeaders already has methods for setting the Content-Disposition header that are used by the form message converter when writing the headers for individual parts.

spring-projects-issues commented 8 years ago

Sébastien Deleuze commented

Pull request submitted.

spring-projects-issues commented 8 years ago

Sébastien Deleuze commented

I have updated the PR that now introduces a new HttpHeaders.ContentDisposition class and a new HttpHeaders#getContentDisposition() method that allows to retrieve the disposition type and name, filename, filename* and size parameters.

spring-projects-issues commented 8 years ago

Sébastien Deleuze commented

I have resolved this issue via this commit.

It introduces a new ContentDisposition class designed to parse and generate Content-Disposition header value as defined in RFC 2183. It supports the disposition type and the name, filename (or filename* when encoded according to RFC 5987) and size parameters.

This new class is usually used thanks to the new getContentDisposition() and setContentDisposition(ContentDisposition) added to HttpHeaders.