Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#10783 closed task (blessed) (fixed)

WordPress's GET function is sending a content-length of 0

Reported by: noel Owned by: DD32
Milestone: 2.9 Priority: normal
Severity: normal Version: 2.8.4
Component: HTTP API Keywords: press this, http
Focuses: Cc:


Sending a content length of 0 with the GET request makes the request fail on some servers.

Sending a blank response of null or false works fine.

The included patch works well (and is necessary for Press This to function correctly under certain instances).

Attachments (2)

http.php.patch (534 bytes) - added by noel 6 years ago.
http.php patch
http.10783.diff (2.3 KB) - added by jacobsantos 6 years ago.
Actual fix for POST and PUT

Download all attachments as: .zip

Change History (8)

@noel6 years ago

http.php patch

comment:1 @ryan6 years ago

  • Milestone changed from Unassigned to 2.9
  • Resolution set to fixed
  • Status changed from new to closed

comment:2 @jacobsantos6 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

A null value basically just removes that value from the array and doing so defeats the entire purpose of why it was put there in the first place.

The correct solution will be to test for POST if there isn't a body and set it. If there is a body, then set it.

The reason it was put there was become some servers require it to be there. So while it works for yours, it will not work for another server. A compromise or filter has to be made in order to ensure that it continues to work or allow for it to be made to work based on configurations.

comment:3 follow-up: @azaozz6 years ago

This only affects GET requests, perhaps the workaround is to always send something to the server when doing a GET, like a single white space, etc. Then Content-Length will be 1.

comment:4 in reply to: ↑ 3 @azaozz6 years ago

Meant to say "always send something to the server when doing a POST" above.

Related bug in PEAR http://pear.php.net/bugs/bug.php?id=14740 was fixed by setting Content-Length only for POST and PUT requests.

@jacobsantos6 years ago

Actual fix for POST and PUT

comment:5 @jacobsantos6 years ago

New patch should correct fix problem.

comment:6 @ryan6 years ago

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

(In [11937]) Fix content length setup. Props jacobsantos. fixes #10783

Note: See TracTickets for help on using tickets.