-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHttpsResult.cs
More file actions
50 lines (42 loc) · 1.26 KB
/
HttpsResult.cs
File metadata and controls
50 lines (42 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace Https.Tests
{
public class HttpsResult : IDisposable
{
public int ExitCode { get; }
public MemoryStream StdOut { get; }
public string Status { get; }
public IReadOnlyDictionary<string, string> Headers { get; }
public HttpsResult(int exitCode, MemoryStream stdout, MemoryStream stderr)
{
ExitCode = exitCode;
StdOut = stdout;
StdOut.Position = 0;
stderr.Position = 0;
var lines = new StreamReader(stderr)
.ReadToEnd()
.Split(Environment.NewLine);
Status = lines[0];
var headers = new Dictionary<string, string>();
foreach (var line in lines.Skip(1))
{
var pos = line.IndexOf(':');
if (pos > -1)
{
var key = line.Substring(0, pos);
var value = line.Substring(pos + 2);
headers[key] = value;
}
}
Headers = headers;
stderr.Dispose();
}
public void Dispose()
{
StdOut.Dispose();
}
}
}