Make WordPress Core

Opened 22 months ago

Closed 22 months ago

Last modified 22 months ago

#56213 closed defect (bug) (invalid)

Type of the response code and message in wp_remote_request()

Reported by: malthert's profile malthert Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: HTTP API Keywords:
Focuses: Cc:

Description

https://developer.wordpress.org/reference/functions/wp_remote_request/

'code' (int|false) HTTP response code.
'message' (string|false) HTTP response message.

code/message can never be false though?

Change History (4)

#1 @martin.krcho
22 months ago

  • Keywords reporter-feedback added

Hey @malthert, thank you for creating the ticket.

Both code and message can actually be set to false. This is happening for example in the following part of function WP_Http::request() that is called by wp_remote_request().
https://github.com/WordPress/wordpress-develop/blob/6.0/src/wp-includes/class-wp-http.php#L424-L435

3rd party developers can also use the filter http_response to tweak the returned array (including the code and message fields).

#2 @malthert
22 months ago

  • Resolution set to invalid
  • Status changed from new to closed

Oh thanks, missed that.

#3 @martin.krcho
22 months ago

No problem. Thanks for closing the ticket yourself.

#4 @SergeyBiryukov
22 months ago

  • Keywords reporter-feedback removed
  • Milestone Awaiting Review deleted
  • Summary changed from wp_remote_request to Type of the response code and message in wp_remote_request()
Note: See TracTickets for help on using tickets.