Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 315b83d

Browse files
author
Geoff Kizer
committed
add more cases and make tests more robust
1 parent 56bae42 commit 315b83d

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

src/System.Net.Http/tests/FunctionalTests/HttpProtocolTests.cs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,16 @@ private Uri CreateServer(string response)
8787
[InlineData(200, " ")]
8888
[InlineData(200, " Something")]
8989
[InlineData(200, "\t")]
90+
[InlineData(200, "O K")]
91+
[InlineData(200, "O\tK")]
92+
[InlineData(200, "O \t\t \t\t\t\t \t K")]
9093
[InlineData(201, "Created")]
9194
[InlineData(202, "Accepted")]
9295
[InlineData(299, "This is not a real status code")]
9396
[InlineData(345, "redirect to nowhere")]
9497
[InlineData(400, "Bad Request")]
9598
[InlineData(500, "Internal Server Error")]
99+
[InlineData(555, "we just don't like you")]
96100
[InlineData(600, "still valid")]
97101
[InlineData(999, "this\ttoo\t")]
98102
public async Task ValidStatusLine(int statusCode, string reason)
@@ -109,15 +113,22 @@ public async Task ValidStatusLine(int statusCode, string reason)
109113

110114
[Theory]
111115
[InlineData("NOTHTTP/1.1")]
112-
[InlineData("HTTP/1.1\r\n")]
113-
[InlineData("HTTP/1.1 \r\n")]
116+
[InlineData("NOTHTTP/1.1 200 OK")]
117+
[InlineData("ABCD/1.1 200 OK")]
118+
[InlineData("HTTP/1.1")]
119+
[InlineData("HTTP/1.1 ")]
114120
[InlineData("HTTP/1.1 ")]
115-
[InlineData("HTTP/1.1 200\r\n")] // need trailing space
121+
[InlineData("HTTP/1.1\t")]
122+
[InlineData("HTTP/1.1\t\t")]
116123
[InlineData("HTTP/1.1\t200 OK")]
117124
[InlineData("HTTP/1.1 200\tOK")]
125+
[InlineData("HTTP/1.1 200")] // need trailing space
126+
[InlineData("HTTP/1.1 200\tOK")]
127+
[InlineData("HTTP/1.1 200 O\rK")]
128+
[InlineData("HTTP/1.1 200 O\nK")]
118129
[InlineData("HTTP/1.1 200OK")]
119130
[InlineData("HTTP/1.1 2345")]
120-
[InlineData("HTTP/1.1 23\r\n")]
131+
[InlineData("HTTP/1.1 23")]
121132
[InlineData("HTTP/1.1 abc")]
122133
[InlineData("HTTP/1.1 2bc")]
123134
[InlineData("HTTP/1.1 20c")]
@@ -127,10 +138,16 @@ public async Task ValidStatusLine(int statusCode, string reason)
127138
[InlineData("HTTP/0.1 200 OK")]
128139
[InlineData("HTTP/1.12 200 OK")]
129140
[InlineData("HTTP/12.1 200 OK")]
141+
[InlineData("HTTP/1.A 200 OK")]
142+
[InlineData("HTTP/A.1 200 OK")]
143+
[InlineData("HTTP/X.Y.Z 200 OK")]
144+
[InlineData("HTTP\\1.1 200 OK")]
145+
[InlineData("HTTP 1.1 200 OK")]
130146
public void InvalidStatusLine(string responseString)
131147
{
132148
using (HttpClient client = new HttpClient())
133149
{
150+
responseString += "\r\nContent-Length: 0\r\n\r\n";
134151
Uri serverUri = CreateServer(responseString);
135152
Assert.ThrowsAsync<HttpRequestException>(() => client.GetAsync(serverUri));
136153
}

0 commit comments

Comments
 (0)