#1 2017-03-15 11:32:59

CycleSoft
Member
Registered: 2013-01-18
Posts: 34

How to add t0 TServiceCustomAnswer.Header more than a hedear

Hi,
I need to add not only a HEADER_CONTENT_TYPE header, but also a:

Content-Disposition: attachment; filename=<a server side suggested file name>

but seems that only the last header added to the property TServiceCustomAnswer.Header is sent back to the client

The OnAfterURI event can't be used because it does not know the suggested file name. (it is determined inside the interface based service).
Same as for overriding the URI method of the TSQLRestServer.

I'm NOT using the last version of the framework (don't ask! smile ) maybe is something already solved in latest versions?

If not, any suggestion on how to do it ?

Thanks!

Offline

#2 2017-03-15 12:01:40

Chaa
Member
Registered: 2011-03-26
Posts: 245

Re: How to add t0 TServiceCustomAnswer.Header more than a hedear

CycleSoft wrote:

but seems that only the last header added to the property TServiceCustomAnswer.Header is sent back to the client

You can add multiple headers to TServiceCustomAnswer.Header, but Content-Type must be first header.

Result.Header := 'Content-Type: application/pdf'
  + #13#10 + 'Content-Disposition: inline; filename="report.pdf"';

P.S.
You can debug TSQLHttpServer.Request to find what's wrong with your headers.

Last edited by Chaa (2017-03-15 12:03:36)

Offline

#3 2017-03-15 12:21:00

CycleSoft
Member
Registered: 2013-01-18
Posts: 34

Re: How to add t0 TServiceCustomAnswer.Header more than a hedear

Thanks for the answer Chaa,

it is exactly what I have tried, but it seemed that the first header specified  ( Content-Type ) is 'lost' and does not reach the client

Now I had tried swapping the 2 headers ( Content-Disposition first, then Content-Type ) and it seems work!

a little bit odd, but maybe I'm just ignoring something.

Thanks again!

Offline

Board footer

Powered by FluxBB