#1 2015-11-12 15:39:27

StxLog
Member
From: France
Registered: 2015-09-14
Posts: 58

Change header from TMVCApplication method

Hi,

I have a function in a TMVCApplication which produce a PDF with fastReport, and then keep it for a while as temp file. I'd like to avoid temp file and send the pdf directly as stream over HTTP.
To do so, does there is a way to access http header/content from TMVCApp method or function? Or should I necesseraly use an interface/method-service?

Thanks!

Offline

#2 2015-11-12 17:27:24

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Change header from TMVCApplication method

You have access to the ServiceContext threadvar, AFAIK.
See http://synopse.info/files/html/Synopse% … l#TITL_107

Offline

#3 2015-11-13 13:09:11

StxLog
Member
From: France
Registered: 2015-09-14
Posts: 58

Re: Change header from TMVCApplication method

Thanks, indeed I havn't seen I could access it from here.

So i've been trying to implement it, with Request.ReturnBlob or Request.Call.OutHead ... But couldn't figure out how to do, so if someone could point me in the right direction it would be greatly appreciated.
Should i send my stream from a procedure? A function? MVC command?

I have my interface and TMVCApp declared as such:

ICustWebApp = interface(IMVCApplication)
  [...]
  function GetReportDoc(const ID: RawUTF8): TMVCAction;
  procedure Reports(const link: RawUTF8; var Scope: Variant);
end;

TCustWebApp = class(TMVCApplication, ICustWebApp)
  [...]
  function GetReportDoc(const ID: RawUTF8): TMVCAction;
  procedure Reports(const link: RawUTF8; var Scope: Variant);
end;

When I click in a link in the Reports.html page, it call GetReportDoc which generate then, theorically, send the report.


I've been trying to replace the return value of my GetReportDoc by TServiceCustomAnswer, but by doing so I need a GetReportDoc.html (dont want to) file and i can see my header and content, but as json when I go to root/GetReportDoc/json?ID=1, not in the HTTP header

Offline

Board footer

Powered by FluxBB