Atozed Forums

Full Version: Http.sys and TIWCGJQPDFViewer error: Atozed or CGDevTools?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

TIWCGJQPDFViewer error message is: PDF.js v1.10.88 (build: c62a1938) Messagge: file origin does not match viewer's

when I use Indy it's ok, no errors.

When I use new http.sys the TIWCGJQPDFViewer does't find pdf file (see below why)


Test scenario:
Public port 3434 redirected on private port 3535 (intraweb app use 3535 port), on my public IP XXX.XXX.X

From a remote site open a browser session http://XXX.XXX.X:3434

UserSession

Code:
function TIWUserSession.PreparePDF: string;

var ms : TMemoryStream;
begin
  Result := TIWAppCache.NewTempFileName;
  ms := TMemoryStream.Create;
  try
    ms.LoadFromFile('wwwroot/pdf/somePDFfile.pdf');
    ms.SaveToFile( Result );
  finally
    ms.Free;
  end;
  Result := TIWAppCache.AddFileToCache(WebApplication, Result, TIWMimeTypes.GetAsString(mtPDF), IW.CacheStream.ctOneTime);
end;


MainForm
Code:
procedure TIWForm1.IWCGJQButton1JQButtonOptionsClick(Sender: TObject; AParams: TStringList);
var pdfFName : string;
begin
 pdfFName := ServerController.UserSession.PreparePDF;
 with TiwFormPDFViewer.Create(WebApplication, pdfFName) do 
   Show;
end;

PDFViewerForm
Code:
constructor TiwFormPDFViewer.Create(AOwner: TComponent; pdfFile : string; showPreview: boolean);
begin
  inherited Create(AOwner);
  IWCGJQPDFViewer1.JQPDFViewerOptions.PDFFileName := pdfFile;
end;


From the browser console (remember XXX.XXX.XXX.X is my public IP) 

with Indy, 

<iframe style="width:100%;height:100%;border:0;" src="/pdf/jq/pdf.js/web/viewer.pdfv?file=http%3A%2F%2FXXX.XXX.XXX.X%3A3434%2Fpdf%2F%24%2Ftemp%2FATZKckrBtj3fu~hbGXiCzjY-W"></iframe>

decoded URL: /pdf/jq/pdf.js/web/viewer.pdfv?file=http://XXX.XXX.XXX.X:3434/pdf/$/temp/ATZKckrBtj3fu~hbGXiCzjY-W


with Http.sys:
<iframe style="width:100%;height:100%;border:0;" src="/pdf/jq/pdf.js/web/viewer.pdfv?file=http%3A%2F%2FXXX.XXX.XXX.X%3A3535%2Fpdf%2F%24%2Ftemp%2FATZepIzsB8XUeYSw2FW6aToMG"></iframe>

decode URL: /pdf/jq/pdf.js/web/viewer.pdfv?file=http://XXX.XXX.XXX.X:3535/pdf/$/temp/ATZlW4ZM9l-U0sTMNVGxvk5Xa

3535 is the local port and obviusly the PDF viewer can't get pdf file (from a remote site must be used 3434 open port)

With Http.sys the url for the cache file is with same port of intraweb application (3535)
while with Indy the cache file is correctly build with requested port 3434

If I simply open my public port 3535 (without a redirect 3434->3535) all works as espected.


Sorry for long post but it's very complicated to explain

Alfredo.

Intraweb 15.0.10, CGDevTools 4.1.0.102