Warning: get_headers() This function may only be used against URLs in

Asked
Active3 hr before
Viewed126 times

8 Answers

warningfunction
90%

Meta Stack Overflow , Stack Overflow Public questions & answers , Stack Overflow help chat ,When you un-supress the warning from get_headers do you get the warning that you can only use get_headers on urls?

When you un-supress the warning from get_headers do you get the warning that you can only use get_headers on urls?

Warning: get_headers(): This
function may only be used against URLs
load more v
88%

This issue came to light after having found the cause of #4488. In the ElasticSearch file ingestion process, a call is made to the get_headers() function in the FileHandler class (here) using a URL that is based on $wgServer.,This causes the get_headers() function to return false, which causes the file ingestion to fail. This should not happen, since a protocol-relative $wgServer should be allowed.,According to the documentation of $wgServer, MediaWiki supports setting it to a protocol-relative URL (e.g., //www.mediawiki.org). Doing this however causes the previously mentioned call to get_header() to fail, since it is unable to recognize the given URL as a valid URL:, Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

PHP Warning: get_headers(): This
function may only be used against URLs
load more v
72%

@howdytom The get_headers function call was removed from the latest dev version of httprl some time ago. setting this back to closed.,This patch prevents double slashes from happening & makes sure get_headers will work with URLs. Still would like info on what echo _httprl_build_drupal_root(); print_r($_SERVER); outputs.,get_headers(): http:// wrapper is disabled in the server configuration by allow_url_fopen=0 httprl.module:365 [warning],Could you tell me what echo _httprl_build_drupal_root(); print_r($_SERVER); gives you? Wondering why it's not returning a valid URL. Change comes from #1878454-52: When does something happen? onwards.

Could you tell me what echo _httprl_build_drupal_root(); print_r($_SERVER); gives you? Wondering why it's not returning a valid URL. Change comes from #1878454-52: When does something happen? onwards.

echo _httprl_build_drupal_root();
print_r($_SERVER);
load more v
65%

I have a sub domain, and the get_headers(‘header.php’); code is returning the following error:,Ugh… get_header() (not headers) is what I needed.,Warning: get_headers(): This function may only be used against URLs in /home/elepha33/public_html/vehicle/wp-content/themes/EESVehicle/index.php on line 12,I have the header.php file in the EESVehicle folder. What am I doing wrong?

index.php – partial

<?php # Script 3.4 - index.php
/**
 * @package WordPresslink https://codex.wordpress.org/Template_Hierarchy *
 * @subpackage EES Vehicle
 */

get_headers('header.php');

?>

<div id="widgetsContainer">
   <div id='jqxWidget' style="font-size: 13px; font-family: Verdana; float: left;">
      <!--<div id="jqxgrid"></div>  -->
   </div>
</div>

<div id="header">
   <h1>ESS Vehicle</h1>
</div>
75%

Warning: get_headers() [function.get-headers]: URL file-access is disabled , the server has upgraded from PHP 4 to a newer version. As a result, the allow_url_fopen is set to OFF, which is responsible for disallowing include files to use absolute file paths.,Documentation for Joomla ExtensionsAllVideosFrontpage SlideshowSimple Image GallerySimple Image Gallery ProSocialConnect,Unfortunately, the latest update for Kunena has seemingly broken all code snippets (old and new) in the forum.

the server has upgraded from PHP 4 to a newer version.As a result, the allow_url_fopen is set to OFF, which is responsible
for disallowing include files to use absolute file paths.

Does the module need allow_url_fopen to be set to on ? If so, is there a workaround, as this seems to be a security risk...

   Or am I barking up the wrong tree ? : )

Any help would be appreciated.
load more v
40%

I get the following Warning: get_headers(): This function may only be used against URLs for both code snippets below.,I have the following issues when trying to get the header using the get_headers() function.,These lines gives you errors because you have to put urls in get_headers function not file paths.,And below line loops because most probably you're visiting the same url you are giving to get_headers.

I get the following Warning: get_headers(): This function may only be used against URLs for both code snippets below.

get_headers("file:///C:/wamp64/www/site/index2.php");
get_headers("C:/wamp64/www/site/index2.php");

And this one just loops forever

get_headers("http://localhost/site/index2.php");
load more v
22%

When you un-supress the warning from get_headers do you get the warning that you can only use get_headers on urls?,http://us3.php.net/get_headers,Why is this happening and what is proper way to get headers from https page without errors (without curl). Also, when I try on some other https site everything is ok,And this is error I'm getting:

This is my code

$url = 'http://www.wikipedia.com'; // URL WITH HTTP
$hurl = str_replace("http", "https", $url); // URL WITH HTTPS

$urlheads = get_headers($url, 1);
$surlheads = get_headers($hurl, 1);
$urlx = false;
$surlx = false;

foreach($urlheads as $name => $value) {
   if ($name === 'Location') {
      $urlx = $value;
   } else {

   }
}
print_r($urlx);

And this is error I'm getting:

Warning: get_headers(): Peer certificate CN = `*.wikipedia.org' did not match expected CN=`
www.wikipedia.com ' in....

Warning: get_headers(): Failed to enable crypto in ....

Warning: get_headers(https: //www.wikipedia.com): failed to open stream:     operation failed in .....
      Array([0] => http: //www.wikipedia.org/ [1] => https://www.wikipedia.org/ )
load more v
60%

get_headers() returns an array with the headers sent by the server in response to a HTTP request. ,get_headers — Fetches all the headers sent by the server in response to an HTTP request, Returns an indexed or associative array with the headers, or false on failure. , If the optional associative parameter is set to true, get_headers() parses the response and sets the array's keys.

Array
   (
      [0] => HTTP / 1.1 200 OK[1] => Date: Sat, 29 May 2004 12: 28: 13 GMT[2] => Server: Apache / 1.3 .27(Unix)(Red - Hat / Linux)[3] => Last - Modified: Wed, 08 Jan 2003 23: 11: 55 GMT[4] => ETag: "3f80f-1b6-3e1cb03b" [5] => Accept - Ranges: bytes[6] => Content - Length: 438[7] => Connection: close[8] => Content - Type: text / html
   )

Array
   (
      [0] => HTTP / 1.1 200 OK[Date] => Sat, 29 May 2004 12: 28: 14 GMT[Server] => Apache / 1.3 .27(Unix)(Red - Hat / Linux)[Last - Modified] => Wed, 08 Jan 2003 23: 11: 55 GMT[ETag] => "3f80f-1b6-3e1cb03b" [Accept - Ranges] => bytes[Content - Length] => 438[Connection] => close[Content - Type] => text / html
   )

Other "warning-function" queries related to "Warning: get_headers() This function may only be used against URLs in"