Opened 3 months ago
Last modified 5 days ago
#23472 new enhancement
Retrieve the first x bytes of a remote file
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.6 |
| Component: | HTTP | Version: | |
| Severity: | normal | Keywords: | has-patch |
| Cc: |
Description
A commonly useful functionality in HTTP clients is to only request the first x bytes of a document, this can be useful for example, when you only need to fetch the first few KB of a image so as to determine it's dimensions from the initial metadata in the file.
At present, we have no way to offer this through WP_HTTP, The attached patch is a first-scratch effort at adding it. No proper unit tests so far, just casual testing which confirms it working.
Patch
- Supports all 3 transports
- Handles streaming-to-file as well
- Doesn't include Headers in the byte count
- Works with Redirects
I'll add some Unit tests for this soon hopefully.
Attachments (1)
Change History (7)
Throwing this in for some soak time, I've renamed the parameter from 'first-x-bytes' to 'limit-response-size' - I'm not entirely sure of what naming scheme to use for this though, the name may change if someone can suggest a better option.

Other things of note