WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 5 years ago

#10416 closed enhancement (wontfix)

Create filter and or constant for forcing use of a specific http transport

Reported by: sivel Owned by: dd32
Milestone: Priority: normal
Severity: normal Version: 2.8.1
Component: HTTP API Keywords:
Focuses: Cc:

Description

While you can disable all of the transports you do not want to use there should be a constant and/or filter that allows you to specify the http transport you want to use. Perhaps 2, one for GET and one for POST.

This would provide similar functionality to the file system methods where you can set a constant or filter to specify which one to force.

Change History (13)

comment:1 @Denis-de-Bernardy6 years ago

isn't the core control plugin good enough for this?

comment:2 follow-up: @sivel6 years ago

No, for several reasons.

  1. That plugin does the same thing I mentioned, disabling all transports except for the one you want to use by means of filtering.
  2. Why would I want to use a plugin when a single define('WP_HTTP_TRANSPORT', 'fsockopen'); could be used, not to mention I am currently doing the same that that plugin does.
  3. In my current specific case I am checking to see if safe_mode and open_basedir are set and if they are I want to force use of fsockopen. However, to do this you have to run 4 filters to disable all of the other transports rather than being able to do one define or one filter to force use of a specific transport.
  4. Lets say for some reason the test for a specific transport returns false that it cannot be used but I want to force it to use that transport anyway. There is currently no way around this.

comment:3 in reply to: ↑ 2 @Denis-de-Bernardy6 years ago

Replying to sivel:

  1. In my current specific case I am checking to see if safe_mode and open_basedir are set and if they are I want to force use of fsockopen. However, to do this you have to run 4 filters to disable all of the other transports rather than being able to do one define or one filter to force use of a specific transport.

This is one area where, imo WP should be fixed. I've been playing with transports and filesystems for most of the day, and the concluding points are:

  • FTP Filesystem times out, and is needing a longer timeout, perhaps through the use of ftp_set_option($wp_filesystem->link, FTP_TIMEOUT_SEC, 300); -- see #10407
  • curl is a memory hog, and might need an ini_set() call to increase the memory limit when used
  • Re your particular problem, it would make more sense to just enforce it in core imo
  1. Lets say for some reason the test for a specific transport returns false that it cannot be used but I want to force it to use that transport anyway. There is currently no way around this.

very true. but again, if it returns false and still works, we should fix the detection code in core.

comment:4 @sivel6 years ago

Just to cross reference 2 other tickets:
#10417
#10418

comment:5 @dd326 years ago

a -1 from me.

The transports need to be fixed if there are bugs. Report the bugs so that something can be done about them.

(One of the bugs: #10417 - safemode and redirects)

comment:6 @azaozz6 years ago

-1 from me too in the current form. Perhaps in some cases one transport works better than another, so having a "preferred transport" filter would be better solution.

comment:7 @dd326 years ago

so having a "preferred transport" filter would be better solution.

A filter on the order would actually accomplish both parties here..

If we keep the filter named to enforce that it should be used to re-order the list, then that'll prevent abuse by most developers.. But it would also allow for someone to return mearly 1 transport...

I'm still -1 though, I'd rather help others who might end up in the same server circumstances than help a developer or too.

comment:8 @azaozz6 years ago

  • Milestone changed from 2.9 to Future Release

No patch, no consensus...

comment:9 @dd326 years ago

  • Keywords 2nd-opinion dev-feedback added

Any feedback from core devs?

A filter could be added to the postTransports and getTransports Working and non-blocking arrays.. But i dont think theres much of a need for it still IMHO.

comment:10 @hakre6 years ago

I made that with a plugin for testings in another ticket (#11499):

http://core.trac.wordpress.org/attachment/ticket/11499/11499-curlforce.php

that plugin enforces the use of CURL methods which were not the first option on my server. Maybe it's of use.

comment:11 @Denis-de-Bernardy5 years ago

I'm still getting some PCLZIP_ERR_BAD_FORMAT(-10) issues. though only with the Streams and fopen() transports. Still investigating...

comment:12 @Denis-de-Bernardy5 years ago

Nailed it down to cookies now being properly sent in those two transports. I'll open a separate ticket.

comment:13 @sivel5 years ago

  • Keywords 2nd-opinion dev-feedback removed
  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Seems to not be any need for this. Marking as wontfix.

Note: See TracTickets for help on using tickets.