| Index: runtime/bin/http_impl.dart
|
| diff --git a/runtime/bin/http_impl.dart b/runtime/bin/http_impl.dart
|
| index e8e5ff14bf0c59d36a626089939a763f320d03c0..dcab3ca3b9d8088d20aec47b38aba7172df8098d 100644
|
| --- a/runtime/bin/http_impl.dart
|
| +++ b/runtime/bin/http_impl.dart
|
| @@ -208,7 +208,7 @@ class _HttpHeaders implements HttpHeaders {
|
| sb.add(": ");
|
| for (int i = 0; i < values.length; i++) {
|
| if (i > 0) {
|
| - sb.add(": ");
|
| + sb.add(", ");
|
| }
|
| sb.add(values[i]);
|
| }
|
| @@ -237,6 +237,7 @@ class _HttpRequestResponseBase {
|
| }
|
|
|
| int get contentLength() => _contentLength;
|
| + bool get persistentConnection() => _persistentConnection;
|
| HttpHeaders get headers() => _headers;
|
|
|
| bool _write(List<int> data, bool copyBuffer) {
|
| @@ -347,6 +348,8 @@ class _HttpRequestResponseBase {
|
| // including headers or chunk information of using chinked transfer
|
| // encoding.
|
| int _bodyBytesWritten = 0;
|
| +
|
| + bool _persistentConnection = true;
|
| }
|
|
|
|
|
| @@ -459,6 +462,11 @@ class _HttpResponse extends _HttpRequestResponseBase implements HttpResponse {
|
| _reasonPhrase = reasonPhrase;
|
| }
|
|
|
| + void set persistentConnection(bool persistentConnection) {
|
| + if (_outputStream != null) throw new HttpException("Header already sent");
|
| + _persistentConnection = persistentConnection;
|
| + }
|
| +
|
| OutputStream get outputStream() {
|
| if (_state >= DONE) throw new HttpException("Response closed");
|
| if (_outputStream == null) {
|
| @@ -594,16 +602,16 @@ class _HttpResponse extends _HttpRequestResponseBase implements HttpResponse {
|
|
|
| // Determine the value of the "Connection" header.
|
| if (_protocolVersion == "1.1" && !_persistentConnection) {
|
| - _headers.set("Connection", "close");
|
| + _headers.add(HttpHeaders.CONNECTION, "close");
|
| } else if (_protocolVersion == "1.0" && _persistentConnection) {
|
| - _headers.set("Connection", "keep-alive");
|
| + _headers.add(HttpHeaders.CONNECTION, "keep-alive");
|
| }
|
| // Determine the value of the "Transfer-Encoding" header based on
|
| // whether the content length is known.
|
| if (_contentLength > 0) {
|
| - _headers.set("Content-Length", _contentLength.toString());
|
| + _headers.set(HttpHeaders.CONTENT_LENGTH, _contentLength.toString());
|
| } else {
|
| - _headers.set("Transfer-Encoding", "chunked");
|
| + _headers.set(HttpHeaders.TRANSFER_ENCODING, "chunked");
|
| }
|
|
|
| // Write headers.
|
| @@ -616,7 +624,6 @@ class _HttpResponse extends _HttpRequestResponseBase implements HttpResponse {
|
| int _statusCode;
|
| String _reasonPhrase;
|
| String _protocolVersion;
|
| - bool _persistentConnection;
|
| _HttpOutputStream _outputStream;
|
| Function _streamErrorHandler;
|
| }
|
| @@ -871,6 +878,7 @@ class _HttpConnection extends _HttpConnectionBase {
|
|
|
| void _onHeadersComplete() {
|
| _request._onHeadersComplete();
|
| + _request._persistentConnection = _httpParser.persistentConnection;
|
| _response._persistentConnection = _httpParser.persistentConnection;
|
| if (onRequestReceived != null) {
|
| onRequestReceived(_request, _response);
|
| @@ -1035,6 +1043,11 @@ class _HttpClientRequest
|
| _contentLength = contentLength;
|
| }
|
|
|
| + void set persistentConnection(bool persistentConnection) {
|
| + if (_state >= HEADER_SENT) throw new HttpException("Header already sent");
|
| + _persistentConnection = persistentConnection;
|
| + }
|
| +
|
| OutputStream get outputStream() {
|
| if (_state == DONE) throw new HttpException("Request closed");
|
| if (_outputStream == null) {
|
| @@ -1090,13 +1103,17 @@ class _HttpClientRequest
|
| _httpConnection._write(_Const.HTTP11);
|
| _writeCRLF();
|
|
|
| + // Determine the value of the "Connection" header.
|
| + if (!_persistentConnection) {
|
| + _headers.add(HttpHeaders.CONNECTION, "close");
|
| + }
|
| // Determine the value of the "Transfer-Encoding" header based on
|
| // whether the content length is known. If there is no content
|
| // neither "Content-Length" nor "Transfer-Encoding" is set
|
| if (_contentLength > 0) {
|
| - _headers.set("Content-Length", _contentLength.toString());
|
| + _headers.set(HttpHeaders.CONTENT_LENGTH, _contentLength.toString());
|
| } else if (_contentLength < 0) {
|
| - _headers.set("Transfer-Encoding", "chunked");
|
| + _headers.set(HttpHeaders.TRANSFER_ENCODING, "chunked");
|
| }
|
|
|
| // Write headers.
|
| @@ -1266,6 +1283,7 @@ class _HttpClientConnection
|
| }
|
|
|
| void _onHeadersComplete() {
|
| + _response._persistentConnection = _httpParser.persistentConnection;
|
| _response._onHeadersComplete();
|
| }
|
|
|
|
|