add_header ( $key, $value )

Adds a custom HTTP header to the cURL request.

Access

public

Parameters

Parameter

Type

Required

Description

$key

string

Required

The custom HTTP header to set.

$value

mixed

Required

The value to assign to the custom HTTP header.

Returns

Type

Description

$this

A reference to the current instance.

Examples

Add a custom header to the request (without firing it).

$http = new RequestCore('http://github.com/skyzyx/requestcore/raw/master/_tests/test_request.txt');
$http->prep_request();
$http->add_header('x-requestcore-header', 'value');

var_dump($http->request_headers);
Result:
array(3) {
  ["Expect"]=>
  string(12) "100-continue"
  ["Connection"]=>
  string(5) "close"
  ["x-requestcore-header"]=>
  string(5) "value"
}

Source

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback