AddHeader VI

Owning Palette: Headers VIs

Requires: Base Development System

Adds a header field line to all Web requests associated with the client handle. Headers define attributes of the data exchanged between the client and server.

If you specify a header that already exists, the specified value overwrites the header value. Use RemoveHeader to remove headers.

Details  

 Add to the block diagram  Find on the palette
client handle specifies the client handle to associate with the Web request. Use client handles to wire together multiple HTTP Client VIs while preserving authentication credentials, HTTP headers, and cookies. Client handles are not required when making independent Web requests without persistent data such as headers or credentials.
header specifies the header field to add to all Web requests associated with the client handle. The header control provides a pull-down menu with some available header fields.

If you specify a header that already exists, the specified value overwrites the header value.
value specifies the value to assign to the header field.
error in describes error conditions that occur before this node runs. This input provides standard error in functionality.
client handle out returns the client handle associated with the Web request. Use client handles to wire together multiple HTTP Client VIs while preserving authentication credentials, HTTP headers, and cookies. Client handles are not required when making independent Web requests without persistent data such as headers or credentials.
error out contains error information. This output provides standard error out functionality.

AddHeader Details

Client handles save header values across multiple Web requests. Use the Open Handle VI to create a client handle. Refer to the World Wide Web Consortium website at www.w3.org for more information about header field definitions including example headers, descriptions, and syntax.

The following screenshot shows code that performs the following:

  1. The OpenHandle VI opens a client handle and a client-side cookie that can store persistent data.
  2. The AddHeader VI adds a new header field line that sets the preferred language for subsequent Web requests associated with the client handle.
  3. The GET VI performs a Web request that includes the Accept-Language header.
  4. The CloseHandle VI closes the client handle and deletes any persistent data, including headers.