Make WordPress Core

Opened 6 years ago

Closed 4 years ago

Last modified 4 years ago

#43605 closed enhancement (fixed)

Add HTTP/1.0 emulation to apiRequest()

Reported by: pento's profile pento Owned by: timothyblynjacobs's profile TimothyBlynJacobs
Milestone: 5.6 Priority: normal
Severity: normal Version:
Component: REST API Keywords: good-first-bug has-patch
Focuses: rest-api Cc:


HTTP/1.1 is nice, but the verbs are fairly strictly filtered by a bunch of web application firewalls.

For wider compatibility, we should default to HTTP/1.0, making use of the X-HTTP-Method-Override header.

See for an example shim, and examples of broken sites.

Change History (14)

#1 @pento
6 years ago

It looks like modsec has some interesting rules that block form encoded strings, but don't block JSON encoded strings. So, we should send things as JSON.


#2 @danielbachhuber
6 years ago

When someone puts a patch together for this, it'd be great to have manual testing instructions (because I'm assuming it's not possible to test this in an automated way).

This ticket was mentioned in Slack in #core-restapi by earnjam. View the logs.

6 years ago

#4 @danielbachhuber
6 years ago

  • Owner set to earnjam
  • Status changed from new to assigned

Assigning to @earnjam per today's #core-restapi Slack chat.

#5 @earnjam
6 years ago

It looks like the shim got replaced with the @wordpress/api-fetch package and has the HTTP/1.0 emulation covered as far as Gutenberg is concerned. (see api-fetch/src/middlewares/http-v1.js)

Do we still want to add this to wp.apiRequest() for 5.0? Doesn't seem like Gutenberg needs it anymore.

#6 @danielbachhuber
6 years ago

  • Keywords needs-patch removed
  • Milestone 5.0 deleted
  • Resolution set to maybelater
  • Status changed from assigned to closed

Good find, @earnjam. The shim was removed from Gutenberg in June:

I don't see it necessary to add HTTP/1.0 emulation to wp.apiRequest() for 5.0.

This ticket was mentioned in Slack in #core-js by swissspidy. View the logs.

4 years ago

#8 @TimothyBlynJacobs
4 years ago

  • Milestone set to 5.6
  • Resolution maybelater deleted
  • Status changed from closed to reopened

This is still necessary if people want to use the smaller wp.apiRequest library properly.

#9 @TimothyBlynJacobs
4 years ago

@earnjam are you still interested in working on this ticket now that it is back open?

#10 @earnjam
4 years ago

  • Owner earnjam deleted
  • Status changed from reopened to assigned

I don't think I can commit to it for 5.6. I'll circle back around if I have some time and it is still open.

#11 @TimothyBlynJacobs
4 years ago

  • Keywords good-first-bug added

Ok, thanks @earnjam!

Adding the good-first-bug keyword.

The fix here is if the passed method is POST, PUT, or DELETE to pass that in the X-HTTP-Method-Override header. We then change the method to POST.

This ticket was mentioned in PR #580 on WordPress/wordpress-develop by yakimun.

4 years ago

  • Keywords has-patch added

Added overriding of the PUT and DELETE methods with the POST method in wp.apiRequest library.

Trac ticket:

#13 @TimothyBlynJacobs
4 years ago

  • Owner set to TimothyBlynJacobs
  • Resolution set to fixed
  • Status changed from assigned to closed

In 49133:

REST API: Add HTTP/1.0 emulation to wp.apiRequest().

This allows for making REST API calls with the PUT and DELETE HTTP methods that may be blocked or unsupported by some server configurations.

Props yakimun.
Fixes #43605.

TimothyBJacobs commented on PR #580:

4 years ago

Merged in 9f502ab.

Thanks for the patch @yakimun!

Note: See TracTickets for help on using tickets.