Try this:

$node = drupal_http_request('http://drupal.org/node/320');

I do not get the node I want, but only a "cannot connect to database" error. I recall getting the same error with wget. I guess some of the sent headers are wrong or insufficient.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

killes@www.drop.org’s picture

Assigned: Unassigned » killes@www.drop.org
Category: support » bug
Status: Active » Needs review
FileSize
1.64 KB

Ok, I investigated that the problem is that drupal_http_request insists in sending the port (even if not specified) and conf_init() cannot find the appropriate configuration file.

There is a comment in drupal_http_request:

// RFC 2616: "non-standard ports MUST, default ports MAY be included". We always add it.

I propose not adding it if it is the default port, we should be able to retrieve our own pages, after all.

ax’s picture

Status: Needs review » Needs work

this doesn't fix the problem. "Host: drupal.org:80" is a valid host header that could be emitted by any other client (wget :)). the bug is in conf_init() and should be fixed there.

i don't mind not sending the 80, though.

killes@www.drop.org’s picture

Status: Needs work » Reviewed & tested by the community

While I agree that conf_init could need a fix, too, there is no reason to send the default ports.

Dries’s picture

I agree with Ax. We should fix this by ignoring port numbers in conf_init(). Not ignoring port numbers is asking for trouble; just try http://drupal.org:80/.

killes@www.drop.org’s picture

Assigned: killes@www.drop.org » Unassigned

I've had a look at conf_init and find it quite complicated and not worth my ime currently. Please commit the current patch, it does not hurt at all and there is no reason to send default ports. other webbrowsers don't do it as well.

drumm’s picture

Assigned: Unassigned » drumm
Status: Reviewed & tested by the community » Needs review
FileSize
817 bytes

Here is a one line patch. Conceptually subdomain.server.tld:80 becomes 80.subdomain.server.tld internally. 80 is the first thing to be lopped off in the search for configuration files.

Steven’s picture

Status: Needs review » Fixed

I like it. It also has the side effect that you can make port-agnostic drupal sites with it.

Committed to HEAD, updated INSTALL.txt.

Dries’s picture

I'm not sure I like this approach. I think it's hairy, rather than nifty. The code is not documented either.

drumm’s picture

Status: Fixed » Reviewed & tested by the community
FileSize
2.12 KB

Here is some documentation.

Dries’s picture

I still don't like it but committed the patch nonetheless.

drumm’s picture

Status: Reviewed & tested by the community » Fixed

Setting to fixed.

I'm open to hearing other implementation ideas and re-opening, but I do think it will work well now.

Anonymous’s picture

Status: Fixed » Closed (fixed)