-
-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy pathRequestInfo.cs
More file actions
130 lines (107 loc) · 5.07 KB
/
Copy pathRequestInfo.cs
File metadata and controls
130 lines (107 loc) · 5.07 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Exceptionless.Serializer;
namespace Exceptionless.Models.Data {
public class RequestInfo : IData {
public RequestInfo() {
Data = new DataDictionary();
Headers = new Dictionary<string, string[]>();
Cookies = new Dictionary<string, string>();
QueryString = new Dictionary<string, string>();
}
/// <summary>
/// The user agent used for the request.
/// </summary>
public string UserAgent { get; set; }
/// <summary>
/// The HTTP method for the request.
/// </summary>
public string HttpMethod { get; set; }
/// <summary>
/// Whether the request was secure or not.
/// </summary>
public bool IsSecure { get; set; }
/// <summary>
/// The host of the request.
/// </summary>
public string Host { get; set; }
/// <summary>
/// The port of the request.
/// </summary>
public int Port { get; set; }
/// <summary>
/// The path of the request.
/// </summary>
public string Path { get; set; }
/// <summary>
/// The referring url for the request.
/// </summary>
public string Referrer { get; set; }
/// <summary>
/// The client's IP address when the error occurred.
/// </summary>
public string ClientIpAddress { get; set; }
/// <summary>
/// The header values from the request.
/// </summary>
public Dictionary<string, string[]> Headers { get; set; }
/// <summary>
/// The request cookies.
/// </summary>
public Dictionary<string, string> Cookies { get; set; }
/// <summary>
/// The data that was POSTed for the request.
/// </summary>
[JsonConverter(typeof(PostDataConverter))]
public object PostData { get; set; }
/// <summary>
/// The query string values from the request.
/// </summary>
public Dictionary<string, string> QueryString { get; set; }
/// <summary>
/// Extended data entries for this request.
/// </summary>
public DataDictionary Data { get; set; }
protected bool Equals(RequestInfo other) {
return string.Equals(UserAgent, other.UserAgent) && string.Equals(HttpMethod, other.HttpMethod) && IsSecure == other.IsSecure && string.Equals(Host, other.Host) && Port == other.Port && string.Equals(Path, other.Path) && string.Equals(Referrer, other.Referrer) && string.Equals(ClientIpAddress, other.ClientIpAddress) && Headers.CollectionEquals(other.Headers) && Cookies.CollectionEquals(other.Cookies) && QueryString.CollectionEquals(other.QueryString) && Equals(Data, other.Data);
}
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj))
return false;
if (ReferenceEquals(this, obj))
return true;
if (obj.GetType() != this.GetType())
return false;
return Equals((RequestInfo)obj);
}
private static readonly ISet<string> _cookieHashCodeExclusions = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase) { "__LastReferenceId" };
public override int GetHashCode() {
unchecked {
var hashCode = UserAgent == null ? 0 : UserAgent.GetHashCode();
hashCode = (hashCode * 397) ^ (HttpMethod == null ? 0 : HttpMethod.GetHashCode());
hashCode = (hashCode * 397) ^ IsSecure.GetHashCode();
hashCode = (hashCode * 397) ^ (Host == null ? 0 : Host.GetHashCode());
hashCode = (hashCode * 397) ^ Port;
hashCode = (hashCode * 397) ^ (Path == null ? 0 : Path.GetHashCode());
hashCode = (hashCode * 397) ^ (Referrer == null ? 0 : Referrer.GetHashCode());
hashCode = (hashCode * 397) ^ (ClientIpAddress == null ? 0 : ClientIpAddress.GetHashCode());
hashCode = (hashCode * 397) ^ (Headers == null ? 0 : Headers.GetCollectionHashCode());
hashCode = (hashCode * 397) ^ (Cookies == null ? 0 : Cookies.GetCollectionHashCode(_cookieHashCodeExclusions));
hashCode = (hashCode * 397) ^ (QueryString == null ? 0 : QueryString.GetCollectionHashCode());
hashCode = (hashCode * 397) ^ (Data == null ? 0 : Data.GetCollectionHashCode());
return hashCode;
}
}
public static class KnownDataKeys {
public const string Browser = "@browser";
public const string BrowserVersion = "@browser_version";
public const string BrowserMajorVersion = "@browser_major_version";
public const string Device = "@device";
public const string OS = "@os";
public const string OSVersion = "@os_version";
public const string OSMajorVersion = "@os_major_version";
public const string IsBot = "@is_bot";
}
}
}