다음을 통해 공유


HttpURLConnection.SetFixedLengthStreamingMode Method

Definition

Overloads

SetFixedLengthStreamingMode(Int32)

This method is used to enable streaming of a HTTP request body without internal buffering, when the content length is known in advance.

SetFixedLengthStreamingMode(Int64)

This method is used to enable streaming of a HTTP request body without internal buffering, when the content length is known in advance.

SetFixedLengthStreamingMode(Int32)

This method is used to enable streaming of a HTTP request body without internal buffering, when the content length is known in advance.

[Android.Runtime.Register("setFixedLengthStreamingMode", "(I)V", "GetSetFixedLengthStreamingMode_IHandler")]
public virtual void SetFixedLengthStreamingMode (int contentLength);
[<Android.Runtime.Register("setFixedLengthStreamingMode", "(I)V", "GetSetFixedLengthStreamingMode_IHandler")>]
abstract member SetFixedLengthStreamingMode : int -> unit
override this.SetFixedLengthStreamingMode : int -> unit

Parameters

contentLength
Int32

The number of bytes which will be written to the OutputStream.

Attributes

Exceptions

if already connected or another mode already set.

if contentLength is less than zero.

Remarks

This method is used to enable streaming of a HTTP request body without internal buffering, when the content length is known in advance.

An exception will be thrown if the application attempts to write more data than the indicated content-length, or if the application closes the OutputStream before writing the indicated amount.

When output streaming is enabled, authentication and redirection cannot be handled automatically. A HttpRetryException will be thrown when reading the response if authentication or redirection are required. This exception can be queried for the details of the error.

This method must be called before the URLConnection is connected.

<B>NOTE:</B> #setFixedLengthStreamingMode(long) is recommended instead of this method as it allows larger content lengths to be set.

Added in 1.5.

Java documentation for java.net.HttpURLConnection.setFixedLengthStreamingMode(int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

SetFixedLengthStreamingMode(Int64)

This method is used to enable streaming of a HTTP request body without internal buffering, when the content length is known in advance.

[Android.Runtime.Register("setFixedLengthStreamingMode", "(J)V", "GetSetFixedLengthStreamingMode_JHandler")]
public virtual void SetFixedLengthStreamingMode (long contentLength);
[<Android.Runtime.Register("setFixedLengthStreamingMode", "(J)V", "GetSetFixedLengthStreamingMode_JHandler")>]
abstract member SetFixedLengthStreamingMode : int64 -> unit
override this.SetFixedLengthStreamingMode : int64 -> unit

Parameters

contentLength
Int64

The number of bytes which will be written to the OutputStream.

Attributes

Exceptions

if already connected or another mode already set.

if contentLength is less than zero.

Remarks

This method is used to enable streaming of a HTTP request body without internal buffering, when the content length is known in advance.

An exception will be thrown if the application attempts to write more data than the indicated content-length, or if the application closes the OutputStream before writing the indicated amount.

When output streaming is enabled, authentication and redirection cannot be handled automatically. A HttpRetryException will be thrown when reading the response if authentication or redirection are required. This exception can be queried for the details of the error.

This method must be called before the URLConnection is connected.

The content length set by invoking this method takes precedence over any value set by #setFixedLengthStreamingMode(int).

Added in 1.7.

Java documentation for java.net.HttpURLConnection.setFixedLengthStreamingMode(long).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

See also

Applies to