[ 
https://issues.apache.org/jira/browse/OLINGO-1041?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Alexander Parr updated OLINGO-1041:
-----------------------------------
    Description: 
Hi all,
I implemented method 'readEntityMedia' which is called via $value for an 
entity. As I do return a PDF file I like to set the response header 
'Cache-Control' to a defined value which is 'max-age = 86400, public' in my 
case.

By default the 'Cache-Control' header is set to private. I tried to change the 
header by using method 'header' of the ODataResponseBuilder:

{code:borderStyle=solid}
public ODataResponse readEntityMedia(GetMediaResourceUriInfo uriInfo,
                        String contentType) throws ODataException {
...
ODataResponseBuilder responseBuilder = 
ODataResponse.fromResponse(EntityProvider.writeBinary(mimeTypeRequested, 
documentData));
                                
responseBuilder
        .header("Cache-Control", "max-age = 86400, public")
        .header("Content-Disposition", "inline;filename=\"" + fileName + "\"");
                                
return responseBuilder.build();

}
{code}

Unfortunately the response header now contains both:
Cache-Control:private 
and
Cache-Control:max-age = 86400, public

which is not what I expected. By calling method 'header' of the ResponseBuilder 
I expect that if a header already exists it gets overwritten.

Best regards,
Alex


  was:
Hi all,
I implemented method 'readEntityMedia' which is called via $value for an 
entity. As I do return a PDF file I like to set the response header 
'Cache-Control' to a defined value which is 'max-age = 86400, public' in my 
case.

By default the 'Cache-Control' header is set to private. I tried to change the 
header by using method 'header' of the ODataResponseBuilder:

public ODataResponse readEntityMedia(GetMediaResourceUriInfo uriInfo,
                        String contentType) throws ODataException {
...
ODataResponseBuilder responseBuilder = 
ODataResponse.fromResponse(EntityProvider.writeBinary(mimeTypeRequested, 
documentData));
                                
responseBuilder
        .header("Cache-Control", "max-age = 86400, public")
        .header("Content-Disposition", "inline;filename=\"" + fileName + "\"");
                                
return responseBuilder.build();

}

Unfortunately the response header now contains both:
Cache-Control:private 
and
Cache-Control:max-age = 86400, public

which is not what I expected. By calling method 'header' of the ResponseBuilder 
I expect that if a header already exists it gets overwritten.

Best regards,
Alex



> Set Cache-Control Header for OData Response
> -------------------------------------------
>
>                 Key: OLINGO-1041
>                 URL: https://issues.apache.org/jira/browse/OLINGO-1041
>             Project: Olingo
>          Issue Type: Bug
>          Components: odata2-core
>    Affects Versions: V2 2.0.6
>         Environment: SAP HANA Cloud Platform
>            Reporter: Alexander Parr
>            Priority: Minor
>              Labels: ODataResponseBuilder, cache-control, header, headers
>
> Hi all,
> I implemented method 'readEntityMedia' which is called via $value for an 
> entity. As I do return a PDF file I like to set the response header 
> 'Cache-Control' to a defined value which is 'max-age = 86400, public' in my 
> case.
> By default the 'Cache-Control' header is set to private. I tried to change 
> the header by using method 'header' of the ODataResponseBuilder:
> {code:borderStyle=solid}
> public ODataResponse readEntityMedia(GetMediaResourceUriInfo uriInfo,
>                       String contentType) throws ODataException {
> ...
> ODataResponseBuilder responseBuilder = 
> ODataResponse.fromResponse(EntityProvider.writeBinary(mimeTypeRequested, 
> documentData));
>                               
> responseBuilder
>       .header("Cache-Control", "max-age = 86400, public")
>       .header("Content-Disposition", "inline;filename=\"" + fileName + "\"");
>                               
> return responseBuilder.build();
> }
> {code}
> Unfortunately the response header now contains both:
> Cache-Control:private 
> and
> Cache-Control:max-age = 86400, public
> which is not what I expected. By calling method 'header' of the 
> ResponseBuilder I expect that if a header already exists it gets overwritten.
> Best regards,
> Alex



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to