I​Http​Content I​Http​Content I​Http​Content Interface

Definition

Provides a base interface for an HTTP entity body and content headers.

public : interface IHttpContentpublic interface IHttpContentPublic Interface IHttpContent
Inheritance
IClosableIDisposableIDisposable
IHttpContentIHttpContentIHttpContent
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Inherited Members

Inherited methods

Remarks

The contents of an HTTP message corresponds to the entity body and headers associated with the content defined in RFC 2616. Several classes and an interface in the Windows.Web.Http namespace can be used for HTTP content, including:

  • IHttpContent - A base interface for developers to create their own content objects. It represents an HTTP entity body and content headers. This interface has methods that get and set the actual content data. It also provides properties that get and set content related headers.
  • HttpBufferContent - HTTP content that uses a buffer.
  • HttpFormUrlEncodedContent - HTTP content that uses name/value tuples encoded with the application/x-www-form-urlencoded MIME type.
  • HttpMultipartContent - HTTP content that uses multipart/* MIME type.
  • HttpMultipartFormDataContent - HTTP content that uses the encoded multipart/form-data MIME type.
  • HttpStreamContent - HTTP content that uses a stream. This content type is used by the HTTP methods to receive data and HTTP methods to upload data.
  • HttpStringContent - HTTP content that uses a string.

Properties

Headers Headers Headers

Get a collection of content headers set on the IHttpContent.

public : HttpContentHeaderCollection Headers { get; }public HttpContentHeaderCollection Headers { get; }Public ReadOnly Property Headers As HttpContentHeaderCollection
Attributes

Remarks

The Headers property returns an HttpContentHeaderCollection object that can be used to get or set the specific headers on the HTTP content in an HTTP request or HTTP response.

See Also

Methods

BufferAllAsync() BufferAllAsync() BufferAllAsync()

Serialize the HTTP content into memory as an asynchronous operation.

public : IAsyncOperationWithProgress<ulong, ulong> BufferAllAsync()public IAsyncOperationWithProgress<ulong, ulong> BufferAllAsync()Public Function BufferAllAsync() As IAsyncOperationWithProgress( Of ulong, ulong )
Returns
Attributes

Remarks

This operation will not block. The returned IAsyncOperationWithProgress(UInt64, UInt64) object will complete after all of the content has been written into memory.

ReadAsBufferAsync() ReadAsBufferAsync() ReadAsBufferAsync()

Serialize the HTTP content to a buffer as an asynchronous operation.

public : IAsyncOperationWithProgress<IBuffer, ulong> ReadAsBufferAsync()public IAsyncOperationWithProgress<IBuffer, ulong> ReadAsBufferAsync()Public Function ReadAsBufferAsync() As IAsyncOperationWithProgress( Of IBuffer, ulong )
Returns
Attributes

Remarks

This operation will not block. The returned IAsyncOperationWithProgress(IBuffer, UInt64) object will complete after all of the content has been written to the buffer.

ReadAsInputStreamAsync() ReadAsInputStreamAsync() ReadAsInputStreamAsync()

Serialize the HTTP content and return an input stream that represents the content as an asynchronous operation.

public : IAsyncOperationWithProgress<IInputStream, ulong> ReadAsInputStreamAsync()public IAsyncOperationWithProgress<IInputStream, ulong> ReadAsInputStreamAsync()Public Function ReadAsInputStreamAsync() As IAsyncOperationWithProgress( Of IInputStream, ulong )
Returns
Attributes

Remarks

This operation will not block. The returned IAsyncOperationWithProgress(IInputStream, UInt64) object will complete after all of the content has been written to the input stream.

ReadAsStringAsync() ReadAsStringAsync() ReadAsStringAsync()

Serialize the HTTP content to a String as an asynchronous operation.

public : IAsyncOperationWithProgress<PlatForm::String, ulong> ReadAsStringAsync()public IAsyncOperationWithProgress<string, ulong> ReadAsStringAsync()Public Function ReadAsStringAsync() As IAsyncOperationWithProgress( Of string, ulong )
Returns
IAsyncOperationWithProgress<PlatForm::String, ulong> IAsyncOperationWithProgress<string, ulong> IAsyncOperationWithProgress<string, ulong>

The object representing the asynchronous operation.

Attributes

Remarks

This operation will not block. The returned IAsyncOperationWithProgress(String, UInt64) object will complete after all of the content has been written to the String.

See Also

TryComputeLength(UInt64) TryComputeLength(UInt64) TryComputeLength(UInt64)

Determines whether the HTTP content has a valid length in bytes.

public : PlatForm::Boolean TryComputeLength(unsigned __int64 length)public bool TryComputeLength(UInt64 length)Public Function TryComputeLength(length As UInt64) As bool
Parameters
length
unsigned __int64 UInt64 UInt64

The length in bytes of the HTTP content.

Returns
PlatForm::Boolean bool bool

true if length is a valid length; otherwise, false.

Attributes

Remarks

The TryComputeLength method calculates the content length for HTTP content in IHttpContent. This is useful for content types that are easy to calculate the content length.

If computing the content length is not possible or expensive (would require the system to buffer the whole content where the serialization would be expensive or require the system to allocate a lot of memory), this method can return false. If this method returns false, this implies that either chunked transfer is needed or the content must get buffered before being sent to the server.

WriteToStreamAsync(IOutputStream) WriteToStreamAsync(IOutputStream) WriteToStreamAsync(IOutputStream)

Write the HTTP content to an output stream as an asynchronous operation.

public : IAsyncOperationWithProgress<ulong, ulong> WriteToStreamAsync(IOutputStream outputStream)public IAsyncOperationWithProgress<ulong, ulong> WriteToStreamAsync(IOutputStream outputStream)Public Function WriteToStreamAsync(outputStream As IOutputStream) As IAsyncOperationWithProgress( Of ulong, ulong )
Parameters
outputStream
IOutputStream IOutputStream IOutputStream

The output stream to write to.

Returns
Attributes

Remarks

This operation will not block. The returned IAsyncOperationWithProgress(UInt64, UInt64) object will complete after all of the content has been written to the output stream.

See Also