Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#9 | bootstrap.inc_1.diff | 2.12 KB | drumm |
#6 | bootstrap.inc_0.diff | 817 bytes | drumm |
#1 | http.patch | 1.64 KB | killes@www.drop.org |
Comments
Comment #1
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedOk, 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.
Comment #2
ax CreditAttribution: ax commentedthis 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.
Comment #3
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedWhile I agree that conf_init could need a fix, too, there is no reason to send the default ports.
Comment #4
Dries CreditAttribution: Dries commentedI 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/.
Comment #5
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedI'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.
Comment #6
drummHere is a one line patch. Conceptually
subdomain.server.tld:80
becomes80.subdomain.server.tld
internally. 80 is the first thing to be lopped off in the search for configuration files.Comment #7
Steven CreditAttribution: Steven commentedI like it. It also has the side effect that you can make port-agnostic drupal sites with it.
Committed to HEAD, updated INSTALL.txt.
Comment #8
Dries CreditAttribution: Dries commentedI'm not sure I like this approach. I think it's hairy, rather than nifty. The code is not documented either.
Comment #9
drummHere is some documentation.
Comment #10
Dries CreditAttribution: Dries commentedI still don't like it but committed the patch nonetheless.
Comment #11
drummSetting to fixed.
I'm open to hearing other implementation ideas and re-opening, but I do think it will work well now.
Comment #12
(not verified) CreditAttribution: commented