Hello,

Looking to the mailling list, I've seen some people trying to send
file in the WebServ demo of ICS.

I've played around a bit with it trying to get it working, and ended
up with a very simple way to do it :

In HttpServer1GetDocument add the case you want :
...
    else if CompareText(ClientCnx.Path, '/myfile.mp3') = 0 then
         CreateVirtualDocument_File(Sender, ClientCnx, Flags);
...

Create the appropriate procedure CreateVirtualDocument_File

Then, put this code in it :

procedure TWebServForm.CreateVirtualDocument_File(
    Sender    : TObject;
    ClientCnx : TMyHttpConnection;
    var Flags : THttpGetFlag);
begin
  Flags := hgSendDoc;
  ClientCnx.FDocument:='J:\myfile.mp3';
end;

And you're done !

(i've seen numerous exemple of people trying to do that and no working
exemple, so i thought this would be a good thing to post it)

Lepidosteus

PS: I first tried to build up my own header using

header := ClientCnx.FVersion + ' Status ''200 OK''\r\n'
          + 'Content-Length: ' + inttostr(ClientCnx.FDocStream.size) +'\r\n'
          + 'Content-type: '+DocumentToContentType(ClientCnx.FDocument)+'\r\n'
          + 'Content-Disposition: attachment; filename=' +
ClientCnx.FDocument +'\r\n'
          + 'Connection: ' + ClientCnx.FRequestConnection + '\r\n'
          + '\r\n\r\n';

With the correct flag and a valid file Stream associated to
ClientCnx.FDocStream, but I ended up with random behaviours (unknown
size by browsers, no action in firefox, opera wouldn't see when the
download is over, etc ...)

I guess i did it bad.
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to