* Append headers without overwriting using Message::appendHeader(): */ assert(count($request->getHeader('cookie')) === 3); // true $request->appendHeader('Cookie', 'cookie4=val4'); assert(count($request->getHeader('Cookie')) === 4); // true /** * You may set multiple headers at one time via $request->setAllHeaders(): */ $request->setAllHeaders(['X-My-Header' => 'some value', 'Accept' => '*/*', 'Cookie' => ['cookie1=val1', 'cookie1=val2']]); /** * You can remove a previously assigned header value using Message::removeHeader(). Once again, * the header field name is case-insensitive: */ $request->removeHeader('cookie'); assert(!$request->hasHeader('Cookie')); // true /** * If you attempt to retrieve a non-existent header Amp\Artax will throw a DomainException: */ try { $request->getHeader('Some-Header-That-Isnt-Assigned'); die('Expected exception not thrown'); } catch (DomainException $e) { // Yep, it worked correctly. } /** * Most HTTP headers may appear multiple times in the same message. For this reason it makes sense * to represent all message headers as arrays. When you retrieve a header it will be returned as a * numerically-indexed array: