Skip to content

Commit

Permalink
Updated sampleapi.php
Browse files Browse the repository at this point in the history
  • Loading branch information
hirak committed Jan 31, 2016
1 parent 89bd5f5 commit fe2b1bc
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/workspace/sampleapi.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,40 @@
parse_str(parse_url($path, PHP_URL_QUERY), $query);
if (isset($query['exit']) && $query['exit'] === '1') exit;

if (isset($query['status'])) {
switch ($query['status']) {
case '401':
$errorResponse = <<<_HTTP_
HTTP/1.1 401 Unauthorized\r
Connection: close\r
\r
_HTTP_;
break;
case '403':
$errorResponse = <<<_HTTP_
HTTP/1.1 403 Forbidden\r
Connection: close\r
\r
_HTTP_;
break;
case '404':
default:
$errorResponse = <<<_HTTP_
HTTP/1.1 404 Not Found\r
Connection: close\r
\r
_HTTP_;
break;
}
fwrite($stream, $errorResponse);
fclose($stream);
unset($readOrigin[(int)$stream]);
continue;
}

if (isset($query['wait']) && $query['wait'] > 0) {
$waiting[(int)$stream] = array(
$stream,
Expand Down

0 comments on commit fe2b1bc

Please sign in to comment.