refact: codegen to override content-type header

This commit is contained in:
APPALA REDDI
2024-01-02 09:23:04 +05:30
parent 5eb91fbaf7
commit c765cb378b
3 changed files with 11 additions and 3 deletions

View File

@ -102,7 +102,9 @@ print(data.decode("utf-8"))
var headers = requestModel.headersMap;
if (headers.isNotEmpty || hasBody) {
hasHeaders = true;
if (hasBody) {
bool hasContentTypeHeader = headers.keys.any((k) => k.toLowerCase() == HttpHeaders.contentTypeHeader);
if (hasBody && !hasContentTypeHeader) {
headers[HttpHeaders.contentTypeHeader] =
kContentTypeMap[requestModel.requestBodyContentType] ?? "";
}