Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangjincheng committed May 31, 2019
2 parents 1a43bd7 + 0f0832f commit bcd9dcb
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions src/Core/Server/Beans/Http/MessageTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,14 @@ public function withHeader($name, $value)
$value = $this->trimHeaderValues($value);
$normalized = strtolower($name);

$new = clone $this;
if (isset($new->headerNames[$normalized])) {
unset($new->headers[$new->headerNames[$normalized]]);

if (isset($this->headerNames[$normalized])) {
unset($this->headers[$this->headerNames[$normalized]]);
}
$new->headerNames[$normalized] = $name;
$new->headers[$name] = $value;
$this->headerNames[$normalized] = $name;
$this->headers[$name] = $value;

return $new;
return $this;
}

/**
Expand Down Expand Up @@ -212,16 +212,15 @@ public function withAddedHeader($name, $value)
$value = $this->trimHeaderValues($value);
$normalized = strtolower($name);

$new = clone $this;
if (isset($new->headerNames[$normalized])) {
$name = $this->headerNames[$normalized];
$new->headers[$name] = array_merge($this->headers[$name], $value);
if (isset($this->headerNames[$normalized])) {
$this->headerNames[$normalized];
$this->headers[$name] = array_merge($this->headers[$name], $value);
} else {
$new->headerNames[$normalized] = $name;
$new->headers[$name] = $value;
$this->headerNames[$normalized] = $name;
$this->headers[$name] = $value;
}

return $new;
return $this;
}

/**
Expand All @@ -244,10 +243,9 @@ public function withoutHeader($name)

$name = $this->headerNames[$normalized];

$new = clone $this;
unset($new->headers[$name], $new->headerNames[$normalized]);
unset($this->headers[$name], $this->headerNames[$normalized]);

return $new;
return $this;
}

/**
Expand Down

0 comments on commit bcd9dcb

Please sign in to comment.