Compartilhar via


URLConnection.SetRequestProperty(String, String) Method

Definition

Sets the general request property.

[Android.Runtime.Register("setRequestProperty", "(Ljava/lang/String;Ljava/lang/String;)V", "GetSetRequestProperty_Ljava_lang_String_Ljava_lang_String_Handler")]
public virtual void SetRequestProperty (string? key, string? value);
[<Android.Runtime.Register("setRequestProperty", "(Ljava/lang/String;Ljava/lang/String;)V", "GetSetRequestProperty_Ljava_lang_String_Ljava_lang_String_Handler")>]
abstract member SetRequestProperty : string * string -> unit
override this.SetRequestProperty : string * string -> unit

Parameters

key
String

the keyword by which the request is known (e.g., "Accept").

value
String

the value associated with it.

Attributes

Exceptions

if the connection has been already established.

if the parameter field is null.

Remarks

Sets the general request property. If a property with the key already exists, overwrite its value with the new value.

NOTE: HTTP requires all request properties which can legally have multiple instances with the same key to use a comma-separated list syntax which enables multiple properties to be appended into a single property.

Java documentation for java.net.URLConnection.setRequestProperty(java.lang.String, java.lang.String).

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