openbmc / bmcweb

A do everything Redfish, KVM, GUI, and DBus webserver for OpenBMC
Apache License 2.0
148 stars 130 forks source link

Json content-type "application/json;charset=utf-8" without space separator is not allowed #271

Closed AleksandrParamonov closed 4 months ago

AleksandrParamonov commented 4 months ago

Is this the right place to submit this?

Bug Description

Redfish requests without space separator between application/json; and charset=utf-8 in content-type in header are considered incorrect.. Code inside parsing.hpp (https://github.com/openbmc/bmcweb/blob/master/http/parsing.hpp#L20) only accepts content-type with space separator: inline bool isJsonContentType(std::string_view contentType) { return bmcweb::asciiIEquals(contentType, "application/json") || bmcweb::asciiIEquals(contentType, "application/json; charset=utf-8"); } Shoudln't "application/json;charset=utf-8" be valid?

Version

b2896149c39967dd9d1ee79357bdc53537cfabd7

Additional Information

I've met warning message "Failed to parse content type on request" during communication with AMI BIOS. AMI BIOS forms without space separator so some requests are considered invalid.

edtanous commented 4 months ago

It looks like most http examples have the space, but the redfish spec does not. Seems like we could just accept either. Please put up a patch in Gerrit for that behavior.

edtanous commented 4 months ago

Can you please test if https://gerrit.openbmc.org/c/openbmc/bmcweb/+/70112 solves your bug?

AleksandrParamonov commented 4 months ago

The issue is fixed and BIOS requests are no longer rejected.

edtanous commented 4 months ago

Reopening, the above review isn't merged yet.