Bewerken

Delen via


SocketsHttpHandler.ResponseHeaderEncodingSelector Property

Definition

Gets or sets a callback that selects the Encoding to decode response header values.

public:
 property System::Net::Http::HeaderEncodingSelector<System::Net::Http::HttpRequestMessage ^> ^ ResponseHeaderEncodingSelector { System::Net::Http::HeaderEncodingSelector<System::Net::Http::HttpRequestMessage ^> ^ get(); void set(System::Net::Http::HeaderEncodingSelector<System::Net::Http::HttpRequestMessage ^> ^ value); };
public System.Net.Http.HeaderEncodingSelector<System.Net.Http.HttpRequestMessage>? ResponseHeaderEncodingSelector { get; set; }
member this.ResponseHeaderEncodingSelector : System.Net.Http.HeaderEncodingSelector<System.Net.Http.HttpRequestMessage> with get, set
Public Property ResponseHeaderEncodingSelector As HeaderEncodingSelector(Of HttpRequestMessage)

Property Value

The header encoding selector callback that selects the Encoding to decode the value for the specified response header name, or null to indicate the default behavior.

Exceptions

An operation has already been started on the current instance.

The current instance has been disposed.

Remarks

When specifying an encoding, you're generally expected to use one of the following encoding schemes: ASCII, Latin1, or UTF8. Other encoding schemes might be susceptible to request smuggling attacks.

Caution

Fixed multi-byte encoding schemes in particular (for example, Unicode or UTF32) must never be used, as their binary representation is likely to be misinterpreted and break the protocol. For instance, part of might be interpreted as a new line (\n) that terminates the header value.

When you specify an encoding, it's your responsibility to ensure that the values are representable via the encoding, and that the server agrees on the encoding used. Otherwise, values will become corrupted. For example, since any set of bytes is considered a valid Latin1 sequence, a server replying with UTF-8 encoded header values might see its responses silently corrupted.

Applies to