private static HttpResponseMessage UnauthorizedRequest(string endpoint, HttpMethod requestType, Dictionary <String, String> headers) { if (headers == null) { headers = new Dictionary <string, string>(); } var httpClient = new HttpClient(); foreach (var header in headers) { httpClient.DefaultRequestHeaders.TryAddWithoutValidation(header.Key, header.Value); } var url = String.Format(ApiBase, Game, endpoint); switch (requestType) { case HttpMethod.Get: return(httpClient.GetAsync(url).Result); default: throw new ArgumentException(); } }
private static HttpResponseMessage UnauthorizedRequest(String url, HttpMethod requestType, Dictionary <String, String> headers) { if (headers == null) { headers = new Dictionary <string, string>(); } var httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Accept", "application/json"); foreach (var header in headers) { httpClient.DefaultRequestHeaders.TryAddWithoutValidation(header.Key, header.Value); } switch (requestType) { case HttpMethod.Get: return(httpClient.GetAsync(url).Result); default: throw new ArgumentException(); } }
private static HttpResponseMessage AuthorizedRequest(String url, AuthType authType, HttpMethod requestType, Dictionary <String, String> headers) { if (headers == null) { headers = new Dictionary <string, string>(); } Authentication authentication; using (var sqlStorage = new SqlStorage()) { authentication = sqlStorage.Authentications.FirstOrDefault(a => a.Type == AuthenticationType.Halo4); } switch (authType) { case AuthType.Spartan: headers.Add("X-343-Authorization-Spartan", authentication != null && authentication.IsValid ? authentication.Key : "f**k"); // error catch break; default: throw new ArgumentException(); } return(UnauthorizedRequest(url, requestType, headers)); }
private static HttpResponseMessage AuthorizedRequest(String url, AuthType authType, HttpMethod requestType) { return(AuthorizedRequest(url, authType, requestType, new Dictionary <string, string>())); }
private static HttpResponseMessage UnauthorizedRequest(String url, HttpMethod requestType) { return(UnauthorizedRequest(url, requestType, new Dictionary <String, String>())); }