HttpContent.TryComputeLength(Int64) Method

Definition

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

protected public:
 abstract bool TryComputeLength([Runtime::InteropServices::Out] long % length);
protected internal abstract bool TryComputeLength (out long length);
abstract member TryComputeLength : int64 -> bool
Protected Friend MustOverride Function TryComputeLength (ByRef length As Long) As Boolean

Parameters

length
Int64

The length in bytes of the HTTP content.

Returns

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

Remarks

The TryComputeLength method gives a HTTP content the ability to calculate the content length. This is useful for content types which are able to easily 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.

Applies to