Language

IHttpSysRequestPropertyFeature.TryGetRequestProperty Method

Definition

Reads an arbitrary HTTP_REQUEST_PROPERTY value from HTTP.SYS using the HttpQueryRequestProperty Windows API.

public virtual bool TryGetRequestProperty(int propertyId, ReadOnlySpan<byte> qualifier, Span<byte> output, out int bytesReturned);
abstract member TryGetRequestProperty : int * ReadOnlySpan<byte> * Span<byte> * int -> bool
override this.TryGetRequestProperty : int * ReadOnlySpan<byte> * Span<byte> * int -> bool
Public Overridable Function TryGetRequestProperty (propertyId As Integer, qualifier As ReadOnlySpan(Of Byte), output As Span(Of Byte), ByRef bytesReturned As Integer) As Boolean

Parameters

propertyId
Int32

The HTTP_REQUEST_PROPERTY identifier to query. The set of supported values is defined by the HTTP_REQUEST_PROPERTY enum in http.h; the caller is responsible for parsing the bytes returned in output using the corresponding native struct.

qualifier
ReadOnlySpan<Byte>

Optional property-specific qualifier bytes. Pass an empty span for properties that do not require a qualifier; it will be mapped to a null pointer when calling the underlying API.

output
Span<Byte>

Destination buffer that receives the property value. Pass an empty span to query the required buffer size via bytesReturned.

bytesReturned
Int32

Returns the number of bytes written to output. If output was too small (or empty), returns the size of the buffer required to hold the value.

Returns

True if the property was successfully read into output. False if output is not large enough to hold the value; in that case bytesReturned contains the required buffer size. For any other failure, an exception is thrown.

Exceptions

Any HttpSys error except for ERROR_INSUFFICIENT_BUFFER or ERROR_MORE_DATA.

If the installed Windows HTTP Server API does not support HttpQueryRequestProperty.

Remarks

If the required buffer size is not known up front, first call this method with an empty output to retrieve the required size in bytesReturned, then allocate that many bytes and retry the query.

Applies to