delphimvcframework icon indicating copy to clipboard operation
delphimvcframework copied to clipboard

DXE7 - ISAPI - Body is empty

Open delagoutte-wanao opened this issue 6 years ago • 6 comments
trafficstars

in function function TMVCWebRequest.Body: string; i had an empty body that is returned by function i used this for fix it but maybe it is not the better resolution : {$IFDEF BERLINORBETTER}

  FWebRequest.ReadTotalContent; // Otherwise ISAPI Raises "Empty BODY"
  FBody := lEncoding.GetString(FWebRequest.RawContent);

  {$ELSE}
  SetLength(lBuffer, FWebRequest.ContentLength);
  FWebRequest.ReadClient(lBuffer[0], FWebRequest.ContentLength);
  lBuffer:=lEncoding.ANSI.GetBytes(FWebRequest.RawContent);<--------i add this
  FBody := lEncoding.GetString(lBuffer);

  {$ENDIF}

delagoutte-wanao avatar Apr 17 '19 13:04 delagoutte-wanao

This change will include unicode bugs IMHO (I don't have XE7 to test it) and should not be needed. Did you check the content-encoding of your request?

danieleteti avatar Apr 20 '19 09:04 danieleteti

IMHO ? for the content-encoding, ctx.Request.ContentCharset return empty value in standalone and isapi mode.

delagoutte-wanao avatar Apr 29 '19 12:04 delagoutte-wanao

in delphi xe7, in unit web.http.pas, TWebRequest , rawcontent and many property are ansistring for {$ELSE !NEXTGEN}

maybe a better resolution could be : {$IFDEF BERLINORBETTER}

FWebRequest.ReadTotalContent; // Otherwise ISAPI Raises "Empty BODY" FBody := lEncoding.GetString(FWebRequest.RawContent);

{$ELSE} SetLength(lBuffer, FWebRequest.ContentLength); FWebRequest.ReadClient(lBuffer[0], FWebRequest.ContentLength);

{$IFDEF VER280} lBuffer:=lEncoding.ANSI.GetBytes(FWebRequest.RawContent);<--------i add this {$ENDIF VER280}

FBody := lEncoding.GetString(lBuffer);

{$ENDIF}

delagoutte-wanao avatar Apr 29 '19 14:04 delagoutte-wanao

Do you still have the problem with the latest version?

danieleteti avatar Oct 09 '19 21:10 danieleteti

Hi, I have the same problem building apache module with delphi 10 seattle. I seek into source code and I found that FWebRequest.ReadClient do nothing when compiling apache module. I suggest this fix: ` {$IFDEF BERLINORBETTER} FWebRequest.ReadTotalContent; // Otherwise ISAPI Raises "Empty BODY" FBody := lEncoding.GetString(FWebRequest.RawContent);

{$ELSE} lBuffer := lEncoding.GetBytes(FWebRequest.RawContent); FBody := lEncoding.GetString(lBuffer);

{$ENDIF} `

Dr-Zer0 avatar Oct 11 '19 09:10 Dr-Zer0

lBuffer := lEncoding.GetBytes(FWebRequest.RawContent); seems useless (in 10.3 Rio doesn't even compile)

Can you test the following?

{$IFDEF BERLINORBETTER}
FWebRequest.ReadTotalContent; // Otherwise ISAPI Raises "Empty BODY"
FBody := lEncoding.GetString(FWebRequest.RawContent);

{$ELSE}
FBody := lEncoding.GetString(FWebRequest.RawContent);
{$ENDIF}

danieleteti avatar Nov 04 '19 10:11 danieleteti