#1 2025-02-11 07:40:42

Alek
Member
From: Russia
Registered: 2014-07-04
Posts: 52

Long wait for reading empty content

I am executing the PUT method in OpenAPIClient

The update command itself is executed quickly. The content on the server is updated. The server returns the status 'HTTP/1.1 204 No Content'.

The header does not contain the "Content-Length" field, and therefore we get to the code section (mormot.net.http.pas) in "GetBody" procedure:

  else if Http.ContentLength < 0 then // -1 means no Content-Length header
  begin
    // no Content-Length neither chunk -> read until the connection is closed
    // also for HTTP/1.1: https://www.rfc-editor.org/rfc/rfc7230#section-3.3.3
    if Assigned(OnLog) then
      OnLog(sllTrace, 'GetBody deprecated loop', [], self);
    // body = either Content-Length or Transfer-Encoding (HTTP/1.1 RFC2616 4.3)
    if SockIn <> nil then // client loop for compatibility with oldest servers
      while not eof(SockIn^) do ////////////////////////////////////////////////// THERE IS A LONG TIMEOUT HERE, depending on the settings 
      begin
        readln(SockIn^, line);
        AppendLine(RawUtf8(Http.Content), [line]);
      end;

But the timeout is the same for everyone (connecttimeout, sendtimeout, recvtimeout)

How to solve this situation?

Offline

#2 2025-02-11 08:09:28

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,929
Website

Re: Long wait for reading empty content

My concern is that I have seen some python servers returning HTTP 204 which in fact returned a body...

b'HTTP/1.1 204 NO CONTENT\r\n'
b'Content-Type: text/html; charset=utf-8\r\n'
b'Date: Mon, 06 Jan 2025 08:16:31 GMT\r\n'
b'Transfer-Encoding: chunked\r\n'
b'Connection: keep-alive\r\n'
b'\r\n'
b'0\r\n\r\n'

I will look into it.

Offline

#3 2025-02-11 09:25:45

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,929
Website

Re: Long wait for reading empty content

I think I nailed it.

Please try with
https://github.com/synopse/mORMot2/commit/869384018

Offline

#4 2025-02-11 10:42:07

Alek
Member
From: Russia
Registered: 2014-07-04
Posts: 52

Re: Long wait for reading empty content

Everything is super!

Minor malfunction unrelated to the topic. An error occurred during compilation.

"mormot.core.variants.pas(7970): E2004 Identifier redeclared: 'p'". Conflict between a variable property P[const aNameOrPath: RawUtf8]

Offline

#5 2025-02-11 19:08:39

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,929
Website

Re: Long wait for reading empty content

The compilation error should be fixed by
https://github.com/synopse/mORMot2/commit/adab4978d

Thanks for the report.

Offline

Board footer

Powered by FluxBB