Opened 13 years ago
Closed 13 years ago
#20222 closed defect (bug) (fixed)
No way to force local HTTP requests through proxy
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.5 | Priority: | normal |
Severity: | normal | Version: | |
Component: | HTTP API | Keywords: | has-patch |
Focuses: | Cc: |
Description
The HTTP API will send requests through a proxy server if the WP_PROXY_HOST
and WP_PROXY_POST
constants are defined.
If the host of an HTTP request is the same as the current host (as is the case when a WP-cron request is spawned) then the request won't be sent through the proxy and there is no way to override this (see trunk/wp-includes/class-http.php@20171#L1346).
I use a proxy for logging and debugging HTTP requests and it's not possible for me to send local HTTP requests through the proxy.
Attachments (3)
Change History (13)
#4
@
13 years ago
I chose to use another constant just so it was inline with the WP_PROXY_HOST
and WP_PROXY_PORT
constants. It's the sort of setting which will be done on a per-site basis and it's easier just to drop that constant into wp-config.php
rather than using a filter.
#5
@
13 years ago
Constants box us in. I wish we'd use fewer of them. You can't, for instance, proxy some local requests, but not all, just using a constant.
#6
@
13 years ago
- Cc kpayne@… added
20222-2.patch uses a callback.
You can determine per URL like so:
add_filter( 'proxy_local_urls_callback', function() { return 'check_url'; }); function check_url( $url ) { return true; // your logic here }
Or you can enable all proxying for all local URLs
add_filter( 'proxy_local_urls_callback', '__return_true' );
Default behavior is backwards compatible.
#7
follow-up:
↓ 8
@
13 years ago
@kurtpayne: Is there any reason you've re-invented the wheel so to say here?
Does that approach have any advatages over this patch? (which I'm about to add)
#8
in reply to:
↑ 7
@
13 years ago
Replying to dd32:
@kurtpayne: Is there any reason you've re-invented the wheel so to say here?
No sir. Just lack of practice. :-)
Does that approach have any advatages over this patch? (which I'm about to add)
Nope, your patch looks good. Thanks.
Patch. The HTTP API can now be told to use the proxy (if one's defined) for local requests by using the following code in your
wp-config.php
file: