Http: FormatException: Scheme not starting with alphabetic character

Created on 13 Oct 2018  路  2Comments  路  Source: dart-lang/http

I want to send a request to my machine using an ip address... Please take this unnecessary exception out so I can send a request. Thanks.

closed-as-intended

Most helpful comment

This is not an unnecessary exception.
The exception specifically calls out 'scheme' being "non-alphabetic", which is true if you're trying to connect to a raw IP "URI" like '8.8.8.8'.
You can read more about the syntax of URIs, but the point is a valid URI requires at least a scheme and a path. An IP is a path, meaning you're missing a scheme, like 'http'.

What you likely need to do is change your URI to something like 'http://8.8.8.8/example.file'.

Here's an example of something I've verified works:

import 'package:http/http.dart' as http;

main() {
  http.read("http://127.0.0.1:8000/").then(print);
}

All 2 comments

This is not an unnecessary exception.
The exception specifically calls out 'scheme' being "non-alphabetic", which is true if you're trying to connect to a raw IP "URI" like '8.8.8.8'.
You can read more about the syntax of URIs, but the point is a valid URI requires at least a scheme and a path. An IP is a path, meaning you're missing a scheme, like 'http'.

What you likely need to do is change your URI to something like 'http://8.8.8.8/example.file'.

Here's an example of something I've verified works:

import 'package:http/http.dart' as http;

main() {
  http.read("http://127.0.0.1:8000/").then(print);
}

Thanks for this Issue. I have actually wondered about this when I made the same stupid mistake.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

matanlurey picture matanlurey  路  6Comments

Buckstabue picture Buckstabue  路  7Comments

HaiVu5583 picture HaiVu5583  路  3Comments

IrosTheBeggar picture IrosTheBeggar  路  5Comments

Jonas-Sander picture Jonas-Sander  路  6Comments