WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 6 years ago

Last modified 6 years 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 7 years ago.
get-remote-first-bytes.php (625 bytes) - added by bradyvercher 7 years ago.
26726.2.diff (1.5 KB) - added by bradyvercher 7 years ago.

Download all attachments as: .zip

Change History (8)

@bradyvercher
7 years ago

#1 follow-up: @dd32
7 years 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.

@bradyvercher
7 years ago

#2 in reply to: ↑ 1 @bradyvercher
7 years ago

Replying to dd32:

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

Whoops, good catch.

#3 @dd32
6 years ago

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

#4 @dd32
6 years 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

#5 @DrewAPicture
6 years ago

In 30767:

Fix a typo in the DocBlock for WP_Http_Curl::$bytes_written_total introduced in [29968].

Props kpdesign.
See #26726.

Note: See TracTickets for help on using tickets.