Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
base system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
10 Aug 2008 at 16:30 UTC
Updated:
14 Sep 2010 at 16:17 UTC
Jump to comment: Most recent file
Comments
Comment #1
dries commentedThis kind of subtle patches could really benefit from a test case. It looks like drupal_http_request() is in need for some tests. Care to write some?
Comment #2
damien tournoud commentedThat whole
drupal_http_request()function will probably benefit for a full rewrite to make it both more robust (error and memory management are *so* bad in that function) and more easily extensible. On the feature list, proxy support has been awaited for a long time (#7881: Add support to drupal_http_request() for proxy servers (http not https)).Comment #3
mustafau commentedI was wrong.
$result->redirect_codeis meant to be set to$result->code. I have put an if statement and updated the function documentation. What do you think about the documentation?I will write a test case for drupal_http_request.
Comment #4
damien tournoud commentedIn that case, how could the
$result->codebe unset? Because this is set on the very last line ofdrupal_http_request(), the only case I can think of is a redirect to a bad url (invalid, or relative, for example). In that case, we should:$result->errorand pass a meaningful error message back to the caller.Comment #5
mustafau commentedIn case of redirect to a bad URL
$result->erroris already set. However$result->codeis set to 301, 302 or 307.$result->redirect_codeand$result->datamight not be set.What I mean by "When a redirect happens you can not rely on the status code returned by this function" is this. For example;
aggregator_refresh()supposes that if$result->codeis 200, 301, 302 or 307$result->datashould be set. However I'm seeing "Undefined property: stdClass::$data in aggregator.module on line 608" errors in log messages. The caller ofdrupal_http_request()(in this caseaggregator_refresh()) relies on$result->codeand does not check forisset($result->data)before using$result->data.Comment #6
damien tournoud commentedOk. This is mainly (but not only) a documentation issue.
I suggest we settle on that:
codeis always the result code of the *last* requestredirect_codeis set only when a redirect occured. It is the redirect code in that case (301, 302, 307, etc.)Note that redirect_code is not used anywhere in core (except in our test cases). I also modified
aggregator_refresh(), which is the only place in core that actually cares about redirects.Comment #7
mustafau commentedI'm OK with this. Before setting to RTBC:
- I think we should set redirect_code even if $retry = 0.
- Move,
after hash compare.
- Incorporate patch at http://drupal.org/node/293532#comment-986376
Comment #8
Anonymous (not verified) commentedThe last submitted patch failed testing.
Comment #9
kars-t commentedI am closing this because the patch seems to be realized in the latest D7 version with all the new API stuff that wasn't there as the patch was written.
The documentation was added and the status code is resolved in drupal_http_request().