Skip to content

Commit

Permalink
Merge pull request #109 from DMTF/Fix108
Browse files Browse the repository at this point in the history
Fix108: Return error when unable to parse
  • Loading branch information
mraineri authored Jun 6, 2019
2 parents c5b25f5 + 6c0a646 commit 45a6253
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/redfishService.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@ REDFISH_EXPORT void serviceDecRef(redfishService* service);
*/
REDFISH_EXPORT void serviceDecRefAndWait(redfishService* service);

/** There was an error parsing the returned payload **/
#define REDFISH_ERROR_PARSING 0xFFFE

/** Accept any type of response **/
#define REDFISH_ACCEPT_ALL 0xFFFFFFFF
/** Accept a JSON response **/
Expand Down
9 changes: 9 additions & 0 deletions src/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,15 @@ static void rawCallbackWrapper(asyncHttpRequest* request, asyncHttpResponse* res
success = true;
}
payload = getPayloadFromAsyncResponse(response, myContext->service);
if(payload == NULL)
{
success = false;
if(response->httpResponseCode == 200)
{
//Override with an error code indicating parsing issues.
response->httpResponseCode = REDFISH_ERROR_PARSING;
}
}
myContext->callback(success, (unsigned short)response->httpResponseCode, payload, myContext->originalContext);
}
freeAsyncRequest(request);
Expand Down

0 comments on commit 45a6253

Please sign in to comment.