Skip to content

Commit

Permalink
Fixed issue with requests
Browse files Browse the repository at this point in the history
  • Loading branch information
kocsismate committed Aug 27, 2015
1 parent 0daac5f commit 6df5ec2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ CHANGED:

FIXED:

## 0.4.1 - 2015-08-26
## 0.4.2 - 2015-08-27

FIXED:

- Some exceptions had errorous namespaces
- `Request::with*` methods returned an instance of PSR `ServerRequestInterface`
- Validation of the `Content-Type` and the `Accept` headers is now compliant with the spec

## 0.4.0 - 2015-08-26

Expand Down
30 changes: 14 additions & 16 deletions src/JsonApi/Request/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,7 @@ protected function getHeaderExtensions($headerName)
protected function getInvalidHeaderMediaType($headerName)
{
foreach ($this->parseMediaTypeHeader($headerName) as $mediaType) {
if ($mediaType["name"] !== "application/vnd.api+json") {
return $mediaType["raw"];
} else {
if ($mediaType["name"] === "application/vnd.api+json") {
foreach ($mediaType["parameters"] as $paramName => $paramValue) {
if ($paramName !== "ext") {
return $mediaType["raw"];
Expand Down Expand Up @@ -405,23 +403,23 @@ public function getHeaderLine($name)
*/
public function withHeader($name, $value)
{
return $this->serverRequest->withHeader($name, $value);
return new self($this->serverRequest->withHeader($name, $value));
}

/**
* @inheritDoc
*/
public function withAddedHeader($name, $value)
{
return $this->serverRequest->withAddedHeader($name, $value);
return new self($this->serverRequest->withAddedHeader($name, $value));
}

/**
* @inheritDoc
*/
public function withoutHeader($name)
{
return $this->serverRequest->withoutHeader($name);
return new self($this->serverRequest->withoutHeader($name));
}

/**
Expand All @@ -437,7 +435,7 @@ public function getBody()
*/
public function withBody(StreamInterface $body)
{
return $this->serverRequest->withBody($body);
return new self($this->serverRequest->withBody($body));
}

/**
Expand All @@ -453,7 +451,7 @@ public function getRequestTarget()
*/
public function withRequestTarget($requestTarget)
{
return $this->serverRequest->withRequestTarget($requestTarget);
return new self($this->serverRequest->withRequestTarget($requestTarget));
}

/**
Expand All @@ -469,7 +467,7 @@ public function getMethod()
*/
public function withMethod($method)
{
return $this->serverRequest->withMethod($method);
return new self($this->serverRequest->withMethod($method));
}

/**
Expand All @@ -485,7 +483,7 @@ public function getUri()
*/
public function withUri(UriInterface $uri, $preserveHost = false)
{
return $this->serverRequest->withUri($uri, $preserveHost);
return new self($this->serverRequest->withUri($uri, $preserveHost));
}

/**
Expand All @@ -509,7 +507,7 @@ public function getCookieParams()
*/
public function withCookieParams(array $cookies)
{
return $this->serverRequest->withCookieParams($cookies);
return new self($this->serverRequest->withCookieParams($cookies));
}

/**
Expand All @@ -525,7 +523,7 @@ public function getQueryParams()
*/
public function withQueryParams(array $query)
{
return $this->serverRequest->withQueryParams($query);
return new self($this->serverRequest->withQueryParams($query));
}

/**
Expand All @@ -541,7 +539,7 @@ public function getUploadedFiles()
*/
public function withUploadedFiles(array $uploadedFiles)
{
return $this->serverRequest->withUploadedFiles($uploadedFiles);
return new self($this->serverRequest->withUploadedFiles($uploadedFiles));
}

/**
Expand All @@ -557,7 +555,7 @@ public function getParsedBody()
*/
public function withParsedBody($data)
{
return $this->serverRequest->withParsedBody($data);
return new self($this->serverRequest->withParsedBody($data));
}

/**
Expand All @@ -581,14 +579,14 @@ public function getAttribute($name, $default = null)
*/
public function withAttribute($name, $value)
{
return $this->serverRequest->withAttribute($name, $value);
return new self($this->serverRequest->withAttribute($name, $value));
}

/**
* @inheritDoc
*/
public function withoutAttribute($name)
{
return $this->serverRequest->withoutAttribute($name);
return new self($this->serverRequest->withoutAttribute($name));
}
}

0 comments on commit 6df5ec2

Please sign in to comment.