Mercurial > SimpleWebPresenter
diff StatusCodes.inc @ 74:1d5166aba2c5
Documentation fixes.
codeFromHeader now throws an exception if the header is malformed.
| author | Tom Fredrik Blenning Klaussen <bfg@blenning.no> |
|---|---|
| date | Fri, 12 Oct 2012 01:16:30 +0200 |
| parents | 947d53f95ccd |
| children | 5e76b6feb2ad |
line wrap: on
line diff
--- a/StatusCodes.inc Fri Oct 12 01:06:32 2012 +0200 +++ b/StatusCodes.inc Fri Oct 12 01:16:30 2012 +0200 @@ -294,12 +294,16 @@ } /** + * Extract the numeric code from a header * + * @param $header an http top header */ public static function codeFromHeader($header) { $matches = array(); preg_match('/HTTP\/\S+\s(\d+)/', $header, $matches); + if ($matches->length < 1) + throw new Exception("Not an http header"); $n = $matches[1]; return $n; }
