|
@@ -42,8 +42,11 @@ uses
|
|
System.NetConsts,
|
|
System.NetConsts,
|
|
System.JSON;
|
|
System.JSON;
|
|
{$ELSE}
|
|
{$ELSE}
|
|
- IdHTTP,
|
|
|
|
- IdException,
|
|
|
|
|
|
+ {$IFDEF DELPHIXE7_UP}
|
|
|
|
+ System.JSON,
|
|
|
|
+ {$ENDIF}
|
|
|
|
+ IdHTTP,
|
|
|
|
+ IdException,
|
|
{$IFDEF FPC}
|
|
{$IFDEF FPC}
|
|
fpjson;
|
|
fpjson;
|
|
{$ELSE}
|
|
{$ELSE}
|
|
@@ -150,7 +153,7 @@ begin
|
|
{$IFDEF DELPHIXE8_UP}
|
|
{$IFDEF DELPHIXE8_UP}
|
|
resp := fHTTPClient.Get(aURL,responsecontent,nil);
|
|
resp := fHTTPClient.Get(aURL,responsecontent,nil);
|
|
{$ELSE}
|
|
{$ELSE}
|
|
- {$IFDEF FPC}
|
|
|
|
|
|
+ {$If Defined(FPC) OR Not Defined(DELPHIXE8_UP)}
|
|
fHTTPClient.Get(aURL,responsecontent);
|
|
fHTTPClient.Get(aURL,responsecontent);
|
|
{$ELSE}
|
|
{$ELSE}
|
|
fHTTPClient.Get(aURL,responsecontent,nil);
|
|
fHTTPClient.Get(aURL,responsecontent,nil);
|
|
@@ -369,17 +372,24 @@ constructor THttpRequestResponse.Create(aResponse : TIdHTTPResponse; const aCont
|
|
begin
|
|
begin
|
|
fStatusCode := aResponse.ResponseCode;
|
|
fStatusCode := aResponse.ResponseCode;
|
|
fStatusText := aResponse.ResponseText;
|
|
fStatusText := aResponse.ResponseText;
|
|
|
|
+ {$If Defined(FPC) OR Defined(DELPHIXE8_UP)}
|
|
if (aContent.Contains('{')) and (aContent.Contains('}')) then fResponse := GetJSON(aContent) as TJsonObject;
|
|
if (aContent.Contains('{')) and (aContent.Contains('}')) then fResponse := GetJSON(aContent) as TJsonObject;
|
|
|
|
+ {$ELSE}
|
|
|
|
+ if (aContent.Contains('{')) and (aContent.Contains('}')) then fResponse:= TJsonObject.ParseJSONValue(aContent) as TJsonObject;
|
|
|
|
+ {$ENDIF}
|
|
//if response is not json, get as json result
|
|
//if response is not json, get as json result
|
|
if fResponse = nil then
|
|
if fResponse = nil then
|
|
begin
|
|
begin
|
|
fResponse := TJSONObject.Create;
|
|
fResponse := TJSONObject.Create;
|
|
|
|
+ {$IFDEF DELPHIXE7_UP}
|
|
|
|
+ fResponse.AddPair('Result',aContent);
|
|
|
|
+ {$ELSE}
|
|
fResponse.Add('Result',aContent);
|
|
fResponse.Add('Result',aContent);
|
|
|
|
+ {$ENDIF}
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
{$ENDIF}
|
|
{$ENDIF}
|
|
|
|
|
|
-
|
|
|
|
destructor THttpRequestResponse.Destroy;
|
|
destructor THttpRequestResponse.Destroy;
|
|
begin
|
|
begin
|
|
if Assigned(fResponse) then fResponse.Free;
|
|
if Assigned(fResponse) then fResponse.Free;
|