@@ -1599,21 +1599,25 @@ function get_image_versions() {
15991599/**
16001600 * Function to get httpcode or port occupancy info.
16011601 *
1602- * @param string $url url to get info about.
1603- * @param int $port The port to check.
1604- * @param bool $port_info Return port info or httpcode.
1605- * @param mixed $auth Send http auth with passed value if not false.
1602+ * @param string $url url to get info about.
1603+ * @param int $port The port to check.
1604+ * @param bool $port_info Return port info or httpcode.
1605+ * @param mixed $auth Send http auth with passed value if not false.
1606+ * @param bool $resolve_localhost Wether to reolve curl request to localhost or not.
16061607 *
16071608 * @return bool|int port occupied or httpcode.
16081609 */
1609- function get_curl_info ( $ url , $ port = 80 , $ port_info = false , $ auth = false ) {
1610+ function get_curl_info ( $ url , $ port = 80 , $ port_info = false , $ auth = false , $ resolve_localhost = false ) {
16101611
16111612 $ ch = curl_init ( $ url );
16121613 curl_setopt ( $ ch , CURLOPT_HEADER , true );
16131614 curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , 1 );
16141615 curl_setopt ( $ ch , CURLOPT_NOBODY , true );
16151616 curl_setopt ( $ ch , CURLOPT_TIMEOUT , 10 );
16161617 curl_setopt ( $ ch , CURLOPT_PORT , $ port );
1618+ if ( $ resolve_localhost ) {
1619+ curl_setopt ( $ ch , CURLOPT_RESOLVE , [ $ url . ': ' . $ port . ': ' . LOCALHOST_IP ] );
1620+ }
16171621 if ( $ auth ) {
16181622 curl_setopt ( $ ch , CURLOPT_USERPWD , $ auth );
16191623 }
0 commit comments