Skip to content

Commit d41f656

Browse files
committed
[Http] Add support for HTTP/1.1 continue status codes
Some clients need this before they send their request body, in order to avoid sending huge amounts of data needlessly
1 parent 923d4a7 commit d41f656

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Request.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ public function getHeaders()
5050
return $this->headers;
5151
}
5252

53+
public function expectsContinue()
54+
{
55+
return isset($this->headers['Expect']) && '100-continue' === $this->headers['Expect'];
56+
}
57+
5358
public function isReadable()
5459
{
5560
return $this->readable;

Response.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ public function isWritable()
2424
return $this->writable;
2525
}
2626

27+
public function writeContinue()
28+
{
29+
if ($this->headWritten) {
30+
throw new \Exception('Response head has already been written.');
31+
}
32+
33+
$this->conn->write("HTTP/1.1 100 Continue\r\n");
34+
}
35+
2736
public function writeHead($status = 200, array $headers = array())
2837
{
2938
if ($this->headWritten) {

0 commit comments

Comments
 (0)