@@ -173,6 +173,18 @@ $message
173173 ->addCookie(new Cookie('PHPSESSID', '<MY_SESSION_ID>'))
174174 ->setBody($messageBody);
175175
176+ // Please note, that headers have some unusual behaviours.
177+ // Header names have an uniform way of nomenclature so the three getter calls would have the same result.
178+ $header1 = $message->getHeaderByName('Content-Type');
179+ $header2 = $message->getHeaderByName('content-type');
180+ $header3 = $message->getHeaderByName('CONTENT-Type');
181+
182+ // To allow multiple request headers using the same name, the method `addAdditionalHeader` provides such a logic.
183+ // Add or replace a request header
184+ $message->addHeader(new Header('Custom-Header', array('CustomHeaderValue')));
185+ // Add a request header and keep the existing one untouched
186+ $message->addAdditionalHeader(new Header('Custom-Header', array('AnotherCustomHeaderValue')));
187+
176188// Configuring and performing a Request
177189$request = new Request();
178190$response = $request
@@ -203,6 +215,8 @@ Cookie: PHPSESSID=<MY_SESSION_ID>
203215Content-Type: application/json
204216Accept: application/json, text/*
205217Runscope-Bucket-Auth: 7a64dde7-74d5-4eed-b170-a2ab406eff08
218+ Custom-Header: CustomHeaderValue
219+ Custom-Header: AnotherCustomHeaderValue
206220Content-Length: 102
207221
208222{"paramName1":"paramValue1","paramName2":"paramValue2","paramName3":{"key1":"value1","key2":"value2"}}
0 commit comments