public function modify(HeaderCollectionInterface $responseHeader, RequestInterface $request) { $origin = $request->getHeaderCollection()->getHeaderValue(HeaderName::ORIGIN, ''); if (!empty($origin)) { $responseHeader->setHeaderValue(HeaderName::ACCESS_CONTROL_ALLOW_ORIGIN, $origin); } $mustAllowCredentials = !empty($request->getHeaderCollection()->getHeaderValue(HeaderName::AUTHORIZATION, '')); if ($mustAllowCredentials) { $responseHeader->setHeaderValue(HeaderName::ACCESS_CONTROL_ALLOW_CREDENTIALS, 'true'); } }
public function getDeserializedRequestContent($rawContent, HeaderCollectionInterface $headerCollection) { if (!empty($rawContent)) { $contentType = $headerCollection->getHeaderValue(HeaderName::CONTENT_TYPE); if ($this->stringUtility->contains($contentType, ContentType::APPLICATION_JSON)) { $deserializedContent = $this->serializer->deserialize($rawContent, 'array', 'json'); } else { throw new UnsupportedMediaTypeException('Submitted media type not supported'); } } else { $deserializedContent = []; } return $deserializedContent; }
public function modify(HeaderCollectionInterface $responseHeader, RequestInterface $request) { $responseHeader->setHeaderValue(HeaderName::CONTENT_TYPE, ContentType::APPLICATION_JSON); }