mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-15 07:45:54 +01:00
Compatibility adjustments in the new RESTClient
This commit is contained in:
parent
2871e131df
commit
8ba8213a6e
@ -1415,9 +1415,9 @@ end;
|
||||
function TRESTClient.SendHTTPCommandWithBody(const ACommand: TMVCHTTPMethodType;
|
||||
const AAccept, AContentMediaType, AContentCharset, AResource, ABody: string): IRESTResponse;
|
||||
var
|
||||
lBytes: TArray<Byte>;
|
||||
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;
|
||||
|
@ -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));
|
||||
|
@ -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;
|
||||
|
@ -2061,24 +2061,24 @@ begin
|
||||
Assert.areEqual<Integer>(HTTP_STATUS.BadRequest, res.StatusCode, 'wrong TDateTime (2)');
|
||||
|
||||
// Correct without 'T'
|
||||
res := RESTClient.doGET('/typed/tdatetime1/2016-10-12 12:12:12', []);
|
||||
Assert.areEqual<Integer>(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<Integer>(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<Integer>(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<Integer>(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<Integer>(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<Integer>(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<Integer>(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<Integer>(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<Integer>(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<Integer>(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<Integer>(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<Integer>(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<Integer>(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<Integer>(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);
|
||||
|
Loading…
Reference in New Issue
Block a user