WordPress.org

Make WordPress Core

Opened 10 months ago

Closed 10 days ago

#26726 closed defect (bug) (fixed)

Limiting response size doesn't work when streaming a file with cURL

Reported by: bradyvercher Owned by: dd32
Milestone: 4.1 Priority: normal
Severity: normal Version: 3.6
Component: HTTP API Keywords:
Focuses: Cc:

Description

The functionality for limiting the response size from an HTTP request was introduced in #23472

However, it doesn't work when stream is set to true and cURL is the transport. I've attached a plugin that'll try to limit the response to 32KB and stream an MP3 to a temporary file. Currently, it downloads the whole file

The attached patch should fix the behavior when using cURL, but I haven't tested the other transports.

Attachments (3)

26726.diff (1.5 KB) - added by bradyvercher 10 months ago.
get-remote-first-bytes.php (625 bytes) - added by bradyvercher 10 months ago.
26726.2.diff (1.5 KB) - added by bradyvercher 10 months ago.

Download all attachments as: .zip

Change History (7)

bradyvercher10 months ago

comment:1 follow-up: dd3210 months ago

$this->bytes_written_total .= $bytes_written; should probably be += but other than that, looks sane to me.

Streams should work as-is already by the looks of it.

bradyvercher10 months ago

comment:2 in reply to: ↑ 1 bradyvercher10 months ago

Replying to dd32:

$this->bytes_written_total .= $bytes_written; should probably be += but other than that, looks sane to me.

Whoops, good catch.

comment:3 dd3210 days ago

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

comment:4 dd3210 days ago

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

In 29968:

HTTP API: Support both the 'limit_response_size' and 'stream' parameters at the same time, allowing a partial file download.
Fixes #26726

Note: See TracTickets for help on using tickets.