Explorar el Código

[httpClient] Check if json response content

Exilon hace 1 año
padre
commit
8d0ef7e4ab
Se han modificado 1 ficheros con 3 adiciones y 1 borrados
  1. 3 1
      Quick.HttpClient.pas

+ 3 - 1
Quick.HttpClient.pas

@@ -380,7 +380,9 @@ constructor THttpRequestResponse.Create(aResponse: IHTTPResponse; const aContent
 begin
   fStatusCode := aResponse.StatusCode;
   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 fResponse = nil then
   begin