[wp-trac] [WordPress Trac] #44174: wp_get_http_headers does not return status code or follow redirects

WordPress Trac noreply at wordpress.org
Mon May 21 13:13:02 UTC 2018


#44174: wp_get_http_headers does not return status code or follow redirects
--------------------------+-----------------------------
 Reporter:  tlhackque     |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  HTTP API      |    Version:  4.9.6
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 wp_get_http_headers performs an HTTP HEAD request and returns a simple
 success or failure code.  This function is listed as part of the "HTTP
 API" on https://codex.wordpress.org/Function_Reference.

 If the target resource issues a redirect, it is not followed, nor is the
 specific redirect code returned.  It is possible to check for the Location
 header & follow the redirect manually.  But wp_get_http_headers should, at
 least optionally, process redirects.  It should also return the HTTP
 status code and message.  One way to do this would be the Apache model -
 provide a Status pseudo-header in the response (e.g. 'Status' => '200 OK')

 If a WordPress resource returns a 404 code, the result is 'success' with
 an HTML page suitable for humans - HEAD, of course, simply says content-
 type: text/html.  This is indistinguishable from 200 for the page.

 The underlying wp_safe_remote_head API seems to return the status, but
 it's not returned from wp_get_http_headers.  Note that wp_safe_remote_head
 is not listed on the function reference page, so I assume is not intended
 for public use.

 (If context matters, I'm using it to implement a shortcode in a plugin.)


 I'm leaving this as a "bug" since failure to provide status prevents a
 caller from detecting errors and correctly processing a response.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44174>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list