#1 Re: mORMot 1 » HttpApi webServer x IndyHttp Firemonkey - PDF Files » 2015-06-05 21:16:57

I'm doing your sugestion, and changing to TSQLRestServerFullMemory
So far it's working smile
Thank you!

#2 Re: mORMot 1 » HttpApi webServer x IndyHttp Firemonkey - PDF Files » 2015-06-03 21:02:03

ab wrote:

Both those files do have the method!

The mORMotNightlyBuild have it, but not for httpApiServer.....

In the SynCrtSock.pas, i do not find it at all...

#3 Re: mORMot 1 » HttpApi webServer x IndyHttp Firemonkey - PDF Files » 2015-06-03 20:55:05

I find the function 'Ctxt.ReturnFile()' on ORMserver (from RestFull example...)

So i mixed both httpApiServer and and ormServer into one...
I really dont know if it's the best way to do it, but works smile

var
  fServer: TSQLHttpServer;
  ORMServer: TNoteServer;
  HTTPServer: THttpApiServer;
...
  HTTPServer := THttpApiServer.Create(false);
  HTTPServer.AddUrl('root','889',false,'+',true);
  HTTPServer.RegisterCompress(CompressDeflate);
  HTTPServer.OnRequest := process;
  
  ORMServer := TNoteServer.Create(ExeVersion.ProgramFilePath+'data','root');
  fServer := TSQLHttpServer.Create(HTTP_PORT,[ORMSERVER]);

#5 Re: mORMot 1 » HttpApi webServer x IndyHttp Firemonkey - PDF Files » 2015-06-03 15:05:14

ab wrote:

On the Server side, you may use Ctxt.ReturnFile() directly.

I do not have this function on my ctxt...

 function TTestServer.Process(Ctxt: THttpServerRequest): cardinal; 

#6 mORMot 1 » HttpApi webServer x IndyHttp Firemonkey - PDF Files » 2015-06-03 14:54:12

evandroxavier
Replies: 9

Hi I'm new at mormot, and started to create a server based on sample: "09 - HttpApi web server"...

What I tring to do: Delphi xe7 http server with oracle database, for json e and file transfer. And and Firemonkey client for android.

So far i manage the server with oracle, a json client for android (using TRestclient on firemonkey) and it works very nice....

But i can't manage to download pdf files with TRestClient or IndyHttp (with webrowsers works).

When trying to download via mormot server i get: "Project WebBrowser.exe raised exception class EIdHTTPProtocolException With Message 'HTTP/1.1 0 0'."
But the same file with the same client in a ftp works...

My server:

  Ctxt.OutCustomHeaders := HEADER_CONTENT_TYPE + HTTP_RESP_STATICFILE  + #13#10 + HEADER_CONTENT_TYPE + GetMimeContentType(ctxt, 200, filename);
  Ctxt.OutContentType := HTTP_RESP_STATICFILE;
  Ctxt.OutContent := ExtractFilePath(filename) +  ExtractFileName(filename); 

idHttp configuration:

object IdHTTP1: TIdHTTP
  AllowCookies = True
  ProxyParams.BasicAuthentication = False
  ProxyParams.ProxyPort = 0
  Request.ContentLength = -1
  Request.ContentRangeEnd = -1
  Request.ContentRangeStart = -1
  Request.ContentRangeInstanceLength = -1
  Request.Accept =
    'STATICFILE, !STATICFILE, application/pdf,text/html,application/x' +
    'html+xml,application/xml;q=0.9,*/*;q=0.8'
  Request.BasicAuthentication = False
  Request.UserAgent =
    #39'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Fir' +
    'efox/12.0'
  Request.Ranges.Units = 'bytes'
  Request.Ranges = <>
  HTTPOptions = [hoKeepOrigProtocol, hoWaitForUnexpectedData]
  OnAuthorization = IdHTTP1Authorization
end

Idhttp call:

  MyFile := TFileStream.Create(sCaminhoPastaLocal + prNomeRel, fmCreate);
  try
    IdHTTP1.Request.CacheControl:= 'no-cache';
    IdHTTP1.OnWork:= NIL;
    IdHTTP1.OnWorkBegin:= NIL;
    IdHTTP1.OnWorkEnd:= NIL;
    IdHTTP1.Get(sCaminhoPdf,myFile);
  finally
    MyFile.Free;
  end;

Board footer

Powered by FluxBB