Skip to content

Commit

Permalink
[httpClient] Check if json response content
Browse files Browse the repository at this point in the history
  • Loading branch information
exilon committed Oct 10, 2023
1 parent 915da47 commit 8d0ef7e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Quick.HttpClient.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8d0ef7e

Please sign in to comment.