#1 2023-07-13 11:25:04

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 430

Mormot2 http client does not return content if stream is used

ab wrote:

Nope. The result is 301.

So you need to set

  h.RedirectMax := 10;

before the request to enable redirection.

Then we got a 200 response, but with no chunked encoding flag, nor content-length.
https://www.rfc-editor.org/rfc/rfc7230#section-3.3.3 states it should read all data until the server closes the connection.
This is a pretty inefficient way of handling the content size, and void the whole HTTP/1.1 interrest - this server is awfully coded for sure, and react as a HTTP/1.0 server.

Previous version was only reading till the connection close with HTTP/1.0 - now I have enabled it for HTTP/1.1 also.
See https://github.com/synopse/mORMot2/commit/ddb7c8d4

@ab you probably remember the above case.
it was impossible to get correct encoding with an http call when using:
var s:RawByteString;  op:THttpClientSocket;
op.Request(url,'GET',_KeepAlive,headers,'','',true,nil{,ContentStream});
s:=op.content;
so I decided to use the call with a stream:
THttpClientSocket.Request(url,'GET',_KeepAlive,headers,'','',true,nil,ContentStream);

I noticed that the above fix does not work with stream parameter and the stream returns empty.
Is it possible also to declare the default encoding for received content if an oracle web server like the one I am using does not return an encoding flag?
Thank you in advance

Last edited by dcoun (2023-07-13 12:07:43)

Offline

#2 2023-07-13 12:03:10

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

Re: Mormot2 http client does not return content if stream is used

Which encoding are you talking about?

Offline

#3 2023-07-13 12:10:36

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 430

Re: Mormot2 http client does not return content if stream is used

forget it.....
It was my fault.
No need for something like that

Last edited by dcoun (2023-07-13 12:13:49)

Offline

#4 2023-07-13 13:26:44

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 430

Re: Mormot2 http client does not return content if stream is used

I can probably use a TRawBytesStream to get a stream and not bothering you.... I will try it

Offline

#5 2023-07-13 17:05:29

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 430

Re: Mormot2 http client does not return content if stream is used

it does not work. I think the problem is in mormot.net.client, line 1616

         if ctxt.OutStream <> nil then
          begin
            if (Http.ContentLength > 0) and
               (ctxt.Status in [HTTP_SUCCESS, HTTP_PARTIALCONTENT]) then
            begin
              if ctxt.OutStream.InheritsFrom(TStreamRedirect) then
                TStreamRedirect(ctxt.OutStream).ExpectedSize :=
                  fRangeStart + Http.ContentLength;
              GetBody(ctxt.OutStream)
            end;
          end
          else
            GetBody(nil);

if stream is defined and header content-length does not exist, it will never call GetBody

Offline

#6 2023-07-13 17:45:56

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 430

Re: Mormot2 http client does not return content if stream is used

I am experiencing also corrupted result content from mormot2's http client, if non-latin characters are included in the returned text.
Probably it happens with the http calls that do not return content-length, but I did not have such problems with WINET and if using directly the curl library

Offline

#7 2023-07-13 20:49:05

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

Re: Mormot2 http client does not return content if stream is used

Which compiler?
Which OS?

Offline

#8 2023-07-13 20:49:51

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 430

Re: Mormot2 http client does not return content if stream is used

Delphi 11.3
Win11

Offline

#9 2023-07-14 05:50:21

dcoun
Member
From: Crete, Greece
Registered: 2020-02-18
Posts: 430

Re: Mormot2 http client does not return content if stream is used

One more hint using WININET (again now.....) in THttpRequest.Request:
If you include Content-type header in InHeader parameter it is included in the request. If InDataType is set, content-type there is not recognized by my Oracle solution web server I have to deal with

Offline

#10 2023-07-14 09:32:13

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

Re: Mormot2 http client does not return content if stream is used

THttpClientSocket does not support chunked answers, only servers returning a proper content-length header.

Offline

Board footer

Powered by FluxBB