Browse Source

[httpClient] Check if json response content

Exilon 1 year ago
parent
commit
8d0ef7e4ab
1 changed files with 3 additions and 1 deletions
  1. 3 1
      Quick.HttpClient.pas

+ 3 - 1
Quick.HttpClient.pas

@@ -380,7 +380,9 @@ constructor THttpRequestResponse.Create(aResponse: IHTTPResponse; const aContent
 begin
 begin
   fStatusCode := aResponse.StatusCode;
   fStatusCode := aResponse.StatusCode;
   fStatusText := aResponse.StatusText;
   fStatusText := aResponse.StatusText;
-  if aContent <> '' then fResponse := TJSONObject.ParseJSONValue(aContent) as TJSONObject;
+  if ((aContent <> '') and
+      (aContent.StartsWith('{') or (aContent.StartsWith('[')))
+      ) then fResponse := TJSONObject.ParseJSONValue(aContent) as TJSONObject;
   //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