When drupal_http_request() follows a redirect, the headers in the second request are mangled. This is a regression from #337783: DX: Array-itize drupal_http_request()'s parameters.

First request:

GET / HTTP/1.0
Host: example.com
User-Agent: Drupal (+http://drupal.org/)
Content-Length: 0

Second request:

GET / HTTP/1.0
Host: Host: example.com
User-Agent: User-Agent: Drupal (+http://drupal.org/)
Content-Length: Content-Length: 0

Also, if the Location header redirects to another site, the Host header of the second request reflects the host of the first request.

CommentFileSizeAuthor
http-redirect-1.patch2.61 KBc960657

Comments

dries’s picture

Status: Needs review » Fixed

Committed to CVS HEAD. Thanks!

andypost’s picture

Issue tags: +Needs backport to D6

Code is the same as d6 so needs backport

c960657’s picture

Issue tags: -Needs backport to D6

I cannot reproduce this in D6.

In D6 the are two arrays containing headers, $headers and $defaults. The one that is being modified, $defaults, is not being passed on recursively in case of a redirect. The problem with HEAD was that only one array was being used.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.