Occasionally, I see

Notice: Undefined offset: 1 in drupal_http_request() (line 984 of includes/common.inc).
Notice: Undefined offset: 1 in _drupal_parse_response_status() (line 1113 of includes/common.inc).

from cron, and I've tracked this down to requests made by update.module, such as

http://updates.drupal.org/release-history/security_review/7.x?site_key=Hy1qd02i3Wlx5c3ifmLj18Ex6e9Khk6rJvhEDWcdY-A&version=7.x-1.0&list=security_review

Indeed, I can sometimes get these notices also by clicking on the Check Manually link on admin/modules/update, and that page will show "Failed to get available update data for one project.", not always for the same project though.

What's happening is that $response is empty in line 984:

  list($response, $result->data) = preg_split("/\r\n\r\n|\n\n|\r\r/", $response, 2);

This is a special case that requires separate treatment, and since even a d.o site can return an empty $response, it's not an obscure case.

Note: This error has been reported multiple times on d.o against various projects, but it is NOT a duplicate of #205969: drupal_http_request() assumes presence of Reason-Phrase in response Status-Line.

CommentFileSizeAuthor
#1 2536372-empty-http-repsonse-1.patch977 bytesberliner

Comments

berliner’s picture

Version: 7.38 » 7.54
StatusFileSize
new977 bytes

I'm seeing this too, while debugging update fetch problems like #512218: Checking for available modules fails for most of the modules on some D7 projects.

Attached is a pretty naive patch that removes the notices by checking for an empty response string. If the response is empty, an error code is set and further processing of the response is stopped. Basically the same behaviour as for timeouts.

This patch together with an increase of the update_max_fetch_attempts variable, seems to resolve my update fetch issues.

berliner’s picture

Status: Active » Needs review

Let's see what the testbot thinks.

salvis’s picture

#1 looks good, but we need an assessment of D8 before we can hope to move forward.

ownage’s picture

I know like 1.5 years have passed but I've encountered these two notices, present on every page load (including the admin theme), and the patch in #1 works wonderfully.

Notice: Undefined offset: 1 in _drupal_parse_response_status() (line 1128 of \includes\common.inc).
Notice: Undefined offset: 1 in drupal_http_request() (line 994 of \includes\common.inc).

But my n00b questions, please respond if you know the answers:

1) Does this patch merely suppress a deeper underlying issue, or should I not worry about that?
2) Does this patch have any chance of being committed to the new releases or will I have to keep hacking Core?

I will be of as much help as needed to help anyone troubleshoot this. Thank you.

darkodev’s picture

We are also seeing these errors for empty $response on link_checker cron runs.

The link being checked exists https://www.nserc-crsng.gc.ca/Students-Etudiants/CGSHarmonization-Harmon...

The response headers are:

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/html
Server: Microsoft-IIS/8.5
X-Powered-By: ASP.NET
Date: Mon, 18 Nov 2019 17:34:02 GMT
Cteonnt-Length: 18642
Strict-Transport-Security: max-age=31536000
Content-Encoding: gzip
Content-Length: 5478

Version: 7.54 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

Status: Needs review » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.