public static HttpRequestBuilder WithStringContent(this HttpRequestBuilder builder, string content, string mediaType) { builder.Request.Content = new StringContent(content, Encoding.UTF8, mediaType); return(builder); }
public static HttpRequestBuilder WithFormUrlEncodedContent(this HttpRequestBuilder builder, IDictionary <string, string> dictionary) { builder.Request.Content = new FormUrlEncodedContent(dictionary); return(builder); }
public static HttpRequestBuilder WithJsonContent <T>(this HttpRequestBuilder builder, T obj, JsonSerializerSettings settings) { var content = JsonConvert.SerializeObject(obj, settings); return(builder.WithStringContent(content, "application/json")); }
public static HttpRequestBuilder WithAuthentication(this HttpRequestBuilder builder, string scheme, string parameter) { builder.Request.Headers.Authorization = new AuthenticationHeaderValue(scheme, parameter); return(builder); }
public static HttpRequestBuilder WithBasicAuthentication(this HttpRequestBuilder builder, string username, string password) { return(builder.WithAuthentication("Basic", Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}")))); }
public static HttpRequestBuilder WithBearerAuthentication(this HttpRequestBuilder builder, string bearerToken) { return(builder.WithAuthentication("Bearer", bearerToken)); }
public static HttpResponseInspector GetResponse(this HttpRequestBuilder builder) { return(builder.GetResponseAsync().GetAwaiter().GetResult()); }