public ByteArrayHttpResponse(byte[] body, HttpResponseCode code, IStringLookup headers) : base(code, headers) { _body = body; _offset = 0; _length = body.Length; }
public RedirectingHttpResponse(HttpResponseCode code, IStringLookup headers) : base(code, headers) { if ((int)code < 300 && (int)code > 399) { throw new ArgumentException("The response code must be a redirection code 3xx.", nameof(code)); } }
public static string ToUriData(this IStringLookup headers) { var builder = new StringBuilder(); foreach (var header in headers) { builder.AppendFormat("{0}={1}&", Uri.EscapeDataString(header.Key), Uri.EscapeDataString(header.Value)); } return(builder.ToString(0, builder.Length - 1)); }
public static bool TryGetByName <T>(this IStringLookup headers, string name, out T value) { if (headers.TryGetByName(name, out var stringValue)) { value = (T)Convert.ChangeType(stringValue, typeof(T), CultureInfo.InvariantCulture); return(true); } value = default; return(false); }
public HttpRequest( HttpMethod method, Uri uri, string protocol, IStringLookup headers, Stream contentStream) { Method = method; Url = uri; Protocol = protocol; PathSegments = uri.GetPathSegments(); Headers = headers; Query = string.IsNullOrEmpty(uri.Query) ? EmptyStringLookup.Instance : new QueryStringLookup(uri.Query); ; ContentStream = contentStream; Content = null; }
public ByteArrayHttpResponse(byte[] body, int offset, int length, HttpResponseCode code, IStringLookup headers) : base(code, headers) { _body = body; _offset = offset; _length = length; }
public EmptyHttpResponse(HttpResponseCode code, IStringLookup headers) : base(code, headers) { }
public StringLookupDebuggerProxy(IStringLookup real) { _real = real; }
public static T GetByNameOrDefault <T>(this IStringLookup headers, string name, T defaultValue) { return(headers.TryGetByName(name, out T value) ? value : defaultValue); }
public static T GetByName <T>(this IStringLookup headers, string name) { return(headers.TryGetByName(name, out T value) ? value : throw new EntryNotFoundException($"Could not find '{name}' in lookup.", name)); }
public static IStringLookup ToChainedStringLookup(this IEnumerable <KeyValuePair <string, string> > entries, IStringLookup parent) => new ChainedDictionaryStringLookup(parent, entries.ToDictionary(e => e.Key, e => e.Value, StringComparer.InvariantCultureIgnoreCase));
public StringHttpResponse(string body, HttpResponseCode code, IStringLookup headers) : base(code, headers) { _body = body; }
protected HttpResponseBase(HttpResponseCode code, IStringLookup headers) { ResponseCode = code; Headers = headers; }
public ChainedDictionaryStringLookup(IStringLookup parent, IDictionary <string, string> values) { _parent = parent; _values = values; }