Skip to content

Commit

Permalink
[Http] Add support for HTTP/1.1 continue status codes
Browse files Browse the repository at this point in the history
Some clients need this before they send their request body, in order to
avoid sending huge amounts of data needlessly
  • Loading branch information
igorw committed Oct 2, 2012
1 parent 923d4a7 commit d41f656
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ public function getHeaders()
return $this->headers;
}

public function expectsContinue()
{
return isset($this->headers['Expect']) && '100-continue' === $this->headers['Expect'];
}

public function isReadable()
{
return $this->readable;
Expand Down
9 changes: 9 additions & 0 deletions Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ public function isWritable()
return $this->writable;
}

public function writeContinue()
{
if ($this->headWritten) {
throw new \Exception('Response head has already been written.');
}

$this->conn->write("HTTP/1.1 100 Continue\r\n");
}

public function writeHead($status = 200, array $headers = array())
{
if ($this->headWritten) {
Expand Down

0 comments on commit d41f656

Please sign in to comment.