diff --git a/sources/MVCFramework.RESTClient.Indy.pas b/sources/MVCFramework.RESTClient.Indy.pas index 8c5bd5dc..c9202cdd 100644 --- a/sources/MVCFramework.RESTClient.Indy.pas +++ b/sources/MVCFramework.RESTClient.Indy.pas @@ -1415,9 +1415,9 @@ end; function TRESTClient.SendHTTPCommandWithBody(const ACommand: TMVCHTTPMethodType; const AAccept, AContentMediaType, AContentCharset, AResource, ABody: string): IRESTResponse; var - lBytes: TArray; lContentCharset: string; lEncoding: TEncoding; + lTmpStrStream: TStringStream; begin Result := TRESTResponse.Create; @@ -1449,8 +1449,12 @@ begin lEncoding := TEncoding.GetEncoding(lContentCharset); try - lBytes := TEncoding.Convert(TEncoding.Default, lEncoding, TEncoding.Default.GetBytes(ABody)); - RawBody.WriteData(lBytes, Length(lBytes)); + lTmpStrStream := TStringStream.Create(ABody, lEncoding, False); + try + RawBody.LoadFromStream(lTmpStrStream); + finally + lTmpStrStream.Free; + end finally lEncoding.Free; end; diff --git a/sources/MVCFramework.RESTClient.pas b/sources/MVCFramework.RESTClient.pas index 6c67070a..0d746f71 100644 --- a/sources/MVCFramework.RESTClient.pas +++ b/sources/MVCFramework.RESTClient.pas @@ -538,7 +538,6 @@ begin try fRawBody.Clear; - lBytes := TEncoding.Convert(TEncoding.Default, lEncoding, TEncoding.Default.GetBytes(aBody)); lBytes := lEncoding.GetBytes(aBody); fRawBody.WriteData(lBytes, Length(lBytes)); SetContentType(BuildContentType(lContentType, lContentCharset)); diff --git a/sources/MVCFramework.View.Renderers.Mustache.pas b/sources/MVCFramework.View.Renderers.Mustache.pas index d1bb653f..e6408ee3 100644 --- a/sources/MVCFramework.View.Renderers.Mustache.pas +++ b/sources/MVCFramework.View.Renderers.Mustache.pas @@ -66,7 +66,6 @@ procedure TMVCMustacheViewEngine.Execute(const ViewName: string; const OutputStr var I: Integer; lPartialName: string; - lData: TObject; lViewFileName: string; lViewTemplate: RawUTF8; lViewEngine: TSynMustache; diff --git a/unittests/general/Several/LiveServerTestU.pas b/unittests/general/Several/LiveServerTestU.pas index 9a0b38a6..9826e1da 100644 --- a/unittests/general/Several/LiveServerTestU.pas +++ b/unittests/general/Several/LiveServerTestU.pas @@ -2061,24 +2061,24 @@ begin Assert.areEqual(HTTP_STATUS.BadRequest, res.StatusCode, 'wrong TDateTime (2)'); // Correct without 'T' - res := RESTClient.doGET('/typed/tdatetime1/2016-10-12 12:12:12', []); - Assert.areEqual(HTTP_STATUS.OK, res.ResponseCode, 'wrong TDateTime (3)'); - Assert.areEqual('2016-10-12T12:12:12.000+02:00 modified from server', res.BodyAsString); + res := RESTClient.Get('/typed/tdatetime1/2016-10-12 12:12:12'); + Assert.areEqual(HTTP_STATUS.OK, res.StatusCode, 'wrong TDateTime (3)'); + Assert.areEqual('2016-10-12T12:12:12.000+02:00 modified from server', res.Content); // Correct in extended form with zero UTC offset - res := RESTClient.doGET('/typed/tdatetime1/2016-10-12T12:12:12Z', []); - Assert.areEqual(HTTP_STATUS.OK, res.ResponseCode); - Assert.areEqual('2016-10-12T14:12:12.000+02:00 modified from server', res.BodyAsString); + res := RESTClient.Get('/typed/tdatetime1/2016-10-12T12:12:12Z'); + Assert.areEqual(HTTP_STATUS.OK, res.StatusCode); + Assert.areEqual('2016-10-12T14:12:12.000+02:00 modified from server', res.Content); // Correct in extended form without timezone - res := RESTClient.doGET('/typed/tdatetime1/2016-10-12T12:12:12', []); - Assert.areEqual(HTTP_STATUS.OK, res.ResponseCode); - Assert.areEqual('2016-10-12T12:12:12.000+02:00 modified from server', res.BodyAsString); + res := RESTClient.Get('/typed/tdatetime1/2016-10-12T12:12:12'); + Assert.areEqual(HTTP_STATUS.OK, res.StatusCode); + Assert.areEqual('2016-10-12T12:12:12.000+02:00 modified from server', res.Content); // Correct in extended form with timezone - res := RESTClient.doGET('/typed/tdatetime1/2016-10-12T12:12:12.000Z', []); - Assert.areEqual(HTTP_STATUS.OK, res.ResponseCode); - Assert.areEqual('2016-10-12T14:12:12.000+02:00 modified from server', res.BodyAsString); + res := RESTClient.Get('/typed/tdatetime1/2016-10-12T12:12:12.000Z'); + Assert.areEqual(HTTP_STATUS.OK, res.StatusCode); + Assert.areEqual('2016-10-12T14:12:12.000+02:00 modified from server', res.Content); // TTime, wrong and correct res := RESTClient.Get('/typed/ttime1/121212'); @@ -2092,22 +2092,22 @@ end; procedure TServerTest.TestTypedDateTimeTypes_UTC; var - res: IRESTResponse; + res: IMVCRESTResponse; begin // If no UTC zone is defined, server must assume its local time zone - res := RESTClient.doGET('/typed/tdatetime1/2016-10-12 12:12:12', []); - Assert.areEqual(HTTP_STATUS.OK, res.ResponseCode, 'wrong TDateTime (3)'); - Assert.areEqual('2016-10-12T12:12:12.000+02:00 modified from server', res.BodyAsString); + res := RESTClient.Get('/typed/tdatetime1/2016-10-12 12:12:12'); + Assert.areEqual(HTTP_STATUS.OK, res.StatusCode, 'wrong TDateTime (3)'); + Assert.areEqual('2016-10-12T12:12:12.000+02:00 modified from server', res.Content); // With UTC zero offset, server must return time expressed as its local UTC - res := RESTClient.doGET('/typed/tdatetime1/2016-10-12T12:12:12Z', []); - Assert.areEqual(HTTP_STATUS.OK, res.ResponseCode); - Assert.areEqual('2016-10-12T14:12:12.000+02:00 modified from server', res.BodyAsString); + res := RESTClient.Get('/typed/tdatetime1/2016-10-12T12:12:12Z'); + Assert.areEqual(HTTP_STATUS.OK, res.StatusCode); + Assert.areEqual('2016-10-12T14:12:12.000+02:00 modified from server', res.Content); // Correct in extended form with timezone - res := RESTClient.doGET('/typed/tdatetime1/2016-10-12T12:12:12.000Z', []); - Assert.areEqual(HTTP_STATUS.OK, res.ResponseCode); - Assert.areEqual('2016-10-12T14:12:12.000+02:00 modified from server', res.BodyAsString); + res := RESTClient.Get('/typed/tdatetime1/2016-10-12T12:12:12.000Z'); + Assert.areEqual(HTTP_STATUS.OK, res.StatusCode); + Assert.areEqual('2016-10-12T14:12:12.000+02:00 modified from server', res.Content); end; procedure TBaseServerTest.DoLoginWith(UserName: string);