Class HttpContent
A base class representing an HTTP entity body and content headers.
public abstract class HttpContent : IDisposable
- Inheritance
-
HttpContent
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
HttpContent()
Initializes a new instance of the HttpContent class.
protected HttpContent()
Properties
Headers
Gets the HTTP content headers as defined in RFC 2616.
public HttpContentHeaders Headers { get; }
Property Value
- HttpContentHeaders
The content headers as defined in RFC 2616.
Methods
CopyTo(Stream)
Serializes the HTTP content into a stream of bytes and copies it to stream
.
public void CopyTo(Stream stream)
Parameters
stream
StreamThe target stream.
Remarks
This is the .NET nanoFramework equivalent of HttpContent.CopyTo(Stream, TransportContext, CancellationToken).
Exceptions
- ArgumentNullException
The
stream
was null.
CreateContentReadStream()
If overridden, returns the HTTP content as a stream. Otherwise, SerializeToStream(Stream) is called.
protected virtual Stream CreateContentReadStream()
Returns
Remarks
This is the .NET nanoFramework equivalent of CreateContentReadStreamAsync().
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Dispose(bool)
protected virtual void Dispose(bool disposing)
Parameters
disposing
bool
LoadIntoBuffer()
Serialize the HTTP content to a memory buffer.
public void LoadIntoBuffer()
Remarks
This operation will block.
After content is serialized to a memory buffer, calls to one of the CopyTo methods will copy the content of the memory buffer to the target stream.
This is the .NET nanoFramework equivalent of LoadIntoBufferAsync.
Exceptions
- ObjectDisposedException
If the object has been disposed.
ReadAsByteArray()
Serialize the HTTP content to a byte array as an synchronous operation.
public byte[] ReadAsByteArray()
Returns
- byte[]
A byte array with the HTTP content.
Remarks
This operation will block.
This is the .NET nanoFramework equivalent of ReadAsByteArrayAsync.
ReadAsStream()
Serializes the HTTP content and returns a stream that represents the content.
public Stream ReadAsStream()
Returns
- Stream
The stream that represents the HTTP content.
Exceptions
- ObjectDisposedException
If the object has been disposed.
ReadAsString()
Serialize the HTTP content to a string as an synchronous operation.
public string ReadAsString()
Returns
- string
A string with the HTTP content.
Remarks
This operation will block.
This supports only UTF8 encoding.
This is the .NET nanoFramework equivalent of ReadAsStringAsync.
SerializeToStream(Stream)
When overridden in a derived class, serializes the HTTP content to a stream. Otherwise, throws a NotSupportedException.
protected abstract void SerializeToStream(Stream stream)
Parameters
stream
StreamThe target stream.
Remarks
This is the .NET nanoFramework equivalent of SerializeToStream(Stream, TransportContext, CancellationToken).
Exceptions
- NotSupportedException
The method is not overridden in the derived class.
TryComputeLength(out long)
Determines whether the HTTP content has a valid length in bytes.
protected abstract bool TryComputeLength(out long length)
Parameters
length
longThe length in bytes of the HTTP content.