thekid/rfc — Issue #180: RFC 0180: UrlInputStream
Author: thekid
Created: 2011-10-09 15:37:51+00:00
State: open

Scope of Change
====
A new class `io.streams.UrlInputStream` will be created. This class
will serve as a factory for other streams depending on the protocol passed
in.

Rationale
====
Easy and unified URL handling.

Functionality
====

Example
----
This has to be implemented in user code wanting to accept URLs as input
and then read from them using streams:

```php
getScheme()) {
case 'file': {
return new FileInputStream(new File($url->getPath()));
}

case 'http': case 'https': {
$c= new HttpConnection($url);
return new HttpInputStream($c->get($url->getPath(), $url->getParams()));
}

case 'ftp': {
$c= new FtpConnection($url);
return $c->connect()->rootDir()->getFile($url->getPath())->getInputStream();
}

default: {
throw new IllegalArgumentException('Cannot stream for protocol '.$url->getScheme());
}
}
}
?>
```

New API
----
The new class will include the above factory sourcecode:

```php

```

Security considerations
====
None.

Speed impact
====
None.

Dependencies
====
None.

Related documents
====
None.

Comments
====