diff --git a/lib/codegen/java/async_http_client.dart b/lib/codegen/java/async_http_client.dart index ec804cc1..86fdf553 100644 --- a/lib/codegen/java/async_http_client.dart +++ b/lib/codegen/java/async_http_client.dart @@ -148,9 +148,9 @@ public class Main { // especially sets up Content-Type header if the request has a body // and Content-Type is not explicitely set by the developer if (hasBody && - !requestModel.enabledHeadersMap.containsKey('Content-Type')) { + !requestModel.enabledHeadersMap.containsKey(kHeaderContentType)) { result += templateRequestHeader - .render({"name": 'Content-Type', "value": contentType}); + .render({"name": kHeaderContentType, "value": contentType}); } // setting up rest of the request headers diff --git a/lib/codegen/js/axios.dart b/lib/codegen/js/axios.dart index 301ecf46..00d4d1a9 100644 --- a/lib/codegen/js/axios.dart +++ b/lib/codegen/js/axios.dart @@ -90,7 +90,7 @@ axios(config) m[i["name"]] = i["value"]; } if (requestModel.hasFormData) { - m[kHeaderContentType] = 'multipart/form-data'; + m[kHeaderContentType] = ContentType.formdata.header; } result += templateHeader .render({"headers": padMultilineString(kEncoder.convert(m), 2)}); diff --git a/lib/codegen/js/fetch.dart b/lib/codegen/js/fetch.dart index 9b5f8161..cd6732a6 100644 --- a/lib/codegen/js/fetch.dart +++ b/lib/codegen/js/fetch.dart @@ -99,7 +99,7 @@ fetch(url, options) var m = {}; for (var i in headers) { // fetch can automatically add the Content-Type header when FormData is passed as body - if (i["name"] == "Content-Type" && requestModel.hasFormData) { + if (i["name"] == kHeaderContentType && requestModel.hasFormData) { continue; } m[i["name"]] = i["value"]; diff --git a/lib/codegen/php/curl.dart b/lib/codegen/php/curl.dart index 4d0ac5e9..86897383 100644 --- a/lib/codegen/php/curl.dart +++ b/lib/codegen/php/curl.dart @@ -238,8 +238,8 @@ function build_data_files(\$boundary, \$fields, \$files) if (requestModel.hasFormData) { // we will override any existing boundary and use our own boundary - m['Content-Type'] = - "multipart/form-data; boundary=-------------$uuid"; + m[kHeaderContentType] = + "${ContentType.formdata.header}; boundary=-------------$uuid"; var boundaryUniqueIdTemplate = jj.Template(kBoundaryUniqueIdTemplate); diff --git a/lib/codegen/php/guzzle.dart b/lib/codegen/php/guzzle.dart index c0e5562e..c7d498da 100644 --- a/lib/codegen/php/guzzle.dart +++ b/lib/codegen/php/guzzle.dart @@ -107,7 +107,7 @@ echo \$res->getBody(); headersString += "\t\t\t\t'$key' => '$value', \n"; }); if (requestModel.hasFormData) { - m['Content-Type'] = 'multipart/form-data'; + m[kHeaderContentType] = ContentType.formdata.header; } headersString = headersString.substring( 0, headersString.length - 2); // Removing trailing comma and space diff --git a/lib/codegen/ruby/faraday.dart b/lib/codegen/ruby/faraday.dart index 852f0dfb..5023e183 100644 --- a/lib/codegen/ruby/faraday.dart +++ b/lib/codegen/ruby/faraday.dart @@ -147,7 +147,7 @@ puts "Response Body: #{response.body}" var headers = requestModel.enabledHeadersMap; if (requestModel.hasBody && !requestModel.hasContentTypeHeader) { if (requestModel.hasJsonData || requestModel.hasTextData) { - headers["Content-Type"] = requestModel.requestBodyContentType.header; + headers[kHeaderContentType] = requestModel.requestBodyContentType.header; } }