HttpDataSource class

HTTP/HTTPS data source for loading data from web URLs.

Supports automatic format detection based on URL path extension or Content-Type header. Can handle CSV, JSON, and other formats served over HTTP/HTTPS.

Features

  • Automatic format detection from URL extension
  • Content-Type header parsing
  • Custom headers support
  • Timeout configuration
  • Redirect following
  • Response caching (optional)

Example

// Register the source
DataSourceRegistry.register(HttpDataSource());

// Use through SmartLoader
final df = await DataFrame.read('https://example.com/data.csv');

// With options
final df = await DataFrame.read(
  'https://api.example.com/data.json',
  options: {
    'headers': {'Authorization': 'Bearer token'},
    'timeout': 30,
  },
);
Inheritance

Constructors

HttpDataSource({Client? client})

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scheme String
The URI scheme this data source handles (e.g., 'http', 's3', 'postgresql')
no setteroverride

Methods

canHandle(Uri uri) bool
Checks if this data source can handle the given URI
override
close() → void
Closes the HTTP client
detectFormat(Uri uri, Map<String, String> headers) String
Detects the data format from URI and response headers
inspect(Uri uri) Future<Map<String, dynamic>>
Optional: Returns metadata about the source without reading all data
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
read(Uri uri, Map<String, dynamic> options) Future<DataFrame>
Reads data from the source and returns a DataFrame
override
toString() String
A string representation of this object.
inherited
write(DataFrame df, Uri uri, Map<String, dynamic> options) Future<void>
Writes a DataFrame to the source
override

Operators

operator ==(Object other) bool
The equality operator.
inherited