-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Closed
Copy link
Labels
area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.library-_http
Description
Hi,
Issue #49305 introduced additional validation to the content-length header field to ensure it only contains valid digits; however, in practice some web servers seem to right-pad the content-length value with spaces. Attempting to fetch a URL that contains white space fails with a HttpException: Content-Length must contain only digits exception.
Could the content-length field be trimmed before applying the validation or the RegExp altered to handle this white space?
The code below shows two URLs; one fails and the other is successful. The failed URL has additional white space.
import 'dart:io';
void main() async {
final client = HttpClient();
final goodRequest = await client.openUrl('GET', Uri.parse('http://httpstat.us/302'))
..followRedirects = false;
final badRequest = await client.openUrl('GET', Uri.parse('http://mp3s.nashownotes.com/pc20rss.xml'))
..followRedirects = false;
final goodResponse = await goodRequest.close();
print(goodResponse.headers.toString());
final badResponse = await badRequest.close();
/// Never gets here due to trailing spaces in content-length header
print(badResponse.headers.toString());
}The successful URL has no white space in the content-length field:
The failing URL has white-space padding:
- Dart SDK Version: 2.19.2
MerryOscar
Metadata
Metadata
Assignees
Labels
area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.library-_http

