[wp-trac] [WordPress Trac] #14348: If it's a HEAD request, stop after the head!

WordPress Trac wp-trac at lists.automattic.com
Sat Aug 11 13:53:41 UTC 2012


#14348: If it's a HEAD request, stop after the head!
---------------------------------------------+------------------
 Reporter:  mitchoyoshitaka                  |       Owner:
     Type:  enhancement                      |      Status:  new
 Priority:  normal                           |   Milestone:  3.5
Component:  Performance                      |     Version:  3.0
 Severity:  normal                           |  Resolution:
 Keywords:  has-patch 3.5-early 2nd-opinion  |
---------------------------------------------+------------------

Comment (by mitchoyoshitaka):

 kurtpayne, mbijon: I'm really really confused by this approach:

 > add_filter( 'wp_die_ajax_handler', '_scalar_wp_die_handler' );

 a) The filter will only run if we're testing in AJAX mode, but we wouldn't
 want this to only be testable as an AJAX request. This should be for all
 kinds of requests.

 b) When `wp_die()` runs and hits the filter (assuming this is in AJAX
 mode) it'll run `_scalar_wp_die_handler` which will immediately `die`. I
 don't think this is what's intended in order to make this testable.

 Moreover, by calling `wp_die()` instead of `exit()`, it will by default
 print out the standard `wp_die()` message HTML (and may even try to return
 status 500), which is precisely *not* what we want to do when dying early
 on a `HEAD` request. If you want to use `wp_die()` for some reason, you'd
 need to modify `wp_die()` to set a handler precisely for this case or
 somesuch.

 In conclusion: I think using `exit()` is the right approach. You can use
 14348-5.diff and hook against `exit_on_http_head` for tests.
 `exit_on_http_head` will only be triggered if you're testing a `HEAD`
 request. You could make sure no output is queued at that point and that
 the return value is set up to be true.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/14348#comment:37>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list