public RequestRunner( ITransmissionSettings transmissionSettings, IAuthenticator authenticator, ICookieStrategy cookieStrategy, IArrayFormatter arrayFormatter) { this.transmissionSettings = transmissionSettings; this.authenticator = authenticator; this.cookieStrategy = cookieStrategy; this.arrayFormatter = arrayFormatter; }
public string BuildRequestUrl(IArrayFormatter arrayFormatter) { if (!Resource.HasParameters || Body.ConsumesResourceParameters) { return(Resource.Path); } var queryString = Resource.GetEncodedParameters(arrayFormatter); return(string.Concat(Resource.Path, "?", queryString)); }
public RequestMiddleware( SystemHttpClient client, ITransmissionSettings transmissionSettings, IArrayFormatter arrayFormatter, CookieContainer cookieContainer) { this.transmissionSettings = transmissionSettings; this.arrayFormatter = arrayFormatter; this.cookieContainer = cookieContainer; this.client = client; }
private IEnumerable <string> GetFormattedParameters(IArrayFormatter arrayFormatter) { if (parameters == null) { return(Enumerable.Empty <string>()); } return(parameters .Where(p => p.HasValue) .Select(p => p.ToQueryString(arrayFormatter))); }
public IContent Serialize(ITransmissionSettings transmissionSettings, IArrayFormatter arrayFormatter) { if (!resource.HasParameters) { return(new ByteArrayContent(transmissionSettings.DefaultSerializerContentType, new byte[0])); } var parameters = resource.GetEncodedParameters(arrayFormatter); var content = Encoding.UTF8.GetBytes(parameters); return(new ByteArrayContent("application/x-www-form-urlencoded", content)); }
public RequestRunner( SystemHttpClient client, ITransmissionSettings transmissionSettings, IArrayFormatter arrayFormatter, CookieContainer cookieContainer, MiddlewareCollection middleware) { var defaultMiddleware = new RequestMiddleware(client, transmissionSettings, arrayFormatter, cookieContainer); middleware.Append(defaultMiddleware); middlewareHead = middleware.BuildMiddlewareChain(); }
public string ToQueryString(IArrayFormatter arrayFormatter) { if (!HasValue) { throw new NotSupportedException($"Could not convert the parameter {Name} to a query string because it did not have a value"); } if (Value is Array array) { return(arrayFormatter.FormatParameter(Name, array, ToQueryStringValue)); } var value = ToQueryStringValue(Value); return(string.Concat(Name, "=", value)); }
public string ToQueryString(IArrayFormatter arrayFormatter) { if (!HasValue) { throw new NotSupportedException($"Could not convert the parameter {Name} to a query string because it did not have a value"); } var enumerable = Value as Array; if (enumerable != null) { return arrayFormatter.FormatParameter(Name, enumerable, ToQueryStringValue); } var value = ToQueryStringValue(Value); return string.Concat(Name, "=", value); }
public string ToQueryString(IArrayFormatter arrayFormatter) { if (!HasValue) { var message = string.Format( "Could not convert the parameter {0} to a query string because it did not have a value", Name); throw new NotSupportedException(message); } var enumerable = Value as Array; if (enumerable != null) { return(arrayFormatter.FormatParameter(Name, enumerable, ToQueryStringValue)); } var value = ToQueryStringValue(Value); return(string.Concat(Name, "=", value)); }
public ISerializableBody Serialize(ITransmissionSettings transmissionSettings, IArrayFormatter arrayFormatter) { return(new MultipartMimeDocumentBody(resource, files)); }
public IContent Serialize(ITransmissionSettings transmissionSettings, IArrayFormatter arrayFormatter) { return(new MultipartMimeContent(resource, files)); }
public string GetEncodedParameters(IArrayFormatter arrayFormatter) { var formattedParameters = GetFormattedParameters(arrayFormatter); return(string.Join("&", formattedParameters)); }
public ISerializableBody Serialize(ITransmissionSettings transmissionSettings, IArrayFormatter arrayFormatter) { var serialized = transmissionSettings.Serialize(body); var content = Encoding.UTF8.GetBytes(serialized); return(new SerializableByteArray(transmissionSettings.DefaultSerializerContentType, content)); }
public ISerializableBody Serialize(ITransmissionSettings transmissionSettings, IArrayFormatter arrayFormatter) { return(new NullSerializableBody(transmissionSettings)); }
public IContent Serialize(ITransmissionSettings transmissionSettings, IArrayFormatter arrayFormatter) { return(new NullContent(transmissionSettings)); }
public string BuildRequestUrl(IArrayFormatter arrayFormatter) { if (!Resource.HasParameters || Body.ConsumesResourceParameters) { return Resource.Path; } var queryString = Resource.GetEncodedParameters(arrayFormatter); return string.Concat(Resource.Path, "?", queryString); }
public IContent Serialize(ITransmissionSettings transmissionSettings, IArrayFormatter arrayFormatter) { return(new StreamableContent( transmissionSettings.DefaultSerializerContentType, (stream, cancellationToken) => transmissionSettings.SerializeAsync(stream, body, cancellationToken))); }