public string Escape(Uri requestTarget, RequestTargetEscaping escaping) { if (requestTarget == null) { throw new ArgumentNullException(nameof(requestTarget)); } switch (escaping) { case RequestTargetEscaping.RFC3986: return(_rfc3986Escaper.Escape(requestTarget, escaping)); case RequestTargetEscaping.RFC2396: return(_rfc2396Escaper.Escape(requestTarget, escaping)); case RequestTargetEscaping.OriginalString: return(_originalStringEscaper.Escape(requestTarget, escaping)); case RequestTargetEscaping.Unescaped: return(_unescapedEscaper.Escape(requestTarget, escaping)); default: throw new ArgumentOutOfRangeException(nameof(escaping), escaping, $"The specified {nameof(RequestTargetEscaping)} value is currently not supported."); } }
public string BuildStringToAppend(HeaderName header) { var path = _request.RequestUri.OriginalString == "*" ? _request.RequestUri.OriginalString : _requestTargetEscaper.Escape(_request.RequestUri, _requestTargetEscaping); return("\n" + new Header( HeaderName.PredefinedHeaderNames.RequestTarget, $"{_request.Method.Method.ToLowerInvariant()} {path}")); }