/** * Adds request id to request/response and returns new instance. * * @param MessageInterface $message * * @return MessageInterface * * @throws \InvalidArgumentException */ public function decorate(MessageInterface $message) { return $message->withHeader($this->headerName, $this->idProvider->getRequestId()); }
public function testWithHeaderAllowsHeaderContinuations() { $message = $this->message->withHeader('X-Foo-Bar', "value,\r\n second value"); $this->assertEquals("value,\r\n second value", $message->getHeaderLine('X-Foo-Bar')); }
/** * Method to add a Cache-Control header to the provided PSR-7 message. * * @link https://tools.ietf.org/html/rfc7234#section-5.2 * * @param MessageInterface $message PSR-7 message to add the Cache-Control header to * @param CacheControl $cacheControl Cache-Control object to add to the message * @return MessageInterface The PSR-7 message with the added Cache-Control header * @throws InvalidArgumentException If the Cache-Control header is invalid */ public function withCacheControl(MessageInterface $message, CacheControl $cacheControl) { return $message->withHeader('Cache-Control', (string) $cacheControl); }
/** * {@inheritdoc} */ public function withHeader($header, $value) { $new = clone $this; $new->message = $this->message->withHeader($header, $value); return $new; }
public function set($header, $value) { $this->request = $this->request->withHeader($header, $value); }