comparison 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
comparison
equal deleted inserted replaced
73:947d53f95ccd 74:1d5166aba2c5
292 && // and not 304 NOT MODIFIED 292 && // and not 304 NOT MODIFIED
293 $code != self::HTTP_NOT_MODIFIED; 293 $code != self::HTTP_NOT_MODIFIED;
294 } 294 }
295 295
296 /** 296 /**
297 * 297 * Extract the numeric code from a header
298 *
299 * @param $header an http top header
298 */ 300 */
299 public static function codeFromHeader($header) 301 public static function codeFromHeader($header)
300 { 302 {
301 $matches = array(); 303 $matches = array();
302 preg_match('/HTTP\/\S+\s(\d+)/', $header, $matches); 304 preg_match('/HTTP\/\S+\s(\d+)/', $header, $matches);
305 if ($matches->length < 1)
306 throw new Exception("Not an http header");
303 $n = $matches[1]; 307 $n = $matches[1];
304 return $n; 308 return $n;
305 } 309 }
306 } 310 }
307 ?> 311 ?>