Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#18732 closed enhancement (fixed)

Pass request arguments to the http_api_debug hook

Reported by: johnbillion's profile johnbillion Owned by: dd32's profile dd32
Milestone: 3.3 Priority: normal
Severity: normal Version: 3.3
Component: HTTP API Keywords: has-patch
Focuses: Cc:

Description

In the HTTP API there's an http_api_debug hook but it doesn't get passed the request arguments. Be nice to get this in to aid a debugging plugin of mine.

Attachments (1)

18732.patch (487 bytes) - added by johnbillion 14 years ago.

Download all attachments as: .zip

Change History (8)

@johnbillion
14 years ago

#1 @johnbillion
14 years ago

  • Keywords has-patch added

Patch.

Pretty please for 3.3?

#2 follow-up: @dd32
14 years ago

  • Milestone changed from Awaiting Review to 3.3
  • Owner set to dd32
  • Status changed from new to accepted

Sounds good to me, there's the http_request_args, pre_http_request and http_response filters available as well, they're useful to catch the start of the request on (and end of a successful request).

If passing extra debug info is of use to plugins, I say do it. I'm curious however, What's the use-case for the plugin?

#3 in reply to: ↑ 2 @johnbillion
14 years ago

Replying to dd32:

I'm curious however, What's the use-case for the plugin?

The plugin logs HTTP request arguments using http_request_args and the corresponding response using http_response. In order to log the transport, it uses the http_api_debug hook, but this hook doesn't get passed the args so it can't be matched up to the request it belongs to.

#4 follow-up: @dd32
14 years ago

In order to log the transport, it uses the http_api_debug hook, but this hook doesn't get passed the args so it can't be matched up to the request it belongs to.

Thought as much, The way I did it in Core Control was to look at the start, and realise that only one request can take place at a time therefor, the next call of the debug hook is the result for it. That being said, I'll throw the patch here in

#5 in reply to: ↑ 4 @johnbillion
14 years ago

Replying to dd32:

only one request can take place at a time therefor, the next call of the debug hook is the result for it.

Yeah that's correct for the debug hook, but not so for the response hook, which doesn't get fired if the request returns a WP_Error. If a page performs two requests and the first one fails, the first response that fires is for the second request. To account for this my plugin gives each request a hash and adds it to the request args, which can then be used to identify a request and log the error in the dubug hook, or the response in the response hook.

#6 @johnbillion
14 years ago

And in case you're wondering why I don't just log the responses on the debug hook, it's because an HTTP request caching plugin I use adds some cache data to the response on the response hook, which I also log by hooking onto the response hook with a late priority. (I do like to make things complicated for myself.)

#7 @dd32
14 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In [18805]:

Pass $args and $url to the http_api_debug action to improve debugging. Props johnbillion. Fixes #18732

Note: See TracTickets for help on using tickets.