HttpEncoder.HeaderNameValueEncode(String, String, String, String) Method

Definition

Encodes a header name and value into a string that can be used as an HTTP header.

protected public:
 virtual void HeaderNameValueEncode(System::String ^ headerName, System::String ^ headerValue, [Runtime::InteropServices::Out] System::String ^ % encodedHeaderName, [Runtime::InteropServices::Out] System::String ^ % encodedHeaderValue);
protected internal virtual void HeaderNameValueEncode (string headerName, string headerValue, out string encodedHeaderName, out string encodedHeaderValue);
abstract member HeaderNameValueEncode : string * string * string * string -> unit
override this.HeaderNameValueEncode : string * string * string * string -> unit
Protected Friend Overridable Sub HeaderNameValueEncode (headerName As String, headerValue As String, ByRef encodedHeaderName As String, ByRef encodedHeaderValue As String)

Parameters

headerName
String

The HTTP header name to encode.

headerValue
String

The HTTP header value to encode.

encodedHeaderName
String

When this method returns, contains the encoded name to use for an HTTP header. This parameter is passed uninitialized.

encodedHeaderValue
String

When this method returns, contains the encoded value to use for an HTTP header. This parameter is passed uninitialized.

Remarks

The HeaderNameValueEncode method takes input strings from the headerName and headerValue parameters and encodes them. The encoded values are returned as out parameters.

The HeaderNameValueEncode method uses the following logic to encode header names and values:

  • All characters whose Unicode value is less than ASCII character 32, except ASCII character 9, are URL-encoded into a format of %NN where the N characters represent hexadecimal values.

  • ASCII character 9 (the horizontal tab character) is not URL-encoded.

  • ASCII character 127 is encoded as %7F.

  • All other characters are not encoded.

    Note

    Although this method can be used for Unicode values, it is typically used for values in the ASCII range.

The default implementation of the HeaderNameValueEncode method returns the value of headerValue in encodedHeaderValue if headerValue is null or is an empty string. Similarly, the default implementation returns the value of headerName in encodedHeaderName if headerName is null or is an empty string.

Applies to