HttpListenerElement Classe
Definição
Representa o elemento HttpListener no arquivo de configuração.Represents the HttpListener element in the configuration file. Essa classe não pode ser herdada.This class cannot be inherited.
public ref class HttpListenerElement sealed : System::Configuration::ConfigurationElement
public sealed class HttpListenerElement : System.Configuration.ConfigurationElement
type HttpListenerElement = class
inherit ConfigurationElement
Public NotInheritable Class HttpListenerElement
Inherits ConfigurationElement
- Herança
Comentários
Essa classe corresponde ao <httpListener> elemento de configuração de elemento (configurações de rede).This class corresponds to the <httpListener> Element (Network Settings) configuration element. Essa classe fornece acesso programático a informações que podem ser armazenadas em arquivos de configuração.This class provides programmatic access to information that can be stored in configuration files.
A UnescapeRequestUrl propriedade indica se o HttpListener usa o URI sem escape bruto, em vez do URI convertido, onde quaisquer valores codificados por porcentagem são convertidos e outras etapas de normalização são executadas.The UnescapeRequestUrl property indicates if HttpListener uses the raw unescaped URI instead of the converted URI where any percent-encoded values are converted and other normalization steps are taken.
Quando uma HttpListener instância recebe uma solicitação por meio do http.sys serviço, ela cria uma instância da cadeia de caracteres de URI fornecida pelo http.sys e a expõe como a HttpListenerRequest.Url propriedade.When a HttpListener instance receives a request through the http.sys service, it creates an instance of the URI string provided by http.sys, and exposes it as the HttpListenerRequest.Url property.
O http.sys serviço expõe duas cadeias de caracteres de URI de solicitação:The http.sys service exposes two request URI strings:
URI brutoRaw URI
URI convertidoConverted URI
O URI bruto é o System.Uri fornecido na linha de solicitação de uma solicitação http:The raw URI is the System.Uri provided in the request line of a HTTP request:
GET /path/
Host: www.contoso.com
O URI bruto fornecido pelo http.sys para a solicitação mencionada acima é "/Path/".The raw URI provided by http.sys for the request mentioned above, is "/path/". Isso representa a cadeia de caracteres após o verbo HTTP, pois ele foi enviado pela rede.This represents the string following the HTTP verb as it was sent over the network.
O http.sys serviço cria um URI convertido a partir das informações fornecidas na solicitação usando o URI fornecido na linha de solicitação HTTP e o cabeçalho do host para determinar o servidor de origem para o qual a solicitação deve ser encaminhada.The http.sys service creates a converted URI from the information provided in the request by using the URI provided in the HTTP request line and the Host header to determine the origin server the request should be forwarded to. Isso é feito comparando as informações da solicitação com um conjunto de prefixos de URI registrados.This is done by comparing the information from the request with a set of registered URI prefixes. A documentação do SDK do servidor HTTP refere-se a esse URI convertido como a estrutura de HTTP_COOKED_URL .The HTTP Server SDK documentation refers to this converted URI as the HTTP_COOKED_URL structure.
Para poder comparar a solicitação com prefixos de URI registrados, é necessário fazer alguma normalização na solicitação.In order to be able to compare the request with registered URI prefixes, some normalization to the request needs to be done. Para o exemplo acima, o URI convertido seria o seguinte:For the sample above the converted URI would be as follows:
http://www.contoso.com/path/
O http.sys serviço combina o Uri.Host valor da propriedade e a cadeia de caracteres na linha de solicitação para criar um URI convertido.The http.sys service combines the Uri.Host property value and the string in the request line to create a converted URI. Além disso, http.sys e a System.Uri classe também faz o seguinte:In addition, http.sys and the System.Uri class also do the following:
Cancela o escape de todos os valores codificados por porcentagem.Un-escapes all percent encoded values.
Converte caracteres não ASCII codificados por porcentagem em uma representação de caractere UTF-16.Converts percent-encoded non-ASCII characters into a UTF-16 character representation. Observe que os caracteres UTF-8 e ANSI/DBCS têm suporte, bem como caracteres Unicode (codificação Unicode usando o formato% uXXXX).Note that UTF-8 and ANSI/DBCS characters are supported as well as Unicode characters (Unicode encoding using the %uXXXX format).
Executa outras etapas de normalização, como compactação de caminho.Executes other normalization steps, like path compression.
Como a solicitação não contém informações sobre a codificação usada para valores codificados por porcentagem, talvez não seja possível determinar a codificação correta apenas analisando os valores codificados por porcentagem.Since the request doesn't contain any information about the encoding used for percent-encoded values, it may not be possible to determine the correct encoding just by parsing the percent-encoded values.
Portanto, o http.sys fornece duas chaves do registro para modificar o processo:Therefore http.sys provides two registry keys for modifying the process:
| Chave do RegistroRegistry Key | Valor padrãoDefault Value | DescriçãoDescription |
|---|---|---|
| EnableNonUTF8EnableNonUTF8 | 11 | Se zero, http.sys aceitará somente URLs codificadas em UTF-8.If zero, http.sys accepts only UTF-8-encoded URLs.Se for diferente de zero, o http.sys também aceitará URLs codificadas por ANSI ou DBCS em solicitações.If non-zero, http.sys also accepts ANSI-encoded or DBCS-encoded URLs in requests. |
| FavorUTF8FavorUTF8 | 11 | Se for diferente de zero, http.sys o sempre tentará decodificar uma URL como UTF-8 primeiro; se essa conversão falhar e EnableNonUTF8 for diferente de zero, Http.sys tentará decodificá-la como ANSI ou DBCS.If non-zero, http.sys always tries to decode a URL as UTF-8 first; if that conversion fails and EnableNonUTF8 is non-zero, Http.sys then tries to decode it as ANSI or DBCS.Se zero (e EnableNonUTF8 for diferente de zero), http.sys o tentará decodificá-lo como ANSI ou DBCS; se isso não for bem-sucedido, ele tentará uma conversão UTF-8.If zero (and EnableNonUTF8 is non-zero), http.sys tries to decode it as ANSI or DBCS; if that is not successful, it tries a UTF-8 conversion. |
Quando o HttpListener recebe uma solicitação, ele usa o URI convertido de http.sys como entrada para a Url propriedade.When HttpListener receives a request, it uses the converted URI from http.sys as input to the Url property.
Há uma necessidade de dar suporte a caracteres além de caracteres e números em URIs.There is a need for supporting characters besides characters and numbers in URIs. Um exemplo é o URI a seguir, que é usado para recuperar informações do cliente para o número de cliente "1/3812":An example is the following URI, which is used to retrieve customer information for customer number "1/3812":
http://www.contoso.com/Customer('1%2F3812')/
Observe a barra codificada por porcentagem no URI (% 2F).Note the percent-encoded slash in the Uri (%2F). Isso é necessário, pois, nesse caso, o caractere de barra representa dados e não um delimitador de caminho.This is necessary, since in this case the slash character represents data and not a path delimiter.
Passar a cadeia de caracteres para o construtor de URI resultará no seguinte URI:Passing the string to Uri constructor will lead to the following URI:
http://www.contoso.com/Customer('1/3812')/
Dividir o caminho em seus segmentos resultaria nos seguintes elementos:Splitting the path into its segments would result in the following elements:
Customer('1
3812')
Essa não é a intenção do remetente da solicitação.This is not the intent of the sender of the request.
Se a UnescapeRequestUrl propriedade for definida como false, quando o HttpListener receber uma solicitação, ele usará o URI bruto em vez do URI convertido de http.sys como entrada para a Url propriedade.If the UnescapeRequestUrl property is set to false, then when the HttpListener receives a request, it uses the raw URI instead of the converted URI from http.sys as input to the Url property.
Construtores
| HttpListenerElement() |
Inicializa uma nova instância da classe HttpListenerElement.Initializes a new instance of the HttpListenerElement class. |
Propriedades
| CurrentConfiguration |
Obtém uma referência para a instância Configuration de nível superior que representa a hierarquia de configuração à qual a instância atual ConfigurationElement pertence.Gets a reference to the top-level Configuration instance that represents the configuration hierarchy that the current ConfigurationElement instance belongs to. (Herdado de ConfigurationElement) |
| ElementInformation |
Obtém um objeto ElementInformation que contém as informações não personalizáveis e a funcionalidade do objeto ConfigurationElement.Gets an ElementInformation object that contains the non-customizable information and functionality of the ConfigurationElement object. (Herdado de ConfigurationElement) |
| ElementProperty |
Obtém o objeto ConfigurationElementProperty que representa o próprio objeto ConfigurationElement.Gets the ConfigurationElementProperty object that represents the ConfigurationElement object itself. (Herdado de ConfigurationElement) |
| EvaluationContext |
Obtém o objeto ContextInformation para o objeto ConfigurationElement.Gets the ContextInformation object for the ConfigurationElement object. (Herdado de ConfigurationElement) |
| HasContext |
Obtém um valor que indica se a propriedade CurrentConfiguration é |
| Item[ConfigurationProperty] |
Obtém ou define uma propriedade ou um atributo desse elemento de configuração.Gets or sets a property or attribute of this configuration element. (Herdado de ConfigurationElement) |
| Item[String] |
Obtém ou define uma propriedade, atributo ou elemento filho desse elemento de configuração.Gets or sets a property, attribute, or child element of this configuration element. (Herdado de ConfigurationElement) |
| LockAllAttributesExcept |
Obtém a coleção de atributos bloqueados.Gets the collection of locked attributes. (Herdado de ConfigurationElement) |
| LockAllElementsExcept |
Obtém a coleção de elementos bloqueados.Gets the collection of locked elements. (Herdado de ConfigurationElement) |
| LockAttributes |
Obtém a coleção de atributos bloqueados.Gets the collection of locked attributes. (Herdado de ConfigurationElement) |
| LockElements |
Obtém a coleção de elementos bloqueados.Gets the collection of locked elements. (Herdado de ConfigurationElement) |
| LockItem |
Obtém ou define um valor que indica se o elemento está bloqueado.Gets or sets a value indicating whether the element is locked. (Herdado de ConfigurationElement) |
| Properties |
Obtém a coleção de propriedades.Gets the collection of properties. (Herdado de ConfigurationElement) |
| Timeouts |
Obtém os elementos de tempo limite padrão usados para um objeto HttpListener.Gets the default timeout elements used for an HttpListener object. |
| UnescapeRequestUrl |
Obtém um valor que indica se HttpListener usa o URI sem escape bruto em vez do URI convertido.Gets a value that indicates if HttpListener uses the raw unescaped URI instead of the converted URI. |
Métodos
| DeserializeElement(XmlReader, Boolean) |
Lê o XML do arquivo de configuração.Reads XML from the configuration file. (Herdado de ConfigurationElement) |
| Equals(Object) |
Compara a instância ConfigurationElement atual com o objeto especificado.Compares the current ConfigurationElement instance to the specified object. (Herdado de ConfigurationElement) |
| GetHashCode() |
Obtém um valor exclusivo que representa a instância ConfigurationElement atual.Gets a unique value representing the current ConfigurationElement instance. (Herdado de ConfigurationElement) |
| GetTransformedAssemblyString(String) |
Retorna a versão transformada do nome do assembly especificado.Returns the transformed version of the specified assembly name. (Herdado de ConfigurationElement) |
| GetTransformedTypeString(String) |
Retorna a versão transformada do nome do tipo especificado.Returns the transformed version of the specified type name. (Herdado de ConfigurationElement) |
| GetType() |
Obtém o Type da instância atual.Gets the Type of the current instance. (Herdado de Object) |
| Init() |
Define o objeto ConfigurationElement para seu estado inicial.Sets the ConfigurationElement object to its initial state. (Herdado de ConfigurationElement) |
| InitializeDefault() |
Usado para inicializar um conjunto padrão de valores para o objeto ConfigurationElement.Used to initialize a default set of values for the ConfigurationElement object. (Herdado de ConfigurationElement) |
| IsModified() |
Indica se este elemento de configuração foi modificado desde a última vez em que foi salvo ou carregado quando implementado em uma classe derivada.Indicates whether this configuration element has been modified since it was last saved or loaded, when implemented in a derived class. (Herdado de ConfigurationElement) |
| IsReadOnly() |
Obtém um valor que indica se o objeto ConfigurationElement é somente leitura.Gets a value indicating whether the ConfigurationElement object is read-only. (Herdado de ConfigurationElement) |
| ListErrors(IList) |
Adiciona os erros de propriedade inválida deste objeto ConfigurationElement e de todos os subelementos à lista passada.Adds the invalid-property errors in this ConfigurationElement object, and in all subelements, to the passed list. (Herdado de ConfigurationElement) |
| MemberwiseClone() |
Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object. (Herdado de Object) |
| OnDeserializeUnrecognizedAttribute(String, String) |
Obtém um valor que indica se um atributo desconhecido é encontrado durante a desserialização.Gets a value indicating whether an unknown attribute is encountered during deserialization. (Herdado de ConfigurationElement) |
| OnDeserializeUnrecognizedElement(String, XmlReader) |
Obtém um valor que indica se um elemento desconhecido é encontrado durante a desserialização.Gets a value indicating whether an unknown element is encountered during deserialization. (Herdado de ConfigurationElement) |
| OnRequiredPropertyNotFound(String) |
Gera uma exceção quando uma propriedade necessária não é encontrada.Throws an exception when a required property is not found. (Herdado de ConfigurationElement) |
| PostDeserialize() |
Chamado depois da desserialização.Called after deserialization. (Herdado de ConfigurationElement) |
| PreSerialize(XmlWriter) |
Chamado antes da serialização.Called before serialization. (Herdado de ConfigurationElement) |
| Reset(ConfigurationElement) |
Redefine o estado interno do objeto ConfigurationElement, incluindo os bloqueios e as coleções de propriedades.Resets the internal state of the ConfigurationElement object, including the locks and the properties collections. (Herdado de ConfigurationElement) |
| ResetModified() |
Redefine o valor do método IsModified() para |
| SerializeElement(XmlWriter, Boolean) |
Grava o conteúdo desse elemento de configuração no arquivo de configuração quando implementado em uma classe derivada.Writes the contents of this configuration element to the configuration file when implemented in a derived class. (Herdado de ConfigurationElement) |
| SerializeToXmlElement(XmlWriter, String) |
Grava as marcas externas desse elemento de configuração no arquivo de configuração quando implementado em uma classe derivada.Writes the outer tags of this configuration element to the configuration file when implemented in a derived class. (Herdado de ConfigurationElement) |
| SetPropertyValue(ConfigurationProperty, Object, Boolean) |
Define uma propriedade para o valor especificado.Sets a property to the specified value. (Herdado de ConfigurationElement) |
| SetReadOnly() |
Define a propriedade IsReadOnly() para o objeto ConfigurationElement e para todos os subelementos.Sets the IsReadOnly() property for the ConfigurationElement object and all subelements. (Herdado de ConfigurationElement) |
| ToString() |
Retorna uma cadeia de caracteres que representa o objeto atual.Returns a string that represents the current object. (Herdado de Object) |
| Unmerge(ConfigurationElement, ConfigurationElement, ConfigurationSaveMode) |
Modifica o objeto ConfigurationElement para remover todos os valores que não devem ser salvos.Modifies the ConfigurationElement object to remove all values that should not be saved. (Herdado de ConfigurationElement) |