Atozed Forums

Full Version: How fix a raw text image gif to send to front end
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a winCGI executable script returning a image. I am using Intraweb as server.

The cgi is from a third party and I can't change your code.

I create my owner  ContentHandler to run the cgi. 

I am not using CGIRunner because It diidn´t work to me.

My handler is something as:

Code:
function TContentDicom.Execute(aRequest: THttpRequest; aReply: THttpReply;
  const aPathname: string; aSession: TIWApplication;
  aParams: TStrings): boolean;
var
  s,wresult,saida,LocalDoc:string;
  i:integer;
begin
  Result:=True;
  LocalDoc:=TIWAppInfo.GetAppPath + 'wwwroot\cgi-bin\tcgi.exe';
  saida:=StrOemToAnsi(MyRunCGI(LocalDoc,TIWAppInfo.GetAppPath + 'wwwroot\cgi-bin\'));
  with aReply do
    begin
      ResetReplyType;
      Code := 200;
      ContentType := MIME_GIF; // MIME_HTML;
      SendStream(TstringStream.Create(saida));
    end;
end;
I have the next code returning from CGI when I query a image:

   
Code:
'Content-type: image/gif'#$A'Access-Control-Allow-Origin: *'#$A#$A'GIF89a@'#1'@'#1'1222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~'#$7F#$7F#$7F'€€€'#$0081#$0081#$0081'‚‚‚ƒƒƒ„„„………†††‡‡‡ˆˆˆ‰‰‰ŠŠŠ‹‹‹ŒŒŒ'#$008D#$008D#$008D'ŽŽŽ'#$008F#$008F#$008F#$0090#$0090#$0090'‘‘‘’’’“““”””•••–––———˜˜˜™™™ššš›››œœœ'#$009D#$009D#$009D'žžžŸŸŸ   ¡¡¡¢¢¢£££¤¤¤¥¥.................


I need to send the image to a front end app in the browser.

   
Code:
<div>
    <img src="getImage(1)">
</div>

Here, getImage function takes the image from server, but not is showing, because I think the format I am returning the image from server to front end has something wrong.
How could I fix the content text of the image on server to be a valid image in the front end?
Hi, wihch version of iw are you using?