0

Does anyone know if it's possible to set the encoding attr in the prolog when using C# HttpClient's PostAsXmlAsync method.

When I look at the requests in Fiddler I can see the encoding in the content-type http header, but I need in the prolog like this:

<?xml version="1.0" encoding="UTF-8"?>
dbc
  • 104,963
  • 20
  • 228
  • 340
Ols1
  • 321
  • 3
  • 15

1 Answers1

0

The XML declaration (what you call "prolog") is optional. When it states version 1.0 and encoding UTF-8, it's even redundant, because those values are the defaults.

In an HTTP transmission the authoritative information about payload encoding is given in the Content-Type header, so it's practical not to send a possibly conflicting piece of information in the payload itself.

So to me it looks as if the HttpClientExtensions class does the right thing.

Tomalak
  • 332,285
  • 67
  • 532
  • 628