| Index: tests/standalone/io/http_parser_test.dart
|
| diff --git a/tests/standalone/io/http_parser_test.dart b/tests/standalone/io/http_parser_test.dart
|
| index 95edf3bcd461c25219319aeb3d4a604fcace013a..a467f051a8a438512d728e7e520f18d2d70536fd 100644
|
| --- a/tests/standalone/io/http_parser_test.dart
|
| +++ b/tests/standalone/io/http_parser_test.dart
|
| @@ -48,17 +48,16 @@ class HttpParserTest {
|
| testParseInvalidResponse();
|
| }
|
|
|
| - static void _testParseRequest(String request,
|
| - String expectedMethod,
|
| - String expectedUri,
|
| - {int expectedTransferLength: 0,
|
| - int expectedBytesReceived: 0,
|
| - Map expectedHeaders: null,
|
| - bool chunked: false,
|
| - bool upgrade: false,
|
| - int unparsedLength: 0,
|
| - bool connectionClose: false,
|
| - String expectedVersion: "1.1"}) {
|
| + static void _testParseRequest(
|
| + String request, String expectedMethod, String expectedUri,
|
| + {int expectedTransferLength: 0,
|
| + int expectedBytesReceived: 0,
|
| + Map expectedHeaders: null,
|
| + bool chunked: false,
|
| + bool upgrade: false,
|
| + int unparsedLength: 0,
|
| + bool connectionClose: false,
|
| + String expectedVersion: "1.1"}) {
|
| StreamController controller;
|
| void reset() {
|
| _HttpParser httpParser = new _HttpParser.requestParser();
|
| @@ -88,38 +87,33 @@ class HttpParserTest {
|
| Expect.equals(-1, incoming.transferLength);
|
| }
|
| if (expectedHeaders != null) {
|
| - expectedHeaders.forEach(
|
| - (String name, String value) =>
|
| + expectedHeaders.forEach((String name, String value) =>
|
| Expect.equals(value, headers[name][0]));
|
| }
|
| - incoming.listen(
|
| - (List<int> data) {
|
| - Expect.isFalse(upgraded);
|
| - bytesReceived += data.length;
|
| - },
|
| - onDone: () {
|
| - port2.close();
|
| - Expect.equals(expectedMethod, method);
|
| - Expect.stringEquals(expectedUri, uri.toString());
|
| - Expect.equals(expectedVersion, headers.protocolVersion);
|
| - if (upgrade) {
|
| - Expect.equals(0, bytesReceived);
|
| - // port1 is closed by the listener on the detached data.
|
| - } else {
|
| - Expect.equals(expectedBytesReceived, bytesReceived);
|
| - }
|
| - });
|
| + incoming.listen((List<int> data) {
|
| + Expect.isFalse(upgraded);
|
| + bytesReceived += data.length;
|
| + }, onDone: () {
|
| + port2.close();
|
| + Expect.equals(expectedMethod, method);
|
| + Expect.stringEquals(expectedUri, uri.toString());
|
| + Expect.equals(expectedVersion, headers.protocolVersion);
|
| + if (upgrade) {
|
| + Expect.equals(0, bytesReceived);
|
| + // port1 is closed by the listener on the detached data.
|
| + } else {
|
| + Expect.equals(expectedBytesReceived, bytesReceived);
|
| + }
|
| + });
|
|
|
| if (upgraded) {
|
| port1.close();
|
| - httpParser.detachIncoming().listen(
|
| - (List<int> data) {
|
| - unparsedBytesReceived += data.length;
|
| - },
|
| - onDone: () {
|
| - Expect.equals(unparsedLength, unparsedBytesReceived);
|
| - port2.close();
|
| - });
|
| + httpParser.detachIncoming().listen((List<int> data) {
|
| + unparsedBytesReceived += data.length;
|
| + }, onDone: () {
|
| + Expect.equals(unparsedLength, unparsedBytesReceived);
|
| + port2.close();
|
| + });
|
| }
|
|
|
| incoming.dataDone.then((_) {
|
| @@ -153,40 +147,35 @@ class HttpParserTest {
|
| testWrite(requestData, 1);
|
| }
|
|
|
| - static void _testParseRequestLean(String request,
|
| - String expectedMethod,
|
| - String expectedUri,
|
| - {int expectedTransferLength: 0,
|
| - int expectedBytesReceived: 0,
|
| - Map expectedHeaders: null,
|
| - bool chunked: false,
|
| - bool upgrade: false,
|
| - int unparsedLength: 0,
|
| - bool connectionClose: false,
|
| - String expectedVersion: "1.1"}) {
|
| - _testParseRequest(request,
|
| - expectedMethod,
|
| - expectedUri,
|
| - expectedTransferLength: expectedTransferLength,
|
| - expectedBytesReceived: expectedBytesReceived,
|
| - expectedHeaders: expectedHeaders,
|
| - chunked: chunked,
|
| - upgrade: upgrade,
|
| - unparsedLength: unparsedLength,
|
| - connectionClose: connectionClose,
|
| - expectedVersion: expectedVersion);
|
| + static void _testParseRequestLean(
|
| + String request, String expectedMethod, String expectedUri,
|
| + {int expectedTransferLength: 0,
|
| + int expectedBytesReceived: 0,
|
| + Map expectedHeaders: null,
|
| + bool chunked: false,
|
| + bool upgrade: false,
|
| + int unparsedLength: 0,
|
| + bool connectionClose: false,
|
| + String expectedVersion: "1.1"}) {
|
| + _testParseRequest(request, expectedMethod, expectedUri,
|
| + expectedTransferLength: expectedTransferLength,
|
| + expectedBytesReceived: expectedBytesReceived,
|
| + expectedHeaders: expectedHeaders,
|
| + chunked: chunked,
|
| + upgrade: upgrade,
|
| + unparsedLength: unparsedLength,
|
| + connectionClose: connectionClose,
|
| + expectedVersion: expectedVersion);
|
| // Same test but with only \n instead of \r\n terminating each header line.
|
| - _testParseRequest(request.replaceAll('\r', ''),
|
| - expectedMethod,
|
| - expectedUri,
|
| - expectedTransferLength: expectedTransferLength,
|
| - expectedBytesReceived: expectedBytesReceived,
|
| - expectedHeaders: expectedHeaders,
|
| - chunked: chunked,
|
| - upgrade: upgrade,
|
| - unparsedLength: unparsedLength,
|
| - connectionClose: connectionClose,
|
| - expectedVersion: expectedVersion);
|
| + _testParseRequest(request.replaceAll('\r', ''), expectedMethod, expectedUri,
|
| + expectedTransferLength: expectedTransferLength,
|
| + expectedBytesReceived: expectedBytesReceived,
|
| + expectedHeaders: expectedHeaders,
|
| + chunked: chunked,
|
| + upgrade: upgrade,
|
| + unparsedLength: unparsedLength,
|
| + connectionClose: connectionClose,
|
| + expectedVersion: expectedVersion);
|
| }
|
|
|
| static void _testParseInvalidRequest(String request) {
|
| @@ -216,8 +205,8 @@ class HttpParserTest {
|
| if (chunkSize == -1) chunkSize = requestData.length;
|
| reset();
|
| for (int pos = 0;
|
| - pos < requestData.length && !errorCalled;
|
| - pos += chunkSize) {
|
| + pos < requestData.length && !errorCalled;
|
| + pos += chunkSize) {
|
| int end = min(requestData.length, pos + chunkSize);
|
| controller.add(requestData.sublist(pos, end));
|
| }
|
| @@ -232,19 +221,18 @@ class HttpParserTest {
|
| testWrite(requestData, 1);
|
| }
|
|
|
| - static void _testParseResponse(String response,
|
| - int expectedStatusCode,
|
| - String expectedReasonPhrase,
|
| - {int expectedTransferLength: 0,
|
| - int expectedBytesReceived: 0,
|
| - Map expectedHeaders: null,
|
| - bool chunked: false,
|
| - bool close: false,
|
| - String responseToMethod: null,
|
| - bool connectionClose: false,
|
| - bool upgrade: false,
|
| - int unparsedLength: 0,
|
| - String expectedVersion: "1.1"}) {
|
| + static void _testParseResponse(
|
| + String response, int expectedStatusCode, String expectedReasonPhrase,
|
| + {int expectedTransferLength: 0,
|
| + int expectedBytesReceived: 0,
|
| + Map expectedHeaders: null,
|
| + bool chunked: false,
|
| + bool close: false,
|
| + String responseToMethod: null,
|
| + bool connectionClose: false,
|
| + bool upgrade: false,
|
| + int unparsedLength: 0,
|
| + String expectedVersion: "1.1"}) {
|
| StreamController controller;
|
| bool upgraded;
|
|
|
| @@ -278,7 +266,9 @@ class HttpParserTest {
|
| if (close) Expect.isTrue(dataEndClose);
|
| Expect.equals(dataEndClose, connectionClose);
|
| }
|
| - };
|
| + }
|
| +
|
| + ;
|
|
|
| var subscription = httpParser.listen((incoming) {
|
| port.close();
|
| @@ -298,16 +288,14 @@ class HttpParserTest {
|
| }
|
| Expect.equals(upgrade, httpParser.upgrade);
|
| headersCompleteCalled = true;
|
| - incoming.listen(
|
| - (List<int> data) {
|
| - Expect.isTrue(headersCompleteCalled);
|
| - bytesReceived += data.length;
|
| - },
|
| - onDone: () {
|
| - dataEndCalled = true;
|
| - dataEndClose = close;
|
| - whenDone();
|
| - });
|
| + incoming.listen((List<int> data) {
|
| + Expect.isTrue(headersCompleteCalled);
|
| + bytesReceived += data.length;
|
| + }, onDone: () {
|
| + dataEndCalled = true;
|
| + dataEndClose = close;
|
| + whenDone();
|
| + });
|
| }, onDone: whenDone);
|
|
|
| headersCompleteCalled = false;
|
| @@ -325,7 +313,6 @@ class HttpParserTest {
|
| for (int pos = 0; pos < requestData.length; pos += chunkSize) {
|
| int end = min(requestData.length, pos + chunkSize);
|
| controller.add(requestData.sublist(pos, end));
|
| -
|
| }
|
| if (close) controller.close();
|
| }
|
| @@ -342,19 +329,18 @@ class HttpParserTest {
|
| void testWrite(List<int> requestData, [int chunkSize = -1]) {
|
| _HttpParser httpParser = new _HttpParser.responseParser();
|
| StreamController controller = new StreamController(sync: true);
|
| - bool errorCalled = false;;
|
| + bool errorCalled = false;
|
| + ;
|
|
|
| if (chunkSize == -1) chunkSize = requestData.length;
|
|
|
| var port = new ReceivePort();
|
| httpParser.listenToStream(controller.stream);
|
| var subscription = httpParser.listen((incoming) {
|
| - incoming.listen(
|
| - (data) {},
|
| - onError: (e) {
|
| - Expect.isFalse(errorCalled);
|
| - errorCalled = true;
|
| - });
|
| + incoming.listen((data) {}, onError: (e) {
|
| + Expect.isFalse(errorCalled);
|
| + errorCalled = true;
|
| + });
|
| });
|
| subscription.onError((e) {
|
| Expect.isFalse(errorCalled);
|
| @@ -367,8 +353,8 @@ class HttpParserTest {
|
|
|
| errorCalled = false;
|
| for (int pos = 0;
|
| - pos < requestData.length && !errorCalled;
|
| - pos += chunkSize) {
|
| + pos < requestData.length && !errorCalled;
|
| + pos += chunkSize) {
|
| int end = min(requestData.length, pos + chunkSize);
|
| controller.add(requestData.sublist(pos, end));
|
| }
|
| @@ -387,25 +373,25 @@ class HttpParserTest {
|
| String request;
|
| Map headers;
|
| var methods = [
|
| - // RFC 2616 methods.
|
| - "OPTIONS", "GET", "HEAD", "POST", "PUT", "DELETE", "TRACE", "CONNECT",
|
| - // WebDAV methods from RFC 4918.
|
| - "PROPFIND", "PROPPATCH", "MKCOL", "COPY", "MOVE", "LOCK", "UNLOCK",
|
| - // WebDAV methods from RFC 5323.
|
| - "SEARCH",
|
| - // Methods with HTTP prefix.
|
| - "H", "HT", "HTT", "HTTP", "HX", "HTX", "HTTX", "HTTPX"];
|
| + // RFC 2616 methods.
|
| + "OPTIONS", "GET", "HEAD", "POST", "PUT", "DELETE", "TRACE", "CONNECT",
|
| + // WebDAV methods from RFC 4918.
|
| + "PROPFIND", "PROPPATCH", "MKCOL", "COPY", "MOVE", "LOCK", "UNLOCK",
|
| + // WebDAV methods from RFC 5323.
|
| + "SEARCH",
|
| + // Methods with HTTP prefix.
|
| + "H", "HT", "HTT", "HTTP", "HX", "HTX", "HTTX", "HTTPX"
|
| + ];
|
| methods = ['GET'];
|
| methods.forEach((method) {
|
| - request = "$method / HTTP/1.1\r\n\r\n";
|
| + request = "$method / HTTP/1.1\r\n\r\n";
|
| _testParseRequestLean(request, method, "/");
|
| - request = "$method /index.html HTTP/1.1\r\n\r\n";
|
| + request = "$method /index.html HTTP/1.1\r\n\r\n";
|
| _testParseRequestLean(request, method, "/index.html");
|
| });
|
| request = "GET / HTTP/1.0\r\n\r\n";
|
| _testParseRequestLean(request, "GET", "/",
|
| - expectedVersion: "1.0",
|
| - connectionClose: true);
|
| + expectedVersion: "1.0", connectionClose: true);
|
|
|
| request = "GET / HTTP/1.0\r\nConnection: keep-alive\r\n\r\n";
|
| _testParseRequestLean(request, "GET", "/", expectedVersion: "1.0");
|
| @@ -477,11 +463,8 @@ POST /test HTTP/1.1\r
|
| Content-Length: 10\r
|
| \r
|
| 0123456789""";
|
| - _testParseRequestLean(request,
|
| - "POST",
|
| - "/test",
|
| - expectedTransferLength: 10,
|
| - expectedBytesReceived: 10);
|
| + _testParseRequestLean(request, "POST", "/test",
|
| + expectedTransferLength: 10, expectedBytesReceived: 10);
|
|
|
| // Test connection close header.
|
| request = "GET /test HTTP/1.1\r\nConnection: close\r\n\r\n";
|
| @@ -497,12 +480,8 @@ Transfer-Encoding: chunked\r
|
| 5\r
|
| 56789\r
|
| 0\r\n\r\n""";
|
| - _testParseRequest(request,
|
| - "POST",
|
| - "/test",
|
| - expectedTransferLength: -1,
|
| - expectedBytesReceived: 10,
|
| - chunked: true);
|
| + _testParseRequest(request, "POST", "/test",
|
| + expectedTransferLength: -1, expectedBytesReceived: 10, chunked: true);
|
|
|
| // Test mixing chunked encoding and content length (content length
|
| // is ignored).
|
| @@ -516,12 +495,8 @@ Transfer-Encoding: chunked\r
|
| 5\r
|
| 56789\r
|
| 0\r\n\r\n""";
|
| - _testParseRequest(request,
|
| - "POST",
|
| - "/test",
|
| - expectedTransferLength: -1,
|
| - expectedBytesReceived: 10,
|
| - chunked: true);
|
| + _testParseRequest(request, "POST", "/test",
|
| + expectedTransferLength: -1, expectedBytesReceived: 10, chunked: true);
|
|
|
| // Test mixing chunked encoding and content length (content length
|
| // is ignored).
|
| @@ -535,12 +510,8 @@ Content-Length: 3\r
|
| 5\r
|
| 56789\r
|
| 0\r\n\r\n""";
|
| - _testParseRequest(request,
|
| - "POST",
|
| - "/test",
|
| - expectedTransferLength: -1,
|
| - expectedBytesReceived: 10,
|
| - chunked: true);
|
| + _testParseRequest(request, "POST", "/test",
|
| + expectedTransferLength: -1, expectedBytesReceived: 10, chunked: true);
|
|
|
| // Test upper and lower case hex digits in chunked encoding.
|
| request = """
|
| @@ -552,12 +523,8 @@ Transfer-Encoding: chunked\r
|
| 1e\r
|
| 012345678901234567890123456789\r
|
| 0\r\n\r\n""";
|
| - _testParseRequest(request,
|
| - "POST",
|
| - "/test",
|
| - expectedTransferLength: -1,
|
| - expectedBytesReceived: 60,
|
| - chunked: true);
|
| + _testParseRequest(request, "POST", "/test",
|
| + expectedTransferLength: -1, expectedBytesReceived: 60, chunked: true);
|
|
|
| // Test chunk extensions in chunked encoding.
|
| request = """
|
| @@ -569,12 +536,8 @@ Transfer-Encoding: chunked\r
|
| 1E;yyy=zzz\r
|
| 012345678901234567890123456789\r
|
| 0\r\n\r\n""";
|
| - _testParseRequest(request,
|
| - "POST",
|
| - "/test",
|
| - expectedTransferLength: -1,
|
| - expectedBytesReceived: 60,
|
| - chunked: true);
|
| + _testParseRequest(request, "POST", "/test",
|
| + expectedTransferLength: -1, expectedBytesReceived: 60, chunked: true);
|
|
|
| // Test HTTP upgrade.
|
| request = """
|
| @@ -584,12 +547,8 @@ Connection: Upgrade\r
|
| \r\n\x01\x01\x01\x01\x01\x02\x02\x02\x02\xFF""";
|
| headers = new Map();
|
| headers["upgrade"] = "irc/1.2";
|
| - _testParseRequest(request,
|
| - "GET",
|
| - "/irc",
|
| - expectedHeaders: headers,
|
| - upgrade: true,
|
| - unparsedLength: 10);
|
| + _testParseRequest(request, "GET", "/irc",
|
| + expectedHeaders: headers, upgrade: true, unparsedLength: 10);
|
|
|
| // Test HTTP upgrade with protocol data.
|
| request = """
|
| @@ -599,11 +558,8 @@ Connection: Upgrade\r
|
| \r\n""";
|
| headers = new Map();
|
| headers["upgrade"] = "irc/1.2";
|
| - _testParseRequest(request,
|
| - "GET",
|
| - "/irc",
|
| - expectedHeaders: headers,
|
| - upgrade: true);
|
| + _testParseRequest(request, "GET", "/irc",
|
| + expectedHeaders: headers, upgrade: true);
|
|
|
| // Test websocket upgrade.
|
| request = """
|
| @@ -621,12 +577,8 @@ Sec-WebSocket-Version: 13\r
|
| headers["sec-websocket-key"] = "dGhlIHNhbXBsZSBub25jZQ==";
|
| headers["origin"] = "http://example.com";
|
| headers["sec-websocket-version"] = "13";
|
| - _testParseRequest(request,
|
| - "GET",
|
| - "/chat",
|
| - expectedHeaders: headers,
|
| - upgrade: true);
|
| -
|
| + _testParseRequest(request, "GET", "/chat",
|
| + expectedHeaders: headers, upgrade: true);
|
|
|
| // Test websocket upgrade with protocol data. NOTE: When using the
|
| // WebSocket protocol this should never happen as the client
|
| @@ -648,12 +600,8 @@ Sec-WebSocket-Version: 13\r
|
| headers["sec-websocket-key"] = "dGhlIHNhbXBsZSBub25jZQ==";
|
| headers["origin"] = "http://example.com";
|
| headers["sec-websocket-version"] = "13";
|
| - _testParseRequest(request,
|
| - "GET",
|
| - "/chat",
|
| - expectedHeaders: headers,
|
| - upgrade: true,
|
| - unparsedLength: 7);
|
| + _testParseRequest(request, "GET", "/chat",
|
| + expectedHeaders: headers, upgrade: true, unparsedLength: 7);
|
| }
|
|
|
| static void testParseResponse() {
|
| @@ -666,46 +614,28 @@ Sec-WebSocket-Version: 13\r
|
| _testParseResponse(response, 100, "Continue");
|
|
|
| response = "HTTP/1.1 100 Continue\r\nContent-Length: 10\r\n\r\n";
|
| - _testParseResponse(response,
|
| - 100,
|
| - "Continue",
|
| - expectedTransferLength: 10,
|
| - expectedBytesReceived: 0);
|
| + _testParseResponse(response, 100, "Continue",
|
| + expectedTransferLength: 10, expectedBytesReceived: 0);
|
|
|
| response = "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n"
|
| - "Connection: Close\r\n\r\n";
|
| - _testParseResponse(response,
|
| - 200,
|
| - "OK",
|
| - connectionClose: true);
|
| + "Connection: Close\r\n\r\n";
|
| + _testParseResponse(response, 200, "OK", connectionClose: true);
|
|
|
| response = "HTTP/1.0 200 OK\r\nContent-Length: 0\r\n\r\n";
|
| - _testParseResponse(response,
|
| - 200,
|
| - "OK",
|
| - expectedVersion: "1.0",
|
| - connectionClose: true);
|
| + _testParseResponse(response, 200, "OK",
|
| + expectedVersion: "1.0", connectionClose: true);
|
|
|
| response = "HTTP/1.0 200 OK\r\nContent-Length: 0\r\n"
|
| - "Connection: Keep-Alive\r\n\r\n";
|
| - _testParseResponse(response,
|
| - 200,
|
| - "OK",
|
| - expectedVersion: "1.0");
|
| + "Connection: Keep-Alive\r\n\r\n";
|
| + _testParseResponse(response, 200, "OK", expectedVersion: "1.0");
|
|
|
| response = "HTTP/1.1 204 No Content\r\nContent-Length: 11\r\n\r\n";
|
| - _testParseResponse(response,
|
| - 204,
|
| - "No Content",
|
| - expectedTransferLength: 11,
|
| - expectedBytesReceived: 0);
|
| + _testParseResponse(response, 204, "No Content",
|
| + expectedTransferLength: 11, expectedBytesReceived: 0);
|
|
|
| response = "HTTP/1.1 304 Not Modified\r\nContent-Length: 12\r\n\r\n";
|
| - _testParseResponse(response,
|
| - 304,
|
| - "Not Modified",
|
| - expectedTransferLength: 12,
|
| - expectedBytesReceived: 0);
|
| + _testParseResponse(response, 304, "Not Modified",
|
| + expectedTransferLength: 12, expectedBytesReceived: 0);
|
|
|
| response = "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n";
|
| _testParseResponse(response, 200, "OK");
|
| @@ -725,13 +655,11 @@ Content-Type: text/html\r
|
| headers = new Map();
|
| headers["content-length"] = "20";
|
| headers["content-type"] = "text/html";
|
| - _testParseResponse(response,
|
| - 200,
|
| - "OK",
|
| - responseToMethod: "HEAD",
|
| - expectedTransferLength: 20,
|
| - expectedBytesReceived: 0,
|
| - expectedHeaders: headers);
|
| + _testParseResponse(response, 200, "OK",
|
| + responseToMethod: "HEAD",
|
| + expectedTransferLength: 20,
|
| + expectedBytesReceived: 0,
|
| + expectedHeaders: headers);
|
|
|
| // Test content.
|
| response = """
|
| @@ -739,11 +667,8 @@ HTTP/1.1 200 OK\r
|
| Content-Length: 20\r
|
| \r
|
| 01234567890123456789""";
|
| - _testParseResponse(response,
|
| - 200,
|
| - "OK",
|
| - expectedTransferLength: 20,
|
| - expectedBytesReceived: 20);
|
| + _testParseResponse(response, 200, "OK",
|
| + expectedTransferLength: 20, expectedBytesReceived: 20);
|
|
|
| // Test upper and lower case hex digits in chunked encoding.
|
| response = """
|
| @@ -755,12 +680,8 @@ Transfer-Encoding: chunked\r
|
| 1f\r
|
| 0123456789012345678901234567890\r
|
| 0\r\n\r\n""";
|
| - _testParseResponse(response,
|
| - 200,
|
| - "OK",
|
| - expectedTransferLength: -1,
|
| - expectedBytesReceived: 57,
|
| - chunked: true);
|
| + _testParseResponse(response, 200, "OK",
|
| + expectedTransferLength: -1, expectedBytesReceived: 57, chunked: true);
|
|
|
| // Test connection close header.
|
| response = """
|
| @@ -768,10 +689,7 @@ HTTP/1.1 200 OK\r
|
| Content-Length: 0\r
|
| Connection: close\r
|
| \r\n""";
|
| - _testParseResponse(response,
|
| - 200,
|
| - "OK",
|
| - connectionClose: true);
|
| + _testParseResponse(response, 200, "OK", connectionClose: true);
|
|
|
| // Test HTTP response without any transfer length indications
|
| // where closing the connections indicates end of body.
|
| @@ -781,13 +699,11 @@ HTTP/1.1 200 OK\r
|
| 01234567890123456789012345
|
| 0123456789012345678901234567890
|
| """;
|
| - _testParseResponse(response,
|
| - 200,
|
| - "OK",
|
| - expectedTransferLength: -1,
|
| - expectedBytesReceived: 59,
|
| - close: true,
|
| - connectionClose: true);
|
| + _testParseResponse(response, 200, "OK",
|
| + expectedTransferLength: -1,
|
| + expectedBytesReceived: 59,
|
| + close: true,
|
| + connectionClose: true);
|
|
|
| // Test HTTP upgrade.
|
| response = """
|
| @@ -797,11 +713,8 @@ Connection: Upgrade\r
|
| \r\n""";
|
| headers = new Map();
|
| headers["upgrade"] = "irc/1.2";
|
| - _testParseResponse(response,
|
| - 101,
|
| - "Switching Protocols",
|
| - expectedHeaders: headers,
|
| - upgrade: true);
|
| + _testParseResponse(response, 101, "Switching Protocols",
|
| + expectedHeaders: headers, upgrade: true);
|
|
|
| // Test HTTP upgrade with protocol data.
|
| response = """
|
| @@ -811,12 +724,8 @@ Connection: Upgrade\r
|
| \r\n\x00\x10\x20\x30\x40\x50\x60\x70\x80\x90\xA0\xB0\xC0\xD0\xE0\xF0""";
|
| headers = new Map();
|
| headers["upgrade"] = "irc/1.2";
|
| - _testParseResponse(response,
|
| - 101,
|
| - "Switching Protocols",
|
| - expectedHeaders: headers,
|
| - upgrade: true,
|
| - unparsedLength: 16);
|
| + _testParseResponse(response, 101, "Switching Protocols",
|
| + expectedHeaders: headers, upgrade: true, unparsedLength: 16);
|
|
|
| // Test websocket upgrade.
|
| response = """
|
| @@ -828,11 +737,8 @@ Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r
|
| headers = new Map();
|
| headers["upgrade"] = "websocket";
|
| headers["sec-websocket-accept"] = "s3pPLMBiTxaQ9kYGzzhZRbK+xOo=";
|
| - _testParseResponse(response,
|
| - 101,
|
| - "Switching Protocols",
|
| - expectedHeaders: headers,
|
| - upgrade: true);
|
| + _testParseResponse(response, 101, "Switching Protocols",
|
| + expectedHeaders: headers, upgrade: true);
|
|
|
| // Test websocket upgrade with protocol data.
|
| response = """
|
| @@ -844,12 +750,8 @@ Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r
|
| headers = new Map();
|
| headers["upgrade"] = "websocket";
|
| headers["sec-websocket-accept"] = "s3pPLMBiTxaQ9kYGzzhZRbK+xOo=";
|
| - _testParseResponse(response,
|
| - 101,
|
| - "Switching Protocols",
|
| - expectedHeaders: headers,
|
| - upgrade: true,
|
| - unparsedLength: 4);
|
| + _testParseResponse(response, 101, "Switching Protocols",
|
| + expectedHeaders: headers, upgrade: true, unparsedLength: 4);
|
| }
|
|
|
| static void testParseInvalidRequest() {
|
| @@ -934,7 +836,6 @@ Transfer-Encoding: chunked\r
|
| }
|
| }
|
|
|
| -
|
| void main() {
|
| HttpParserTest.runAllTests();
|
| }
|
|
|