[Lazarus] fpWeb file download
Leonardo M. Ramé
l.rame at griensu.com
Thu Jun 10 22:23:41 CEST 2010
Hi, I'm trying to implement file downloading for an fpWeb CGI without
success, I'm doing this so far:
procedure TFPWebModule1.TFPWebActions0Request(Sender: TObject;
ARequest: TRequest; AResponse: TResponse; var Handled: Boolean);
var
lImage: string;
lFileStream: TFileStream;
begin
lImage := '/home/leonardo/files/file1.dcm';
lFileStream := TFileStream.Create(lImage, fmShareDenyNone);
try
AResponse.ContentType := 'image/dicom3';
AResponse.CustomHeaders.Values['Content-Disposition'] :=
'attachment; filename=' + ExtractFileName(lImage);
AResponse.LoadFromStream(lFileStream, True);
AResponse.SendContent; // not sure if this is needed.
finally
lFileStream.Free;
end;
Handled := True;
end;
And the results of curl are this:
* About to connect() to localhost port 80 (#0)
* Trying ::1... connected
* Connected to localhost (::1) port 80 (#0)
> GET /cgi-bin/getstudy/StudyId?IdSeries=1 HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7
OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15
> Host: localhost
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Thu, 10 Jun 2010 20:17:52 GMT
< Server: Apache/2.2.14 (Ubuntu)
< Content-Disposition: attachment; filename=MR_4c1139a4b76d62c2.dcm
< Content-Length: 0
< Content-Type: image/dicom3
<
* Connection #0 to host localhost left intact
* Closing connection #0
As you can see, the Content-Lenght is 0, and the image isn't downloaded.
What is the correct way of implementing this?.
--
Leonardo M. Ramé
Griensu S.A. - Medical IT Córdoba
Tel.: 0351-4247979
More information about the Lazarus
mailing list