Skip to content

Commit

Permalink
Add Encoding and Media Type to StringContent for form data (#4487)
Browse files Browse the repository at this point in the history
* Add Encoding and Media Type to StringContent for form data in Client.Class.liquid

* Fully qualify Encoding
  • Loading branch information
ArieGato authored Sep 27, 2023
1 parent b881479 commit f9d7515
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public async Task when_content_is_formdata_with_property_object_then_content_sho
// Assert
Assert.Contains("var content_ = new System.Net.Http.MultipartFormDataContent(boundary_);", code);
Assert.Contains("var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(propertyDto, _settings.Value)", code);
Assert.Contains("content_.Add(new System.Net.Http.StringContent(json_), \"propertyDto\");", code);
Assert.Contains("content_.Add(new System.Net.Http.StringContent(json_, System.Text.Encoding.UTF8, \"application/json\"), \"propertyDto\");", code);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@
}
{% elsif parameter.IsObject -%}
var json_ = {% if UseSystemTextJson %}System.Text.Json.JsonSerializer.Serialize{% else %}Newtonsoft.Json.JsonConvert.SerializeObject{% endif %}({{ parameter.VariableName }}, {% if UseRequestAndResponseSerializationSettings %}_requestSettings{% else %}_settings{% endif %}.Value);
content_.Add(new System.Net.Http.StringContent(json_), "{{ parameter.Name }}");
content_.Add(new System.Net.Http.StringContent(json_, System.Text.Encoding.UTF8, "application/json"), "{{ parameter.Name }}");
{% else -%}
content_.Add(new System.Net.Http.StringContent(ConvertToString({{ parameter.VariableName }}, System.Globalization.CultureInfo.InvariantCulture)), "{{ parameter.Name }}");
{% endif -%}
Expand Down

0 comments on commit f9d7515

Please sign in to comment.