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

@ -55,8 +55,11 @@ class DartHttpCodeGen {
final strContent = CodeExpression(Code('r\'\'\'$body\'\'\''));
dataExp = declareVar('body', type: refer('String')).assign(strContent);
composeHeaders.putIfAbsent(HttpHeaders.contentTypeHeader,
final hasContentTypeHeader = composeHeaders.keys.any((k) => k.toLowerCase() == HttpHeaders.contentTypeHeader);
if (!hasContentTypeHeader) {
composeHeaders.putIfAbsent(HttpHeaders.contentTypeHeader,
() => kContentTypeMap[contentType] ?? '');
}
}
Expression? queryParamExp;