pkg/http_server: move to multi-lib layout
Dependencies between features are now crystal clear R=sgjesse@google.com Review URL: https://codereview.chromium.org//756493002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41936 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
# 0.9.5+1
|
||||
|
||||
* Updated the layout of package contents.
|
||||
|
||||
# 0.9.5
|
||||
|
||||
* Removed the decoding of HTML entity values (in the form &#xxxxx;) for
|
||||
|
||||
@@ -1,19 +1,12 @@
|
||||
# http_server
|
||||
A set of high-level classes that, together with
|
||||
`HttpServer`, makes is easier to serve web content.
|
||||
|
||||
This package contains a set of high-level classes that, together with
|
||||
HttpServer, makes is easy to provide content through HTTP servers.
|
||||
|
||||
**NOTE:** This package currently only works for
|
||||
server-side or command-line Dart applications. In other words, if the app
|
||||
imports `dart:io`, it can use this package.
|
||||
|
||||
## Using
|
||||
|
||||
Please see the [API docs][docs] for explanations and examples.
|
||||
**NOTE:** This package only works for server-side or command-line Dart
|
||||
applications. In other words, if the app imports `dart:io`, it can use this
|
||||
package.
|
||||
|
||||
## Filing issues
|
||||
|
||||
Please file issues for the http package at [http://dartbug.com/new][bugs].
|
||||
File issues for the `http_server` package at [http://dartbug.com/new][bugs].
|
||||
|
||||
[bugs]: http://dartbug.com/new
|
||||
[docs]: https://api.dartlang.org/docs/channels/stable/latest/http_server.html
|
||||
@@ -26,11 +26,11 @@
|
||||
* import 'dart:io';
|
||||
* import 'dart:async';
|
||||
* import 'package:http_server/http_server.dart';
|
||||
*
|
||||
*
|
||||
* void main() {
|
||||
* var staticFiles = new VirtualDirectory('.')
|
||||
* ..allowDirectoryListing = true;
|
||||
*
|
||||
*
|
||||
* runZoned(() {
|
||||
* HttpServer.bind('0.0.0.0', 7777).then((server) {
|
||||
* print('Server running');
|
||||
@@ -41,25 +41,25 @@
|
||||
* }
|
||||
*
|
||||
* ## Virtual directory
|
||||
*
|
||||
*
|
||||
* The [VirtualDirectory] class makes it easy to serve static content
|
||||
* from the file system. It supports:
|
||||
*
|
||||
*
|
||||
* * Range-based requests.
|
||||
* * If-Modified-Since based caching.
|
||||
* * Automatic GZip-compression of content.
|
||||
* * Following symlinks, either throughout the system or inside
|
||||
* a jailed root.
|
||||
* * Directory listing.
|
||||
*
|
||||
*
|
||||
* See [VirtualDirectory] for more information.
|
||||
*
|
||||
*
|
||||
* ## Virtual host
|
||||
*
|
||||
*
|
||||
* The [VirtualHost] class helps to serve multiple hosts on the same
|
||||
* address, by using the `Host` field of the incoming requests. It also
|
||||
* works with wildcards for sub-domains.
|
||||
*
|
||||
*
|
||||
* var virtualHost = new VirtualHost(server);
|
||||
* // Filter out on a specific host
|
||||
* var stream1 = virtualServer.addHost('static.myserver.com');
|
||||
@@ -67,24 +67,14 @@
|
||||
* var stream2 = virtualServer.addHost('*.myserver.com');
|
||||
* // Requets not matching any hosts.
|
||||
* var stream3 = virtualServer.unhandled;
|
||||
*
|
||||
*
|
||||
* See [VirtualHost] for more information.
|
||||
*
|
||||
* [pub]: http://pub.dartlang.org/packages/http_server
|
||||
*/
|
||||
library http_server;
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:mime/mime.dart';
|
||||
import "package:path/path.dart";
|
||||
|
||||
part 'src/http_body.dart';
|
||||
part 'src/http_body_impl.dart';
|
||||
part 'src/http_multipart_form_data.dart';
|
||||
part 'src/http_multipart_form_data_impl.dart';
|
||||
part 'src/virtual_directory.dart';
|
||||
part 'src/virtual_host.dart';
|
||||
|
||||
export 'src/http_body.dart';
|
||||
export 'src/http_multipart_form_data.dart';
|
||||
export 'src/virtual_directory.dart';
|
||||
export 'src/virtual_host.dart';
|
||||
|
||||
@@ -2,8 +2,13 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of http_server;
|
||||
library http_server.http_body;
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'http_body_impl.dart';
|
||||
|
||||
/**
|
||||
* [HttpBodyHandler] is a helper class for processing and collecting
|
||||
@@ -104,7 +109,7 @@ class HttpBodyHandler
|
||||
* for more information on `multipart/form-data`.
|
||||
*/
|
||||
HttpBodyHandler({Encoding defaultEncoding: UTF8})
|
||||
: _transformer = new _HttpBodyHandlerTransformer(defaultEncoding);
|
||||
: _transformer = new HttpBodyHandlerTransformer(defaultEncoding);
|
||||
|
||||
/**
|
||||
* Process and parse an incoming [HttpRequest]. The returned [HttpRequestBody]
|
||||
@@ -115,7 +120,7 @@ class HttpBodyHandler
|
||||
static Future<HttpRequestBody> processRequest(
|
||||
HttpRequest request,
|
||||
{Encoding defaultEncoding: UTF8}) {
|
||||
return _HttpBodyHandler.processRequest(request, defaultEncoding);
|
||||
return HttpBodyHandlerImpl.processRequest(request, defaultEncoding);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,7 +131,7 @@ class HttpBodyHandler
|
||||
static Future<HttpClientResponseBody> processResponse(
|
||||
HttpClientResponse response,
|
||||
{Encoding defaultEncoding: UTF8}) {
|
||||
return _HttpBodyHandler.processResponse(response, defaultEncoding);
|
||||
return HttpBodyHandlerImpl.processResponse(response, defaultEncoding);
|
||||
}
|
||||
|
||||
Stream<HttpRequestBody> bind(Stream<HttpRequest> stream) {
|
||||
|
||||
@@ -2,13 +2,22 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of http_server;
|
||||
library http_server.http_body_impl;
|
||||
|
||||
class _HttpBodyHandlerTransformer
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:mime/mime.dart';
|
||||
|
||||
import 'http_body.dart';
|
||||
import 'http_multipart_form_data.dart';
|
||||
|
||||
class HttpBodyHandlerTransformer
|
||||
implements StreamTransformer<HttpRequest, HttpRequestBody> {
|
||||
final Encoding _defaultEncoding;
|
||||
|
||||
const _HttpBodyHandlerTransformer(this._defaultEncoding);
|
||||
const HttpBodyHandlerTransformer(this._defaultEncoding);
|
||||
|
||||
Stream<HttpRequestBody> bind(Stream<HttpRequest> stream) {
|
||||
return new Stream<HttpRequestBody>.eventTransformed(
|
||||
@@ -28,7 +37,7 @@ class _HttpBodyHandlerTransformerSink implements EventSink<HttpRequest> {
|
||||
|
||||
void add(HttpRequest request) {
|
||||
_pending++;
|
||||
_HttpBodyHandler.processRequest(request, _defaultEncoding)
|
||||
HttpBodyHandlerImpl.processRequest(request, _defaultEncoding)
|
||||
.then(_outSink.add, onError: _outSink.addError)
|
||||
.whenComplete(() {
|
||||
_pending--;
|
||||
@@ -44,7 +53,7 @@ class _HttpBodyHandlerTransformerSink implements EventSink<HttpRequest> {
|
||||
}
|
||||
}
|
||||
|
||||
class _HttpBodyHandler {
|
||||
class HttpBodyHandlerImpl {
|
||||
static Future<HttpRequestBody> processRequest(
|
||||
HttpRequest request,
|
||||
Encoding defaultEncoding) {
|
||||
|
||||
@@ -2,8 +2,15 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of http_server;
|
||||
library http_server.http_multipart_form_data;
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:mime/mime.dart';
|
||||
|
||||
import 'http_multipart_form_data_impl.dart';
|
||||
|
||||
/**
|
||||
* [:HttpMultipartFormData:] class used for 'upgrading' a [MimeMultipart] by
|
||||
@@ -76,5 +83,5 @@ abstract class HttpMultipartFormData implements Stream {
|
||||
*/
|
||||
static HttpMultipartFormData parse(MimeMultipart multipart,
|
||||
{Encoding defaultEncoding: UTF8})
|
||||
=> _HttpMultipartFormData.parse(multipart, defaultEncoding);
|
||||
=> HttpMultipartFormDataImpl.parse(multipart, defaultEncoding);
|
||||
}
|
||||
|
||||
@@ -2,10 +2,18 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of http_server;
|
||||
library http_server.http_multipart_form_data_impl;
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
class _HttpMultipartFormData extends Stream implements HttpMultipartFormData {
|
||||
import 'package:mime/mime.dart';
|
||||
|
||||
import 'http_multipart_form_data.dart';
|
||||
|
||||
class HttpMultipartFormDataImpl extends Stream
|
||||
implements HttpMultipartFormData {
|
||||
final ContentType contentType;
|
||||
final HeaderValue contentDisposition;
|
||||
final HeaderValue contentTransferEncoding;
|
||||
@@ -16,7 +24,7 @@ class _HttpMultipartFormData extends Stream implements HttpMultipartFormData {
|
||||
|
||||
Stream _stream;
|
||||
|
||||
_HttpMultipartFormData(ContentType this.contentType,
|
||||
HttpMultipartFormDataImpl(ContentType this.contentType,
|
||||
HeaderValue this.contentDisposition,
|
||||
HeaderValue this.contentTransferEncoding,
|
||||
MimeMultipart this._mimeMultipart,
|
||||
@@ -74,7 +82,7 @@ class _HttpMultipartFormData extends Stream implements HttpMultipartFormData {
|
||||
throw new HttpException(
|
||||
"Mime Multipart doesn't contain a Content-Disposition header value");
|
||||
}
|
||||
return new _HttpMultipartFormData(
|
||||
return new HttpMultipartFormDataImpl(
|
||||
type, disposition, encoding, multipart, defaultEncoding);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,14 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of http_server;
|
||||
library http_server.virtual_directory;
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:mime/mime.dart';
|
||||
import 'package:path/path.dart';
|
||||
|
||||
// Used for signal a directory redirecting, where a tailing slash is missing.
|
||||
class _DirectoryRedirect {
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
part of http_server;
|
||||
library http_server.virtual_host;
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
/**
|
||||
* The [VirtualHost] class is a utility class for handling multiple hosts on
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
name: http_server
|
||||
version: 0.9.5
|
||||
version: 0.9.5+1
|
||||
author: Dart Team <misc@dartlang.org>
|
||||
description: Library of HTTP server classes.
|
||||
homepage: http://www.dartlang.org
|
||||
dependencies:
|
||||
mime: ">=0.9.0 <0.10.0"
|
||||
path: ">=0.9.0 <2.0.0"
|
||||
dev_dependencies:
|
||||
unittest: ">=0.10.0 <0.12.0"
|
||||
environment:
|
||||
sdk: ">=1.0.0 <2.0.0"
|
||||
sdk: '>=1.0.0 <2.0.0'
|
||||
dependencies:
|
||||
mime: '>=0.9.0 <0.10.0'
|
||||
path: '>=0.9.0 <2.0.0'
|
||||
dev_dependencies:
|
||||
unittest: '>=0.10.0 <0.12.0'
|
||||
|
||||
Reference in New Issue
Block a user