You are not logged in.
Pages: 1
I need this too. Sometimes need to send big pictures (6MB+) and don't know what is the better approach.
How to get feedback to show a gauge, for example?
Last edited by Junior/RO (2013-03-04 20:26:15)
Offline
If the picture is a file, you can use a special kind of content type response, as defined in SynCrtSock unit.
const
/// used by THttpApiServer.Request for http.sys to send a static file
// - the OutCustomHeader should contain the proper 'Content-type: ....'
// corresponding to the file (e.g. by calling GetMimeContentType() function
// from SynCommons supplyings the file name)
HTTP_RESP_STATICFILE = '!STATICFILE';
Note that it will work only with THttpApiServer kind of server (i.e. using high performance http.sys API).
But whole file access and sending will occur in background, at the kernel level, so with best performance.
It is used by sample "09 - HttpApi web server". See HttpApiServer.dpr
But this does not handle chunking process, so I guess a "gauge" may not work as expected for AJAX.
For non AJAX client process, it will depend on your client class.
Offline
Offline
TSQLHttpServer can use HTTP_RESP_STATICFILE kind of content.
It will let the server side be much scalable, if your purpose is exactly to serve some file content.
In all cases, all RESTful process relies on memory, so even interface-based services is not meant to server GB of data.
Unless you switch to 64 bit version of the compiler.
The Delphi HTTP client classes do not have a progress callback yet.
It may be possible to add it at TWinHttpAPI class level, i.e. for WinINet and WinHTTP APIs. You can add a feature request as a ticket in http://synopse.info/fossil/reportlist
For direct socket client, it would need more code refactoring.
Offline
I want to discuss this http://synopse.info/fossil/info/ce1141092e ticket.
I agree with you about using FindIniNameValue() and work with InHead. Everything is OK here.
But what should I do to send static file with custom content type? Seams I must add CONTENT-TYPE twice into OutHeader?
Ctxt.Call.OutHeader := HEADER_CONTENT_TYPE + HTTP_RESP_STATICFILE + #13#10 + HEADER_CONTENT_TYPE + getMyCustomContentType();
I'm right?
Offline
Yes, I rewrite my code in this manner - everything work good and now I'm compatible with main mORMot branch
Just one remark - when I send static files in this manner I get incorrect statistics:
TSQLRestServer.URI()
.....
inc(fStats.fOutcomingBytes,length(Call.OutHead)+length(Call.OutBody)+16);
we actually increase out bytes by fileName length
As for me is good to add fStats.fileTransfered counter and count number of files we send (calculating real file length is slow?)
Offline
As for me is good to add fStats.fileTransfered counter and count number of files we send (calculating real file length is slow?)
Good idea!
Please create a ticket for this small enhancement, so that we won't forget it.
Offline
created ticket http://synopse.info/fossil/tktview/4a24 … 9850d3606a
Offline
Pages: 1