#1 2026-02-03 06:44:00

slan2026
Member
Registered: 2026-02-03
Posts: 5

TRestHttpServer mormot.core.text.pas IsInvalidHttpHeader

When I run the code in mormot2\ex\mvc-blog on my computer, an error occurs: 00000000156a25fa  # EXCOS EAccessViolation (c0000005 EXCEPTION_ACCESS_VIOLATION) [blog 2] at 5abb8e mormot.core.text.pas IsInvalidHttpHeader (10879)   {16 0.89 0.57 10GB/31.8GB 4a651701}. However, it runs normally on another computer. How can I resolve this error on my computer, or is there a part of my computer that might be malfunctioning?

Offline

#2 2026-02-03 17:55:31

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,406
Website

Re: TRestHttpServer mormot.core.text.pas IsInvalidHttpHeader

Which compiler?
Which Operating System?

Can you give more context?

Offline

#3 2026-02-03 23:45:04

slan2026
Member
Registered: 2026-02-03
Posts: 5

Re: TRestHttpServer mormot.core.text.pas IsInvalidHttpHeader

ab wrote:

Which compiler?
Which Operating System?

Can you give more context?

Delphi12.1
win10。
Additionally, I compiled it once using Lazarus, and everything went smoothly.

When I debug, the returned value is on line 8016 of the  mormot.rest.server.pas unit
//  lazarus: Call.OutHead = 'Content-Type: text/html;charset=utf-8' 
//delphi12.1:OutHead 'Content-Type: text/html;charset=utf-8'#$D#$A'ETag: "E039C149"'

Last edited by slan2026 (2026-02-04 00:38:43)

Offline

#4 2026-02-04 09:22:24

rvk
Member
Registered: 2022-04-14
Posts: 156

Re: TRestHttpServer mormot.core.text.pas IsInvalidHttpHeader

I wonder why that IsInvalidHttpHeader changed so much?

It used to be a simple lineair search for invalid line-breaks.
If you look at it now... it became so much more complex (and prone to errors and bugs, as is now the case).

This is the old version:
https://github.com/synopse/mORMot2/blob … .pas#L5473

This is the newer expanded version:
https://github.com/synopse/mORMot2/blob … pas#L10862

It's also strange that searching for IsInvalidHttpHeader on github doesn't give you the location of this function, while it is in the repository.

Offline

#5 2026-02-04 19:18:23

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,406
Website

Re: TRestHttpServer mormot.core.text.pas IsInvalidHttpHeader

The old version was not correct anyway, and slower.

It is very likely that the problem comes from outside this function itself, and that Call.OutHead is incorrect.
I have tried to reproduce the issue with no success:
https://github.com/synopse/mORMot2/commit/bc3f00a03

Do you set the output headers by hand in your server?
Do you use cookies at that time?
Can you have the content of Call.OutHead when it is actually triggered?

Win32 or Win64?

Offline

#6 2026-02-05 09:42:22

rvk
Member
Registered: 2022-04-14
Posts: 156

Re: TRestHttpServer mormot.core.text.pas IsInvalidHttpHeader

I can't even compile the current trunk/master on Delphi 10.2.

First I get an error regarding UnCamelCase.
[dcc32 Error] mormot.core.rtti.pas(6253): E2250 There is no overloaded version of 'UnCamelCase' that can be called with these arguments

After fixing that (with a related fix) I get an error in this line:
[dcc32 Error] mormot.ui.pdf.pas(12254): E2029 'THEN' expected but ')' found

        if w < Trunc(R.rclBounds.Right - R.rclBounds.Left) / Canvas.fFactorX) then

This latest source from that file is from januari 27th so...
https://github.com/synopse/mORMot2/blob … pas#L12254

It's amazing how you can compile the latest mORMot2 without any problems wink wink

About the IsInvalidHttpHeader from this topic... I also couldn't reproduce this under Delphi 10.2 win64.
So hopefully @slan2026 can provide more information about the problem and debug exactly on what line the error occurs.

Offline

#7 2026-02-06 01:32:23

slan2026
Member
Registered: 2026-02-03
Posts: 5

Re: TRestHttpServer mormot.core.text.pas IsInvalidHttpHeader

ab wrote:

Win32 or Win64?

i am not  set the output headers by hand in  server and not use cookies . debug in win32.
I downloaded the source code from GitHub and run the example.
When debugging with Delphi 12.1, input  http://localhost:8092 in Edge .
The breakpoint is at line 10879 of the mormot.cre.text.as unit.
After pressing F8, pause at line 8022 of the mormot.rest.server. pas unit
and continue stepping to locate line 8652 of the mormot.net.server. pas unit.
As I mentioned above, everything works fine when I debug with Lazaus。

Offline

#8 2026-02-06 01:47:04

slan2026
Member
Registered: 2026-02-03
Posts: 5

Re: TRestHttpServer mormot.core.text.pas IsInvalidHttpHeader

ab wrote:

Win32 or Win64?

I just found the reason. I used madexcept to detect memory leaks during debugging, and after removing it, everything went smoothly.
Thank you very much.

Offline

#9 2026-02-06 09:03:11

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,406
Website

Re: TRestHttpServer mormot.core.text.pas IsInvalidHttpHeader

The PDF unit compilation should be fixed now
https://github.com/synopse/mORMot2/commit/a7b04d7a3

Offline

Board footer

Powered by FluxBB