delphimvcframework
delphimvcframework copied to clipboard
DXE7 - ISAPI - Body is empty
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}
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?
IMHO ? for the content-encoding, ctx.Request.ContentCharset return empty value in standalone and isapi mode.
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}
Do you still have the problem with the latest version?
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} `
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}