Exemple #1
0
 public static HttpRequestBuilder WithStringContent(this HttpRequestBuilder builder, string content, string mediaType)
 {
     builder.Request.Content = new StringContent(content, Encoding.UTF8, mediaType);
     return(builder);
 }
Exemple #2
0
 public static HttpRequestBuilder WithFormUrlEncodedContent(this HttpRequestBuilder builder, IDictionary <string, string> dictionary)
 {
     builder.Request.Content = new FormUrlEncodedContent(dictionary);
     return(builder);
 }
Exemple #3
0
        public static HttpRequestBuilder WithJsonContent <T>(this HttpRequestBuilder builder, T obj, JsonSerializerSettings settings)
        {
            var content = JsonConvert.SerializeObject(obj, settings);

            return(builder.WithStringContent(content, "application/json"));
        }
Exemple #4
0
 public static HttpRequestBuilder WithAuthentication(this HttpRequestBuilder builder, string scheme, string parameter)
 {
     builder.Request.Headers.Authorization = new AuthenticationHeaderValue(scheme, parameter);
     return(builder);
 }
Exemple #5
0
 public static HttpRequestBuilder WithBasicAuthentication(this HttpRequestBuilder builder, string username, string password)
 {
     return(builder.WithAuthentication("Basic", Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}"))));
 }
Exemple #6
0
 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());
 }