mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-30 00:54:06 +02:00
RedfishPkg/RedfishHttpDxe: check response content type.
Check HTTP response content type to see if it is application/json type or not. In Redfish, we expect to see response data in JSON format. If it is not, show warning message to developer. Signed-off-by: Nickle Wang <nicklew@nvidia.com>
This commit is contained in:
parent
14e6c48103
commit
31f0225005
@ -493,6 +493,7 @@ ParseResponseMessage (
|
|||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EDKII_JSON_VALUE JsonData;
|
EDKII_JSON_VALUE JsonData;
|
||||||
EFI_HTTP_HEADER *ContentEncodedHeader;
|
EFI_HTTP_HEADER *ContentEncodedHeader;
|
||||||
|
EFI_HTTP_HEADER *ContentTypeHeader;
|
||||||
VOID *DecodedBody;
|
VOID *DecodedBody;
|
||||||
UINTN DecodedLength;
|
UINTN DecodedLength;
|
||||||
|
|
||||||
@ -545,6 +546,17 @@ ParseResponseMessage (
|
|||||||
//
|
//
|
||||||
if ((ResponseMsg->BodyLength != 0) && (ResponseMsg->Body != NULL)) {
|
if ((ResponseMsg->BodyLength != 0) && (ResponseMsg->Body != NULL)) {
|
||||||
DEBUG ((REDFISH_HTTP_CACHE_DEBUG_REQUEST, "%a: body length: %d\n", __func__, ResponseMsg->BodyLength));
|
DEBUG ((REDFISH_HTTP_CACHE_DEBUG_REQUEST, "%a: body length: %d\n", __func__, ResponseMsg->BodyLength));
|
||||||
|
|
||||||
|
//
|
||||||
|
// We expect to see JSON body
|
||||||
|
//
|
||||||
|
ContentTypeHeader = HttpFindHeader (RedfishResponse->HeaderCount, RedfishResponse->Headers, HTTP_HEADER_CONTENT_TYPE);
|
||||||
|
if (ContentTypeHeader != NULL) {
|
||||||
|
if (AsciiStrCmp (ContentTypeHeader->FieldValue, HTTP_CONTENT_TYPE_APP_JSON) != 0) {
|
||||||
|
DEBUG ((DEBUG_WARN, "%a: body is not in %a format\n", __func__, HTTP_CONTENT_TYPE_APP_JSON));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check if data is encoded.
|
// Check if data is encoded.
|
||||||
//
|
//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user