forked from GNUsocial/gnu-social
		
	Allow a quickHead request, will only return headers
This commit is contained in:
		@@ -206,6 +206,29 @@ class HTTPClient extends HTTP_Request2
 | 
			
		||||
        return $data;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * If you want an Accept header, put it in $headers
 | 
			
		||||
     */
 | 
			
		||||
    public static function quickHead($url, array $params=array(), array $headers=array())
 | 
			
		||||
    {
 | 
			
		||||
        if (!empty($params)) {
 | 
			
		||||
            $params = http_build_query($params, null, '&');
 | 
			
		||||
            if (strpos($url, '?') === false) {
 | 
			
		||||
                $url .= '?' . $params;
 | 
			
		||||
            } else {
 | 
			
		||||
                $url .= '&' . $params;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $client = new HTTPClient();
 | 
			
		||||
        $response = $client->head($url, $headers);
 | 
			
		||||
        if (!$response->isOk()) {
 | 
			
		||||
            // TRANS: Exception. %s is the URL we tried to GET.
 | 
			
		||||
            throw new Exception(sprintf(_m('Could not GET URL %s.'), $url), $response->getStatus());
 | 
			
		||||
        }
 | 
			
		||||
        return $response->getHeader();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Convenience function to run a GET request.
 | 
			
		||||
     *
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user