Recent

Author Topic: TFPHTTPServer in a thread  (Read 7136 times)

Thaddy

  • Hero Member
  • *****
  • Posts: 9301
Re: TFPHTTPServer in a thread
« Reply #30 on: July 30, 2019, 07:38:44 pm »
No. I got a compile error in trunk, removed the unit and tested basic functionality. The simpleserver works and serves what you ask. I did not test anything else.
« Last Edit: July 30, 2019, 07:40:53 pm by Thaddy »
also related to equus asinus.

julkas

  • Sr. Member
  • ****
  • Posts: 438
  • KISS principle / Lazarus 2.0.0 / FPC 3.0.4
Re: TFPHTTPServer in a thread
« Reply #31 on: July 30, 2019, 08:23:31 pm »
Because wmecho is not needed and makes it fail to compile because it can not be found.
After that, try to start the server and ask for a page (must exist) like index.html.
Works.
I don't know if wmecho is needed. I have found this unit. After successfully compilation and run open chrom and make request, app fails with exception.
Continue tomorrow. I think code is broken or has bug.
This example must working out of the box.
procedure mulu64(a, b: QWORD; out clo, chi: QWORD); assembler;
asm
  mov rax, a
  mov rdx, b
  mul rdx
  mov [clo], rax
  mov [chi], rdx
end;

rvk

  • Hero Member
  • *****
  • Posts: 3842
Re: TFPHTTPServer in a thread
« Reply #32 on: July 30, 2019, 09:19:05 pm »
No. I got a compile error in trunk, removed the unit and tested basic functionality. The simpleserver works and serves what you ask. I did not test anything else.
Yes, neat. It works with one index.htm  :(

But when serving a complete website (with css), even the simpleserver example craps out.

Try it with the website provided (and attached), which contains .css files.

For me, there is really something fishy going on in function TFPHTTPConnection.ReadString() and shows a real potential problem in core FPC. Like we had a few weeks ago with the wrong reference counting in the pure calculator app (which was also confirmed a real problem).

Can anybody test simplehttpserver.lpi (in fpc\packages\fcl-web\examples\httpserver) with attached website and confirm the problem?

euMesmo

  • New Member
  • *
  • Posts: 12
Re: TFPHTTPServer in a thread
« Reply #33 on: July 31, 2019, 01:16:47 am »
Hi rvk.
Yes, I tested the simplehttpserver on W7 with firefox and chrome and it works after commenting the line "if FCount>=5 then Active:=false" as it prevented the complete loading of all files.

As anecdote, the avast antivirus considers simplehttpserver a "threat".

However there is something "strange", when closing the browser the exception "EHTTPServer" appears with the message: "Missing HTTP protocol version in request".  If we click on the continue button of the exception message the server is still working.
I have placed in the code the line "Arequest.ProtocolVersion:='HTTP/1.1';" but it doesn't seem to solve it.

I have tried a bigger web (several html+css+js), the only problem is that when, from the web, a new html file is requested, the exception reappears. Clicking on the continue button of the exception message continues to work and loads the html, even html inserted into iframes.

julkas

  • Sr. Member
  • ****
  • Posts: 438
  • KISS principle / Lazarus 2.0.0 / FPC 3.0.4
Re: TFPHTTPServer in a thread
« Reply #34 on: July 31, 2019, 08:11:53 am »
Hi rvk.
Yes, I tested the simplehttpserver on W7 with firefox and chrome and it works after commenting the line "if FCount>=5 then Active:=false" as it prevented the complete loading of all files.

As anecdote, the avast antivirus considers simplehttpserver a "threat".

However there is something "strange", when closing the browser the exception "EHTTPServer" appears with the message: "Missing HTTP protocol version in request".  If we click on the continue button of the exception message the server is still working.
I have placed in the code the line "Arequest.ProtocolVersion:='HTTP/1.1';" but it doesn't seem to solve it.

I have tried a bigger web (several html+css+js), the only problem is that when, from the web, a new html file is requested, the exception reappears. Clicking on the continue button of the exception message continues to work and loads the html, even html inserted into iframes.
Install Apache or nginx ... and you have working solution.
I have same exception.
« Last Edit: July 31, 2019, 08:14:21 am by julkas »
procedure mulu64(a, b: QWORD; out clo, chi: QWORD); assembler;
asm
  mov rax, a
  mov rdx, b
  mul rdx
  mov [clo], rax
  mov [chi], rdx
end;

Leledumbo

  • Hero Member
  • *****
  • Posts: 8114
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: TFPHTTPServer in a thread
« Reply #35 on: August 02, 2019, 08:13:28 am »
However there is something "strange", when closing the browser the exception "EHTTPServer" appears with the message: "Missing HTTP protocol version in request".  If we click on the continue button of the exception message the server is still working.
Intentional, the exception actually happens internally and handled gracefully without ever leaking out of the webserver unit code. But GDB will still catch it unless you whitelist it.

euMesmo

  • New Member
  • *
  • Posts: 12
Re: TFPHTTPServer in a thread
« Reply #36 on: August 04, 2019, 01:24:41 am »
Install Apache or nginx ... and you have working solution.
I have same exception.

Yeah, it's the solution I'm using for my application. But if I could insert an http server into my application, users would no longer have to "add" anything. If that server also supported php it would be perfect.

euMesmo

  • New Member
  • *
  • Posts: 12
Re: TFPHTTPServer in a thread
« Reply #37 on: August 04, 2019, 01:27:31 am »
Intentional, the exception actually happens internally and handled gracefully without ever leaking out of the webserver unit code. But GDB will still catch it unless you whitelist it.
Indeed, once compiled there is no problem, maybe a little slow but everything seems to work fine.

julkas

  • Sr. Member
  • ****
  • Posts: 438
  • KISS principle / Lazarus 2.0.0 / FPC 3.0.4
Re: TFPHTTPServer in a thread
« Reply #38 on: August 04, 2019, 12:27:10 pm »
Install Apache or nginx ... and you have working solution.
I have same exception.

Yeah, it's the solution I'm using for my application. But if I could insert an http server into my application, users would no longer have to "add" anything. If that server also supported php it would be perfect.
Check - https://wiki.freepascal.org/Brook_for_Free_Pascal
procedure mulu64(a, b: QWORD; out clo, chi: QWORD); assembler;
asm
  mov rax, a
  mov rdx, b
  mul rdx
  mov [clo], rax
  mov [chi], rdx
end;

euMesmo

  • New Member
  • *
  • Posts: 12
Re: TFPHTTPServer in a thread
« Reply #39 on: August 06, 2019, 01:44:37 pm »
Hi julkas. THanks for the feedback. I'm gonna try it.

julkas

  • Sr. Member
  • ****
  • Posts: 438
  • KISS principle / Lazarus 2.0.0 / FPC 3.0.4
Re: TFPHTTPServer in a thread
« Reply #40 on: August 06, 2019, 02:23:36 pm »
procedure mulu64(a, b: QWORD; out clo, chi: QWORD); assembler;
asm
  mov rax, a
  mov rdx, b
  mul rdx
  mov [clo], rax
  mov [chi], rdx
end;