66license: http://creativecommons.org/publicdomain/zero/1.0/
77*/
88
9- // in $h: HTTP headers as a string
10- // returns: array of rel values as indices to arrays of URLs
9+ /**
10+ * @param string $h HTTP headers
11+ * @return array $rels rel values as indices to arrays of URLs
12+ */
1113function http_rels ($ h ) {
1214 $ h = preg_replace ("/( \r\n| \r)/ " , "\n" , $ h );
1315 $ h = explode ("\n" , preg_replace ("/( \n)[ \t]+/ " , " " , $ h ));
@@ -33,8 +35,8 @@ function http_rels($h) {
3335 foreach ($ relarray as $ rel ) {
3436 $ rel = strtolower (trim ($ rel ));
3537 if ($ rel != '' ) {
36- if (!array_key_exists ($ rel , $ rels )) {
37- $ rels [$ rel ] = array ();
38+ if (!array_key_exists ($ rel , $ rels )) {
39+ $ rels [$ rel ] = array ();
3840 }
3941 if (!in_array ($ href , $ rels [$ rel ])) {
4042 $ rels [$ rel ][] = $ href ;
@@ -48,19 +50,18 @@ function http_rels($h) {
4850 return $ rels ;
4951}
5052
51- // in $url: URL to get HTTP HEAD Link (and effective/x-extended) rels
52- // returns: array of
53- // "status"=> HTTP status code,
54- // "type"=> HTTP Content-Type
55- // "rels" array with http_rels return value
53+ /**
54+ * @param $url URL to get HTTP HEAD Link (and effective/x-extended) rels
55+ * @return array "status"=> HTTP status code, "type"=> HTTP Content-Type, "rels" array with http_rels return value
56+ */
5657function head_http_rels ($ url ) {
57- $ c = curl_init ();
58- curl_setopt ($ c , CURLOPT_RETURNTRANSFER , 1 );
59- curl_setopt ($ c , CURLOPT_URL , $ url );
60- curl_setopt ($ c , CURLOPT_CONNECTTIMEOUT , 2 );
61- curl_setopt ($ c , CURLOPT_TIMEOUT , 4 );
62- curl_setopt ($ c , CURLOPT_USERAGENT , 'head_http_rels function ' );
63- curl_setopt ($ c , CURLOPT_FOLLOWLOCATION , 1 );
58+ $ c = curl_init ();
59+ curl_setopt ($ c , CURLOPT_RETURNTRANSFER , 1 );
60+ curl_setopt ($ c , CURLOPT_URL , $ url );
61+ curl_setopt ($ c , CURLOPT_CONNECTTIMEOUT , 2 );
62+ curl_setopt ($ c , CURLOPT_TIMEOUT , 4 );
63+ curl_setopt ($ c , CURLOPT_USERAGENT , 'head_http_rels function ' );
64+ curl_setopt ($ c , CURLOPT_FOLLOWLOCATION , 1 );
6465 curl_setopt ($ c , CURLOPT_SSL_VERIFYPEER , false );
6566 curl_setopt ($ c , CURLOPT_SSL_VERIFYHOST , false );
6667 curl_setopt ($ c , CURLOPT_HEADER , true );
0 commit comments