> 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 :
Thanks for your example. > + '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. You have bad end of line marker. '\r\n' are just C/C++ end of line. Translated to Delphi, it is #13#10. And you have one too much: end of header is an empty line. You have two ! You code becomes: + 'Connection: ' + ClientCnx.FRequestConnection + #13#10 + + #13#10; // Only one CRLF to end the header. Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html -- [EMAIL PROTECTED] http://www.overbyte.be ----- Original Message ----- From: "Lepidosteus" <[EMAIL PROTECTED]> To: <twsocket@elists.org> Sent: Sunday, May 28, 2006 3:09 AM Subject: [twsocket] ICS: Sending file through THttpServer, code exemple > 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 -- 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