203 instantiations of StringSegment
Microsoft.AspNetCore.Components (3)
src\Http\Routing\src\PathTokenizer.cs (3)
86return new StringSegment(_path, currentSegmentStart, delimiterIndex - currentSegmentStart); 100return new StringSegment(_path, currentSegmentStart, _path.Length - currentSegmentStart); 138return new StringSegment(_path, _index, _length);
Microsoft.AspNetCore.HostFiltering (1)
HostFilteringMiddleware.cs (1)
103if (allowedHosts is not null && HostString.MatchesAny(new StringSegment(host), allowedHosts))
Microsoft.AspNetCore.Http (1)
HeaderDictionary.cs (1)
127HeaderUtilities.TryParseNonNegativeInt64(new StringSegment(rawValue[0]).Trim(), out value))
Microsoft.AspNetCore.Http.Abstractions (2)
Internal\HeaderSegmentCollection.cs (2)
117new StringSegment(_header, _leadingStart, _leadingEnd - _leadingStart), 118new StringSegment(_header, _valueStart, _valueEnd - _valueStart));
Microsoft.AspNetCore.Mvc.Abstractions (3)
ModelBinding\ModelStateDictionary.cs (3)
63var emptySegment = new StringSegment(buffer: string.Empty); 617return new StringSegment(key, keyStart, index - keyStart); 926=> GetNode(new StringSegment(propertyName));
Microsoft.AspNetCore.Mvc.Core (35)
Formatters\MediaType.cs (9)
18private static readonly StringSegment QualityParameter = new StringSegment("q"); 194return ReplaceEncoding(new StringSegment(mediaType), encoding); 239return GetEncoding(new StringSegment(mediaType)); 294new StringSegment(mediaType, start, parser.CurrentOffset - start), 359var asterisk = new StringSegment("*"); 392name = new StringSegment(input, current, nameLength); 421value = new StringSegment(input, current + 1, valueLength - 2); 425value = new StringSegment(input, current, valueLength); 454return HasName(new StringSegment(name));
Formatters\OutputFormatter.cs (2)
115context.ContentType = new StringSegment(SupportedMediaTypes[0]); 146context.ContentType = new StringSegment(SupportedMediaTypes[i]);
Formatters\TextOutputFormatter.cs (2)
113selectedMediaType = new StringSegment(SupportedMediaTypes[0]); 126selectedMediaType = new StringSegment(mediaTypeWithCharset);
Infrastructure\DefaultOutputFormatterSelector.cs (3)
176formatterContext.ContentType = new StringSegment(); 222formatterContext.ContentType = new StringSegment(contentType); 252formatterContext.ContentType = new StringSegment(possibleOutputContentTypes[j]);
Routing\ViewEnginePath.cs (1)
49var pathSegment = new StringSegment(path);
src\Shared\MediaType\ReadOnlyMediaTypeHeaderValue.cs (18)
46Type = new StringSegment(); 47SubType = new StringSegment(); 48SubTypeWithoutSuffix = new StringSegment(); 49SubTypeSuffix = new StringSegment(); 60SubType = new StringSegment(); 61SubTypeWithoutSuffix = new StringSegment(); 62SubTypeSuffix = new StringSegment(); 77SubTypeSuffix = new StringSegment(); 107type = new StringSegment(input, current, typeLength); 136subType = new StringSegment(input, current, subtypeLength); 276return GetParameter(new StringSegment(parameterName)); 299return new StringSegment(); 333return GetEncoding(new StringSegment(mediaType)); 511var asterisk = new StringSegment("*"); 544name = new StringSegment(input, current, nameLength); 573value = new StringSegment(input, current + 1, valueLength - 2); 577value = new StringSegment(input, current, valueLength); 606return HasName(new StringSegment(name));
Microsoft.AspNetCore.Mvc.Core.Test (77)
Formatters\AcceptHeaderParserTest.cs (11)
17new MediaTypeSegmentWithQuality(new StringSegment("application/json"),1.0) 34new MediaTypeSegmentWithQuality(new StringSegment("application/json"),1.0), 35new MediaTypeSegmentWithQuality(new StringSegment("application/xml;q=0.8"),0.8) 56new MediaTypeSegmentWithQuality(new StringSegment("application/json"),1.0), 57new MediaTypeSegmentWithQuality(new StringSegment("application/xml"),1.0), 95var expectedMediaTypes = expected.Select(e => new MediaTypeSegmentWithQuality(new StringSegment(e), 1.0)).ToList(); 110new MediaTypeSegmentWithQuality(new StringSegment("application/json"), 1.0), 111new MediaTypeSegmentWithQuality(new StringSegment("application/xml;q=0.8"), 0.8) 160new MediaTypeSegmentWithQuality(new StringSegment("*/*Content-Type"), 1.0), 161new MediaTypeSegmentWithQuality(new StringSegment("application/json"), 1.0), 179new MediaTypeSegmentWithQuality(new StringSegment("application/json"), 1.0),
Formatters\FormatFilterTest.cs (4)
34var mediaType = new StringSegment("application/json"); 63var mediaType = new StringSegment("application/json"); 111var mediaType = new StringSegment(contentType); 325var mediaType = new StringSegment("application/foo");
Formatters\JsonOutputFormatterTestBase.cs (5)
46ContentType = new StringSegment(mediaType), 56Assert.Equal(new StringSegment(expectedContentType), outputFormatterContext.ContentType); 97ContentType = new StringSegment(mediaType.ToString()), 129ContentType = new StringSegment(mediaType.ToString()), 190ContentType = new StringSegment(contentType),
Formatters\MediaTypeTest.cs (14)
21Assert.Equal(new StringSegment("application"), result.Type); 22Assert.Equal(new StringSegment("json"), result.SubType); 52Assert.Equal(new StringSegment(expectedSubTypeWithoutSuffix), result.SubTypeWithoutSuffix); 53Assert.Equal(new StringSegment(expectedSubtypeSuffix), result.SubTypeSuffix); 85Assert.Equal(new StringSegment("application"), result.Type); 86Assert.Equal(new StringSegment("json+bson"), result.SubType); 87Assert.Equal(new StringSegment("json"), result.SubTypeWithoutSuffix); 88Assert.Equal(new StringSegment("bson"), result.SubTypeSuffix); 89Assert.Equal(new StringSegment("pretty"), result.GetParameter("format")); 90Assert.Equal(new StringSegment("0.8"), result.GetParameter("q")); 91Assert.Equal(new StringSegment("utf-8"), result.GetParameter("charset")); 101Assert.Equal(new StringSegment("ediaType"), result.Type); 157var expectedParameter = new StringSegment("utf-8"); 186var expectedParameter = new StringSegment("utf-8");
Formatters\NoContentFormatterTests.cs (4)
39var contentType = useNonNullContentType ? new StringSegment("text/plain") : new StringSegment(); 71ContentType = new StringSegment("text/plain"), 99ContentType = new StringSegment("text/plain"),
Formatters\OutputFormatterTests.cs (2)
63ContentType = new StringSegment(formatter.SupportedMediaTypes[0].ToString()), 92ContentType = new StringSegment(requestedContentType),
Formatters\StreamOutputFormatterTest.cs (3)
18var contentTypeHeader = new StringSegment(contentType); 43var contentTypeHeader = contentType == null ? new StringSegment() : new StringSegment(contentType);
Formatters\StringOutputFormatterTests.cs (7)
43var expectedContentType = new StringSegment(contentType); 50context.ContentType = new StringSegment(contentType); 76Assert.Equal(new StringSegment("text/plain"), context.ContentType); 86var expectedContentType = new StringSegment("text/plain"); 96context.ContentType = new StringSegment("text/plain"); 111var expectedContentType = new StringSegment("text/plain"); 118context.ContentType = new StringSegment("text/plain");
Formatters\SystemTextJsonOutputFormatterTest.cs (6)
51ContentType = new StringSegment(mediaType.ToString()), 79ContentType = new StringSegment(mediaType.ToString()), 106ContentType = new StringSegment(mediaType.ToString()), 135ContentType = new StringSegment(mediaType.ToString()), 197ContentType = new StringSegment(mediaType.ToString()), 237ContentType = new StringSegment(mediaType.ToString()),
Formatters\TextOutputFormatterTests.cs (10)
59ContentType = new StringSegment(httpRequest.Headers.Accept), 85ContentType = new StringSegment(contentType), 92Assert.Equal(new StringSegment(expectedContentType), formatterContext.ContentType); 107ContentType = new StringSegment("application/json"), 117formatterContext.ContentType = new StringSegment("application/json"); 138ContentType = new StringSegment("application/json; charset=utf-7"), 148Assert.Equal(new StringSegment("application/json; charset=utf-8"), formatterContext.ContentType); 164ContentType = new StringSegment(contentType), 183var testContentType = new StringSegment("text/json"); 215var testContentType = new StringSegment("text/json");
Infrastructure\DefaultOutputFormatterSelectorTest.cs (7)
43Assert.Equal(new StringSegment("application/json"), context.ContentType); 73Assert.Equal(new StringSegment("application/json"), context.ContentType); 173Assert.Equal(new StringSegment(expectedContentType), context.ContentType); 202Assert.Equal(new StringSegment("application/json"), context.ContentType); 232Assert.Equal(new StringSegment("application/xml"), context.ContentType); 329Assert.Equal(new StringSegment("text/custom2"), context.ContentType); 360Assert.Equal(new StringSegment("text/custom"), context.ContentType);
ProducesAttributeTests.cs (2)
20var mediaType1 = new StringSegment("application/json"); 21var mediaType2 = new StringSegment("text/json;charset=utf-8");
ProducesResponseTypeAttributeTests.cs (2)
15var mediaType1 = new StringSegment("application/json"); 16var mediaType2 = new StringSegment("text/json;charset=utf-8");
Microsoft.AspNetCore.Mvc.Core.TestCommon (4)
MediaTypeAssert.cs (4)
14Equal(new StringSegment(left), new StringSegment(right)); 19Equal(new StringSegment(left), right); 24Equal(left, new StringSegment(right));
Microsoft.AspNetCore.Mvc.Formatters.Xml.Test (8)
XmlDataContractSerializerOutputFormatterTest.cs (4)
125context.ContentType = new StringSegment("application/xml"); 384outputFormatterContext.ContentType = new StringSegment("application/xml"); 417outputFormatterContext.ContentType = new StringSegment(mediaType); 426Assert.Equal(new StringSegment(expectedContentType), outputFormatterContext.ContentType);
XmlSerializerOutputFormatterTest.cs (4)
133context.ContentType = new StringSegment("application/xml"); 357outputFormatterContext.ContentType = new StringSegment("application/xml"); 388outputFormatterContext.ContentType = new StringSegment(mediaType); 397Assert.Equal(new StringSegment(expectedContentType), outputFormatterContext.ContentType);
Microsoft.AspNetCore.Mvc.NewtonsoftJson.Test (8)
NewtonsoftJsonOutputFormatterTest.cs (3)
454ContentType = new StringSegment(mediaType.ToString()), 499ContentType = new StringSegment(mediaType.ToString()), 533ContentType = new StringSegment(mediaType.ToString()),
src\Mvc\Mvc.Core\test\Formatters\JsonOutputFormatterTestBase.cs (5)
46ContentType = new StringSegment(mediaType), 56Assert.Equal(new StringSegment(expectedContentType), outputFormatterContext.ContentType); 97ContentType = new StringSegment(mediaType.ToString()), 129ContentType = new StringSegment(mediaType.ToString()), 190ContentType = new StringSegment(contentType),
Microsoft.AspNetCore.Mvc.TagHelpers (3)
GlobbingUrlBuilder.cs (3)
293value = new StringSegment(value.Buffer, value.Offset + 2, value.Length - 2); 299value = new StringSegment(value.Buffer, value.Offset + 1, value.Length - 1); 335return new StringSegment(value.Buffer, offset, trimmedEnd - offset + 1);
Microsoft.AspNetCore.Owin (1)
DictionaryStringValuesWrapper.cs (1)
57HeaderUtilities.TryParseNonNegativeInt64(new StringSegment(rawValue[0]).Trim(), out value))
Microsoft.AspNetCore.Routing (21)
PathTokenizer.cs (3)
86return new StringSegment(_path, currentSegmentStart, delimiterIndex - currentSegmentStart); 100return new StringSegment(_path, currentSegmentStart, _path.Length - currentSegmentStart); 138return new StringSegment(_path, _index, _length);
src\Shared\MediaType\ReadOnlyMediaTypeHeaderValue.cs (18)
46Type = new StringSegment(); 47SubType = new StringSegment(); 48SubTypeWithoutSuffix = new StringSegment(); 49SubTypeSuffix = new StringSegment(); 60SubType = new StringSegment(); 61SubTypeWithoutSuffix = new StringSegment(); 62SubTypeSuffix = new StringSegment(); 77SubTypeSuffix = new StringSegment(); 107type = new StringSegment(input, current, typeLength); 136subType = new StringSegment(input, current, subtypeLength); 276return GetParameter(new StringSegment(parameterName)); 299return new StringSegment(); 333return GetEncoding(new StringSegment(mediaType)); 511var asterisk = new StringSegment("*"); 544name = new StringSegment(input, current, nameLength); 573value = new StringSegment(input, current + 1, valueLength - 2); 577value = new StringSegment(input, current, valueLength); 606return HasName(new StringSegment(name));
Microsoft.AspNetCore.Routing.Tests (18)
PathTokenizerTest.cs (18)
19{ "//", new StringSegment[] { new StringSegment("//", 1, 0) } }, 24new StringSegment("///", 1, 0), 25new StringSegment("///", 2, 0), 32new StringSegment("////", 1, 0), 33new StringSegment("////", 2, 0), 34new StringSegment("////", 3, 0), 37{ "/zero", new StringSegment[] { new StringSegment("/zero", 1, 4) } }, 38{ "/zero/", new StringSegment[] { new StringSegment("/zero/", 1, 4) } }, 43new StringSegment("/zero/one", 1, 4), 44new StringSegment("/zero/one", 6, 3), 51new StringSegment("/zero/one/", 1, 4), 52new StringSegment("/zero/one/", 6, 3), 59new StringSegment("/zero/one/two", 1, 4), 60new StringSegment("/zero/one/two", 6, 3), 61new StringSegment("/zero/one/two", 10, 3), 68new StringSegment("/zero/one/two/", 1, 4), 69new StringSegment("/zero/one/two/", 6, 3), 70new StringSegment("/zero/one/two/", 10, 3),
Microsoft.AspNetCore.Server.HttpSys (2)
src\Shared\HttpSys\RequestProcessing\HeaderCollection.cs (1)
132HeaderUtilities.TryParseNonNegativeInt64(new StringSegment(rawValue[0]).Trim(), out value))
src\Shared\HttpSys\RequestProcessing\RequestHeaders.cs (1)
188HeaderUtilities.TryParseNonNegativeInt64(new StringSegment(rawValue[0]).Trim(), out value))
Microsoft.AspNetCore.Server.IIS (2)
src\Shared\HttpSys\RequestProcessing\HeaderCollection.cs (1)
132HeaderUtilities.TryParseNonNegativeInt64(new StringSegment(rawValue[0]).Trim(), out value))
src\Shared\HttpSys\RequestProcessing\RequestHeaders.cs (1)
188HeaderUtilities.TryParseNonNegativeInt64(new StringSegment(rawValue[0]).Trim(), out value))
Microsoft.AspNetCore.Shared.Tests (2)
src\Shared\HttpSys\RequestProcessing\HeaderCollection.cs (1)
132HeaderUtilities.TryParseNonNegativeInt64(new StringSegment(rawValue[0]).Trim(), out value))
src\Shared\HttpSys\RequestProcessing\RequestHeaders.cs (1)
188HeaderUtilities.TryParseNonNegativeInt64(new StringSegment(rawValue[0]).Trim(), out value))
Microsoft.AspNetCore.WebUtilities (1)
MultipartReader.cs (1)
58boundary = HeaderUtilities.RemoveQuotes(new StringSegment(boundary)).ToString();
Microsoft.Extensions.FileProviders.Embedded (1)
Manifest\EmbeddedFilesManifest.cs (1)
73var trimmed = new StringSegment(path, start, end - start);
Microsoft.Extensions.Primitives (2)
StringSegment.cs (2)
307public static implicit operator StringSegment(string? value) => new StringSegment(value); 438return new StringSegment(Buffer, Offset + offset, length);
Microsoft.Net.Http.Headers (2)
HeaderUtilities.cs (1)
346if (TryParseNonNegativeInt64(new StringSegment(headerValue, startIndex, HttpRuleParser.GetNumberLength(headerValue, startIndex, false)), out result))
StringWithQualityHeaderValueComparer.cs (1)
17private static readonly StringSegment Any = new("*");
Microsoft.Net.Http.Headers.Tests (6)
HeaderUtilitiesTest.cs (2)
351var input = new StringSegment(inputString); 403var input = new StringSegment(inputString);
MediaTypeHeaderValueTest.cs (4)
56Assert.Equal(new StringSegment(expectedSubTypeWithoutSuffix), result.SubTypeWithoutSuffix); // TODO consider overloading to have SubTypeWithoutSuffix? 57Assert.Equal(new StringSegment(expectedSubTypeSuffix), result.Suffix); 77Assert.Equal(new StringSegment(expectedSubTypeWithoutSuffix), result.SubTypeWithoutSuffix); // TODO consider overloading to have SubTypeWithoutSuffix? 78Assert.Equal(new StringSegment(expectedSubTypeSuffix), result.Suffix);
855 references to StringSegment
Aspire.Dashboard (2)
Otlp\Http\OtlpHttpEndpointsBuilder.cs (2)
76private static KnownContentType GetKnownContentType(string? contentType, out StringSegment charSet) 113switch (GetKnownContentType(context.Request.ContentType, out var charSet))
Microsoft.AspNetCore.Authentication.Test (3)
OpenIdConnect\OpenIdConnectChallengeTests.cs (1)
453Assert.False(StringSegment.IsNullOrEmpty(correlationCookie.Value));
OpenIdConnect\OpenIdConnectEventTests.cs (1)
1018Assert.True(StringSegment.IsNullOrEmpty(parsedValues.Single().Value));
OpenIdConnect\OpenIdConnectEventTests_Handler.cs (1)
1018Assert.True(StringSegment.IsNullOrEmpty(parsedValues.Single().Value));
Microsoft.AspNetCore.Components (10)
src\Http\Routing\src\PathTokenizer.cs (6)
17internal struct PathTokenizer : IReadOnlyList<StringSegment> 71public StringSegment this[int index] 109IEnumerator<StringSegment> IEnumerable<StringSegment>.GetEnumerator() 119public struct Enumerator : IEnumerator<StringSegment> 134public StringSegment Current
src\Http\Routing\src\Patterns\RoutePatternMatcher.cs (4)
79foreach (var stringSegment in pathTokenizer) 147foreach (var requestSegment in pathTokenizer) 202private bool TryMatchLiterals(int index, StringSegment stringSegment, RoutePatternPathSegment pathSegment) 247private bool SavePathSegmentsAsValues(int index, RouteValueDictionary values, StringSegment requestSegment, RoutePatternPathSegment pathSegment)
Microsoft.AspNetCore.Components.WebAssembly.Server (14)
ContentEncodingNegotiator.cs (14)
15private static readonly StringSegment[] _preferredEncodings = 16new StringSegment[] { "br", "gzip" }; 18private static readonly Dictionary<StringSegment, string> _encodingExtensionMap = new Dictionary<StringSegment, string>(StringSegmentComparer.OrdinalIgnoreCase) 53var selectedEncoding = StringSegment.Empty; 58var encodingName = encoding.Value; 73if (StringSegment.Equals("*", encodingName, StringComparison.Ordinal)) 80if (StringSegment.Equals("identity", encodingName, StringComparison.OrdinalIgnoreCase)) 82selectedEncoding = StringSegment.Empty; 97StringSegment PickPreferredEncoding(HttpContext context, StringSegment selectedEncoding, StringWithQualityHeaderValue encoding) 99foreach (var preferredEncoding in _preferredEncodings) 112return StringSegment.Empty;
Microsoft.AspNetCore.Grpc.JsonTranscoding (3)
Internal\JsonRequestHelpers.cs (2)
28public static bool HasJsonContentType(HttpRequest request, out StringSegment charset) 67public static Encoding? GetEncodingFromCharset(StringSegment charset)
Internal\JsonTranscodingServerCallContext.cs (1)
51IsJsonRequestContent = JsonRequestHelpers.HasJsonContentType(HttpContext.Request, out var charset);
Microsoft.AspNetCore.HostFiltering (4)
HostFilteringMiddleware.cs (1)
101private bool CheckHostInAllowList(IList<StringSegment>? allowedHosts, string host)
MiddlewareConfigurationManager.cs (3)
13internal sealed record MiddlewareConfiguration(bool AllowAnyNonEmptyHost, bool AllowEmptyHosts, bool IncludeFailureMessage, ReadOnlyCollection<StringSegment>? AllowedHosts = default); 40var allowedHosts = new List<StringSegment>(); 62private static bool TryProcessHosts(IEnumerable<string> incoming, List<StringSegment> results)
Microsoft.AspNetCore.Http (26)
Features\FormFeature.cs (2)
380var boundary = HeaderUtilities.RemoveQuotes(contentType.Boundary); 381if (StringSegment.IsNullOrEmpty(boundary))
src\Http\Shared\CookieHeaderParserShared.cs (17)
37if (parsedName == null || StringSegment.IsNullOrEmpty(parsedName.Value) 38|| parsedValue == null || StringSegment.IsNullOrEmpty(parsedValue.Value)) 59public static bool TryParseValue(StringSegment value, ref int index, bool supportsMultipleValues, [NotNullWhen(true)] out StringSegment? parsedName, [NotNullWhen(true)] out StringSegment? parsedValue) 69if (StringSegment.IsNullOrEmpty(value) || (index == value.Length)) 108private static int GetNextNonEmptyOrWhitespaceIndex(StringSegment input, int startIndex, bool skipEmptyValues, out bool separatorFound) 140internal static bool TryGetCookieLength(StringSegment input, ref int offset, [NotNullWhen(true)] out StringSegment? parsedName, [NotNullWhen(true)] out StringSegment? parsedValue) 147if (StringSegment.IsNullOrEmpty(input) || (offset >= input.Length)) 182internal static StringSegment GetCookieValue(StringSegment input, ref int offset) 191return StringSegment.Empty; 216return StringSegment.Empty; 227return StringSegment.Empty; 230private static bool ReadEqualsSign(StringSegment input, ref int offset)
src\Shared\HttpRuleParser.cs (7)
54internal static int GetTokenLength(StringSegment input, int startIndex) 68internal static int GetWhitespaceLength(StringSegment input, int startIndex) 111internal static int GetNumberLength(StringSegment input, int startIndex, bool allowDecimal) 155internal static HttpParseResult GetQuotedStringLength(StringSegment input, int startIndex, out int length) 163internal static HttpParseResult GetQuotedPairLength(StringSegment input, int startIndex, out int length) 187internal static bool TryStringToDate(StringSegment input, out DateTimeOffset result) 211StringSegment input,
Microsoft.AspNetCore.Http.Abstractions (25)
HostString.cs (18)
95GetParts(_value, out var host, out _); 109GetParts(_value, out _, out var port); 111if (!StringSegment.IsNullOrEmpty(port) 147GetParts(_value, out var host, out var port); 151return StringSegment.IsNullOrEmpty(port) 225public static bool MatchesAny(StringSegment value, IList<StringSegment> patterns) 234GetParts(value, out var host, out var port); 247var pattern = patterns[i]; 254if (StringSegment.Equals(pattern, host, StringComparison.OrdinalIgnoreCase)) 263var allowedRoot = pattern.Subsegment(1); 265var hostRoot = host.Subsegment(host.Length - allowedRoot.Length); 341private static void GetParts(StringSegment value, out StringSegment host, out StringSegment port) 347if (StringSegment.IsNullOrEmpty(value))
Internal\HeaderSegment.cs (6)
10private readonly StringSegment _formatting; 11private readonly StringSegment _data; 16public HeaderSegment(StringSegment formatting, StringSegment data) 22public StringSegment Formatting 27public StringSegment Data
Internal\ParsingHelpers.cs (1)
25if (!StringSegment.IsNullOrEmpty(segment.Data))
Microsoft.AspNetCore.Http.Abstractions.Tests (3)
HostStringTest.cs (3)
146Assert.True(HostString.MatchesAny(host, new StringSegment[] { pattern })); 165Assert.False(HostString.MatchesAny(host, new StringSegment[] { pattern })); 171Assert.Throws<FormatException>(() => HostString.MatchesAny("example.com:1abc", new StringSegment[] { "example.com" }));
Microsoft.AspNetCore.Http.Extensions (9)
HttpRequestJsonExtensions.cs (9)
63if (!request.HasJsonContentType(out var charset)) 103if (!request.HasJsonContentType(out var charset)) 141if (!request.HasJsonContentType(out var charset)) 201if (!request.HasJsonContentType(out var charset)) 245if (!request.HasJsonContentType(out var charset)) 275private static bool HasJsonContentType(this HttpRequest request, out StringSegment charset) 281charset = StringSegment.Empty; 299charset = StringSegment.Empty; 326private static Encoding? GetEncodingFromCharset(StringSegment charset)
Microsoft.AspNetCore.Http.Microbenchmarks (2)
HeaderUtilitiesBenchmark.cs (2)
12public StringSegment UnescapeAsQuotedString() 18public StringSegment EscapeAsQuotedString()
Microsoft.AspNetCore.HttpOverrides (2)
ForwardedHeadersMiddleware.cs (2)
25private IList<StringSegment>? _allowedHosts; 77var allowedHosts = new List<StringSegment>();
Microsoft.AspNetCore.HttpsPolicy (4)
HstsMiddleware.cs (4)
42var includeSubdomains = hstsOptions.IncludeSubDomains ? IncludeSubDomains : StringSegment.Empty; 43var preload = hstsOptions.Preload ? Preload : StringSegment.Empty;
Microsoft.AspNetCore.Localization (19)
ProviderCultureResult.cs (12)
18public ProviderCultureResult(StringSegment culture) 19: this(new List<StringSegment> { culture }, new List<StringSegment> { culture }) 29public ProviderCultureResult(StringSegment culture, StringSegment uiCulture) 30: this(new List<StringSegment> { culture }, new List<StringSegment> { uiCulture }) 39public ProviderCultureResult(IList<StringSegment> cultures) 50public ProviderCultureResult(IList<StringSegment> cultures, IList<StringSegment> uiCultures) 59public IList<StringSegment> Cultures { get; } 64public IList<StringSegment> UICultures { get; }
RequestCultureProviderLoggerExtensions.cs (2)
12public static partial void UnsupportedCultures(this ILogger logger, string requestCultureProvider, IList<StringSegment> cultures); 15public static partial void UnsupportedUICultures(this ILogger logger, string requestCultureProvider, IList<StringSegment> uiCultures);
RequestLocalizationMiddleware.cs (5)
130IList<StringSegment> cultureNames, 134foreach (var cultureName in cultureNames) 152StringSegment cultureName, 182private static CultureInfo? GetCultureInfo(StringSegment name, IList<CultureInfo>? supportedCultures) 192supportedCulture => StringSegment.Equals(supportedCulture.Name, name, StringComparison.OrdinalIgnoreCase));
Microsoft.AspNetCore.Mvc.Abstractions (11)
Formatters\OutputFormatterCanWriteContext.cs (1)
39public virtual StringSegment ContentType { get; set; }
ModelBinding\ModelStateDictionary.cs (10)
63var emptySegment = new StringSegment(buffer: string.Empty); 535var subKey = FindNext(key, ref match); 572var subKey = FindNext(key, ref match); 590private static StringSegment FindNext(string key, ref MatchResult currentMatch) 832public ModelStateNode(StringSegment subKey) 843public StringSegment SubKey { get; } 875public ModelStateNode? GetNode(StringSegment subKey) 895public ModelStateNode GetOrAddNode(StringSegment subKey) 928private int BinarySearch(StringSegment searchKey) 937var midKey = ChildNodes[mid].SubKey;
Microsoft.AspNetCore.Mvc.Core (87)
Formatters\MediaType.cs (31)
18private static readonly StringSegment QualityParameter = new StringSegment("q"); 34/// <param name="mediaType">The <see cref="StringSegment"/> with the media type.</param> 35public MediaType(StringSegment mediaType) 77public StringSegment Type => _mediaTypeHeaderValue.Type; 91public StringSegment SubType => _mediaTypeHeaderValue.SubType; 100public StringSegment SubTypeWithoutSuffix => _mediaTypeHeaderValue.SubTypeWithoutSuffix; 109public StringSegment SubTypeSuffix => _mediaTypeHeaderValue.SubTypeSuffix; 141public StringSegment Charset => _mediaTypeHeaderValue.Charset; 167/// The <see cref="StringSegment"/>for the given <paramref name="parameterName"/> if found; otherwise 170public StringSegment GetParameter(string parameterName) 178/// The <see cref="StringSegment"/>for the given <paramref name="parameterName"/> if found; otherwise 181public StringSegment GetParameter(StringSegment parameterName) 205public static string ReplaceEncoding(StringSegment mediaType, Encoding encoding) 208var charset = parsedMediaType.GetParameter("charset"); 247public static Encoding? GetEncoding(StringSegment mediaType) 266if (parsedMediaType.Type.Equals(default(StringSegment)) || 267parsedMediaType.SubType.Equals(default(StringSegment))) 298private static string CreateMediaTypeWithEncoding(StringSegment mediaType, Encoding encoding) 349var nameLength = GetNameLength(input, startIndex, out var name); 359var asterisk = new StringSegment("*"); 370var valueLength = GetValueLength(input, current, out var value); 378private static int GetNameLength(string input, int startIndex, out StringSegment name) 388name = default(StringSegment); 400private static int GetValueLength(string input, int startIndex, out StringSegment value) 416value = default(StringSegment); 442public MediaTypeParameter(StringSegment name, StringSegment value) 448public StringSegment Name { get; } 450public StringSegment Value { get; } 457public bool HasName(StringSegment name)
Formatters\MediaTypeSegmentWithQuality.cs (3)
16/// <param name="mediaType">The <see cref="StringSegment"/> containing the media type.</param> 18public MediaTypeSegmentWithQuality(StringSegment mediaType, double quality) 27public StringSegment MediaType { get; }
Formatters\TextOutputFormatter.cs (4)
84var contentTypeCharset = parsedContentType.Charset; 107var selectedMediaType = context.ContentType; 199var charset = acceptValues[i].Value; 200if (!StringSegment.IsNullOrEmpty(charset))
Routing\ViewEnginePath.cs (5)
49var pathSegment = new StringSegment(path); 59foreach (var segment in tokenizer) 77var pathSegments = new List<StringSegment>(); 78foreach (var segment in tokenizer) 109var segment = pathSegments[i];
src\Shared\HttpRuleParser.cs (7)
54internal static int GetTokenLength(StringSegment input, int startIndex) 68internal static int GetWhitespaceLength(StringSegment input, int startIndex) 111internal static int GetNumberLength(StringSegment input, int startIndex, bool allowDecimal) 155internal static HttpParseResult GetQuotedStringLength(StringSegment input, int startIndex, out int length) 163internal static HttpParseResult GetQuotedPairLength(StringSegment input, int startIndex, out int length) 187internal static bool TryStringToDate(StringSegment input, out DateTimeOffset result) 211StringSegment input,
src\Shared\MediaType\ReadOnlyMediaTypeHeaderValue.cs (37)
27/// <param name="mediaType">The <see cref="StringSegment"/> with the media type.</param> 28public ReadOnlyMediaTypeHeaderValue(StringSegment mediaType) 43var typeLength = GetTypeLength(mediaType, offset, out var type); 57var subTypeLength = GetSubtypeLength(mediaType, offset + typeLength, out var subType); 89private static int GetTypeLength(string input, int offset, out StringSegment type) 93type = default(StringSegment); 103type = default(StringSegment); 115private static int GetSubtypeLength(string input, int offset, out StringSegment subType) 122subType = default(StringSegment); 132subType = default(StringSegment); 144private static bool TryGetSuffixLength(StringSegment subType, out int suffixLength) 167public StringSegment Type { get; } 181public StringSegment SubType { get; } 190public StringSegment SubTypeWithoutSuffix { get; } 199public StringSegment SubTypeSuffix { get; } 231public StringSegment Charset => GetParameter("charset"); 271/// The <see cref="StringSegment"/>for the given <paramref name="parameterName"/> if found; otherwise 274public StringSegment GetParameter(string parameterName) 284/// The <see cref="StringSegment"/>for the given <paramref name="parameterName"/> if found; otherwise 287public StringSegment GetParameter(StringSegment parameterName) 310public bool TryGetLastParameter(StringSegment parameterName, out StringSegment parameterValue) 341public static Encoding? GetEncoding(StringSegment mediaType) 347private static Encoding? GetEncodingFromCharset(StringSegment charset) 501var nameLength = GetNameLength(input, startIndex, out var name); 511var asterisk = new StringSegment("*"); 522var valueLength = GetValueLength(input, current, out var value); 530private static int GetNameLength(string input, int startIndex, out StringSegment name) 540name = default(StringSegment); 552private static int GetValueLength(string input, int startIndex, out StringSegment value) 568value = default(StringSegment); 594public MediaTypeParameter(StringSegment name, StringSegment value) 600public StringSegment Name { get; } 602public StringSegment Value { get; } 609public bool HasName(StringSegment name)
Microsoft.AspNetCore.Mvc.Core.Test (23)
Formatters\FormatFilterTest.cs (4)
34var mediaType = new StringSegment("application/json"); 63var mediaType = new StringSegment("application/json"); 111var mediaType = new StringSegment(contentType); 325var mediaType = new StringSegment("application/foo");
Formatters\MediaTypeTest.cs (5)
157var expectedParameter = new StringSegment("utf-8"); 161var result = parsedMediaType.GetParameter("charset"); 175var result = parsedMediaType.GetParameter("other"); 186var expectedParameter = new StringSegment("utf-8"); 191var result = parsedMediaType.GetParameter("CHARSET");
Formatters\NoContentFormatterTests.cs (1)
39var contentType = useNonNullContentType ? new StringSegment("text/plain") : new StringSegment();
Formatters\StreamOutputFormatterTest.cs (2)
18var contentTypeHeader = new StringSegment(contentType); 43var contentTypeHeader = contentType == null ? new StringSegment() : new StringSegment(contentType);
Formatters\StringOutputFormatterTests.cs (3)
43var expectedContentType = new StringSegment(contentType); 86var expectedContentType = new StringSegment("text/plain"); 111var expectedContentType = new StringSegment("text/plain");
Formatters\TextOutputFormatterTests.cs (4)
115var firstContentType = formatterContext.ContentType; 120var secondContentType = formatterContext.ContentType; 183var testContentType = new StringSegment("text/json"); 215var testContentType = new StringSegment("text/json");
ProducesAttributeTests.cs (2)
20var mediaType1 = new StringSegment("application/json"); 21var mediaType2 = new StringSegment("text/json;charset=utf-8");
ProducesResponseTypeAttributeTests.cs (2)
15var mediaType1 = new StringSegment("application/json"); 16var mediaType2 = new StringSegment("text/json;charset=utf-8");
Microsoft.AspNetCore.Mvc.Core.TestCommon (4)
MediaTypeAssert.cs (4)
17public static void Equal(string left, StringSegment right) 22public static void Equal(StringSegment left, string right) 27public static void Equal(StringSegment left, StringSegment right)
Microsoft.AspNetCore.Mvc.TagHelpers (17)
Cache\CacheTagKey.cs (2)
279foreach (var item in tokenizer) 281var trimmedValue = item.Trim();
EnvironmentTagHelper.cs (6)
91foreach (var item in tokenizer) 93var environment = item.Trim(); 110foreach (var item in tokenizer) 112var environment = item.Trim(); 128foreach (var item in tokenizer) 130var environment = item.Trim();
GlobbingUrlBuilder.cs (9)
121foreach (var includePattern in includeTokenizer) 134foreach (var excludePattern in excludeTokenizer) 230while (TryGetNextSegment(ref xEnumerator, out var xSegment)) 232if (!TryGetNextSegment(ref yEnumerator, out var ySegment)) 267private static bool TryGetNextSegment(ref StringTokenizer.Enumerator enumerator, out StringSegment segment) 278segment = default(StringSegment); 283private static string NormalizePath(StringSegment value) 311private static StringSegment Trim(StringSegment value)
Microsoft.AspNetCore.OutputCaching (1)
OutputCacheMiddleware.cs (1)
528if (ifNoneMatchHeader.Count == 1 && StringSegment.Equals(ifNoneMatchHeader[0], EntityTagHeaderValue.Any.Tag, StringComparison.OrdinalIgnoreCase))
Microsoft.AspNetCore.ResponseCaching (1)
ResponseCachingMiddleware.cs (1)
435if (ifNoneMatchHeader.Count == 1 && StringSegment.Equals(ifNoneMatchHeader[0], EntityTagHeaderValue.Any.Tag, StringComparison.OrdinalIgnoreCase))
Microsoft.AspNetCore.ResponseCompression (4)
ResponseCompressionProvider.cs (4)
98var encodingName = encoding.Value; 110if (StringSegment.Equals(provider.EncodingName, encodingName, StringComparison.OrdinalIgnoreCase)) 117if (StringSegment.Equals("*", encodingName, StringComparison.Ordinal)) 130if (StringSegment.Equals("identity", encodingName, StringComparison.OrdinalIgnoreCase))
Microsoft.AspNetCore.Routing (54)
PathTokenizer.cs (6)
17internal struct PathTokenizer : IReadOnlyList<StringSegment> 71public StringSegment this[int index] 109IEnumerator<StringSegment> IEnumerable<StringSegment>.GetEnumerator() 119public struct Enumerator : IEnumerator<StringSegment> 134public StringSegment Current
Patterns\RoutePatternMatcher.cs (4)
79foreach (var stringSegment in pathTokenizer) 147foreach (var requestSegment in pathTokenizer) 202private bool TryMatchLiterals(int index, StringSegment stringSegment, RoutePatternPathSegment pathSegment) 247private bool SavePathSegmentsAsValues(int index, RouteValueDictionary values, StringSegment requestSegment, RoutePatternPathSegment pathSegment)
src\Shared\HttpRuleParser.cs (7)
54internal static int GetTokenLength(StringSegment input, int startIndex) 68internal static int GetWhitespaceLength(StringSegment input, int startIndex) 111internal static int GetNumberLength(StringSegment input, int startIndex, bool allowDecimal) 155internal static HttpParseResult GetQuotedStringLength(StringSegment input, int startIndex, out int length) 163internal static HttpParseResult GetQuotedPairLength(StringSegment input, int startIndex, out int length) 187internal static bool TryStringToDate(StringSegment input, out DateTimeOffset result) 211StringSegment input,
src\Shared\MediaType\ReadOnlyMediaTypeHeaderValue.cs (37)
27/// <param name="mediaType">The <see cref="StringSegment"/> with the media type.</param> 28public ReadOnlyMediaTypeHeaderValue(StringSegment mediaType) 43var typeLength = GetTypeLength(mediaType, offset, out var type); 57var subTypeLength = GetSubtypeLength(mediaType, offset + typeLength, out var subType); 89private static int GetTypeLength(string input, int offset, out StringSegment type) 93type = default(StringSegment); 103type = default(StringSegment); 115private static int GetSubtypeLength(string input, int offset, out StringSegment subType) 122subType = default(StringSegment); 132subType = default(StringSegment); 144private static bool TryGetSuffixLength(StringSegment subType, out int suffixLength) 167public StringSegment Type { get; } 181public StringSegment SubType { get; } 190public StringSegment SubTypeWithoutSuffix { get; } 199public StringSegment SubTypeSuffix { get; } 231public StringSegment Charset => GetParameter("charset"); 271/// The <see cref="StringSegment"/>for the given <paramref name="parameterName"/> if found; otherwise 274public StringSegment GetParameter(string parameterName) 284/// The <see cref="StringSegment"/>for the given <paramref name="parameterName"/> if found; otherwise 287public StringSegment GetParameter(StringSegment parameterName) 310public bool TryGetLastParameter(StringSegment parameterName, out StringSegment parameterValue) 341public static Encoding? GetEncoding(StringSegment mediaType) 347private static Encoding? GetEncodingFromCharset(StringSegment charset) 501var nameLength = GetNameLength(input, startIndex, out var name); 511var asterisk = new StringSegment("*"); 522var valueLength = GetValueLength(input, current, out var value); 530private static int GetNameLength(string input, int startIndex, out StringSegment name) 540name = default(StringSegment); 552private static int GetValueLength(string input, int startIndex, out StringSegment value) 568value = default(StringSegment); 594public MediaTypeParameter(StringSegment name, StringSegment value) 600public StringSegment Name { get; } 602public StringSegment Value { get; } 609public bool HasName(StringSegment name)
Microsoft.AspNetCore.Routing.Tests (17)
PathTokenizerTest.cs (17)
11public static TheoryData<string, StringSegment[]> TokenizationData 15return new TheoryData<string, StringSegment[]> 17{ string.Empty, new StringSegment[] { } }, 18{ "/", new StringSegment[] { } }, 19{ "//", new StringSegment[] { new StringSegment("//", 1, 0) } }, 22new StringSegment[] 30new StringSegment[] 37{ "/zero", new StringSegment[] { new StringSegment("/zero", 1, 4) } }, 38{ "/zero/", new StringSegment[] { new StringSegment("/zero/", 1, 4) } }, 41new StringSegment[] 49new StringSegment[] 57new StringSegment[] 66new StringSegment[] 79public void PathTokenizer_Count(string path, StringSegment[] expectedSegments) 93public void PathTokenizer_Indexer(string path, StringSegment[] expectedSegments) 107public void PathTokenizer_Enumerator(string path, StringSegment[] expectedSegments) 113Assert.Equal<StringSegment>(expectedSegments, tokenizer);
Microsoft.Extensions.FileProviders.Embedded (9)
Manifest\EmbeddedFilesManifest.cs (5)
41var trimmed = RemoveLeadingAndTrailingDirectorySeparators(path); 50foreach (var segment in tokenizer) 63private static StringSegment RemoveLeadingAndTrailingDirectorySeparators(string path) 69return StringSegment.Empty; 73var trimmed = new StringSegment(path, start, end - start);
Manifest\ManifestDirectory.cs (1)
23public override ManifestEntry Traverse(StringSegment segment)
Manifest\ManifestEntry.cs (1)
32public abstract ManifestEntry Traverse(StringSegment segment);
Manifest\ManifestFile.cs (1)
23public override ManifestEntry Traverse(StringSegment segment) => UnknownPath;
Manifest\ManifestSinkDirectory.cs (1)
20public override ManifestEntry Traverse(StringSegment segment) => this;
Microsoft.Extensions.FileProviders.Physical (1)
Internal\PathUtils.cs (1)
59foreach (StringSegment segment in tokenizer)
Microsoft.Extensions.Primitives (147)
Extensions.cs (3)
14/// Adds the given <see cref="StringSegment"/> to the <see cref="StringBuilder"/>. 17/// <param name="segment">The <see cref="StringSegment"/> to add.</param> 19public static StringBuilder Append(this StringBuilder builder, StringSegment segment)
InplaceStringBuilder.cs (1)
78public void Append(StringSegment segment)
StringSegment.cs (105)
15public readonly struct StringSegment : IEquatable<StringSegment>, IEquatable<string?> 18/// A <see cref="StringSegment"/> for <see cref="string.Empty"/>. 20public static readonly StringSegment Empty = string.Empty; 23/// Initializes an instance of the <see cref="StringSegment"/> struct. 26/// The original <see cref="string"/>. The <see cref="StringSegment"/> includes the whole <see cref="string"/>. 36/// Initializes an instance of the <see cref="StringSegment"/> struct. 65/// Gets the <see cref="string"/> buffer for this <see cref="StringSegment"/>. 70/// Gets the offset within the buffer for this <see cref="StringSegment"/>. 75/// Gets the length of this <see cref="StringSegment"/>. 85/// Gets whether this <see cref="StringSegment"/> contains a valid value. 92/// Gets the <see cref="char"/> at a specified position in the current <see cref="StringSegment"/>. 94/// <param name="index">The offset into the <see cref="StringSegment"/></param> 114/// Gets a <see cref="ReadOnlySpan{T}"/> from the current <see cref="StringSegment"/>. 116/// <returns>The <see cref="ReadOnlySpan{T}"/> from this <see cref="StringSegment"/>.</returns> 120/// Gets a <see cref="ReadOnlySpan{T}"/> from the current <see cref="StringSegment"/> that starts 123/// <param name="start">The zero-based starting character position in this <see cref="StringSegment"/>.</param> 125/// this <see cref="StringSegment"/>.</returns> 140/// Gets a <see cref="ReadOnlySpan{T}"/> from the current <see cref="StringSegment"/> that starts 143/// <param name="start">The zero-based starting character position in this <see cref="StringSegment"/>.</param> 146/// <paramref name="start"/> in this <see cref="StringSegment"/>.</returns> 162/// Gets a <see cref="ReadOnlyMemory{T}"/> from the current <see cref="StringSegment"/>. 164/// <returns>The <see cref="ReadOnlyMemory{T}"/> from this <see cref="StringSegment"/>.</returns> 168/// Compares substrings of two specified <see cref="StringSegment"/> objects using the specified rules, 171/// <param name="a">The first <see cref="StringSegment"/> to compare.</param> 172/// <param name="b">The second <see cref="StringSegment"/> to compare.</param> 179public static int Compare(StringSegment a, StringSegment b, StringComparison comparisonType) 199return obj is StringSegment segment && Equals(segment); 207public bool Equals(StringSegment other) => Equals(other, StringComparison.Ordinal); 215public bool Equals(StringSegment other, StringComparison comparisonType) 231/// Determines whether two specified <see cref="StringSegment"/> objects have the same value. A parameter specifies the culture, case, and 234/// <param name="a">The first <see cref="StringSegment"/> to compare.</param> 235/// <param name="b">The second <see cref="StringSegment"/> to compare.</param> 238public static bool Equals(StringSegment a, StringSegment b, StringComparison comparisonType) => a.Equals(b, comparisonType); 241/// Checks if the specified <see cref="string"/> is equal to the current <see cref="StringSegment"/>. 243/// <param name="text">The <see cref="string"/> to compare with the current <see cref="StringSegment"/>.</param> 244/// <returns><see langword="true" /> if the specified <see cref="string"/> is equal to the current <see cref="StringSegment"/>; otherwise, <see langword="false" />.</returns> 248/// Checks if the specified <see cref="string"/> is equal to the current <see cref="StringSegment"/>. 250/// <param name="text">The <see cref="string"/> to compare with the current <see cref="StringSegment"/>.</param> 252/// <returns><see langword="true" /> if the specified <see cref="string"/> is equal to the current <see cref="StringSegment"/>; otherwise, <see langword="false" />.</returns> 287/// Checks if two specified <see cref="StringSegment"/> have the same value. 289/// <param name="left">The first <see cref="StringSegment"/> to compare, or <see langword="null" />.</param> 290/// <param name="right">The second <see cref="StringSegment"/> to compare, or <see langword="null" />.</param> 292public static bool operator ==(StringSegment left, StringSegment right) => left.Equals(right); 295/// Checks if two specified <see cref="StringSegment"/> have different values. 297/// <param name="left">The first <see cref="StringSegment"/> to compare, or <see langword="null" />.</param> 298/// <param name="right">The second <see cref="StringSegment"/> to compare, or <see langword="null" />.</param> 300public static bool operator !=(StringSegment left, StringSegment right) => !left.Equals(right); 304/// Creates a new <see cref="StringSegment"/> from the given <see cref="string"/>. 306/// <param name="value">The <see cref="string"/> to convert to a <see cref="StringSegment"/>.</param> 307public static implicit operator StringSegment(string? value) => new StringSegment(value); 310/// Creates a see <see cref="ReadOnlySpan{T}"/> from the given <see cref="StringSegment"/>. 312/// <param name="segment">The <see cref="StringSegment"/> to convert to a <see cref="ReadOnlySpan{T}"/>.</param> 313public static implicit operator ReadOnlySpan<char>(StringSegment segment) => segment.AsSpan(); 316/// Creates a see <see cref="ReadOnlyMemory{T}"/> from the given <see cref="StringSegment"/>. 318/// <param name="segment">The <see cref="StringSegment"/> to convert to a <see cref="ReadOnlyMemory{T}"/>.</param> 319public static implicit operator ReadOnlyMemory<char>(StringSegment segment) => segment.AsMemory(); 322/// Checks if the beginning of this <see cref="StringSegment"/> matches the specified <see cref="string"/> when compared using the specified <paramref name="comparisonType"/>. 326/// <returns><see langword="true" /> if <paramref name="text"/> matches the beginning of this <see cref="StringSegment"/>; otherwise, <see langword="false" />.</returns> 348/// Checks if the end of this <see cref="StringSegment"/> matches the specified <see cref="string"/> when compared using the specified <paramref name="comparisonType"/>. 352/// <returns><see langword="true" /> if <paramref name="text"/> matches the end of this <see cref="StringSegment"/>; otherwise, <see langword="false" />.</returns> 374/// Retrieves a substring from this <see cref="StringSegment"/>. 377/// <param name="offset">The zero-based starting character position of a substring in this <see cref="StringSegment"/>.</param> 379/// <paramref name="offset"/> in this <see cref="StringSegment"/>.</returns> 386/// Retrieves a substring from this <see cref="StringSegment"/>. 389/// <param name="offset">The zero-based starting character position of a substring in this <see cref="StringSegment"/>.</param> 392/// <paramref name="offset"/> in this <see cref="StringSegment"/>.</returns> 409/// Retrieves a <see cref="StringSegment"/> that represents a substring from this <see cref="StringSegment"/>. 410/// The <see cref="StringSegment"/> starts at the position specified by <paramref name="offset"/>. 412/// <param name="offset">The zero-based starting character position of a substring in this <see cref="StringSegment"/>.</param> 413/// <returns>A <see cref="StringSegment"/> that begins at <paramref name="offset"/> in this <see cref="StringSegment"/> 418public StringSegment Subsegment(int offset) => Subsegment(offset, Length - offset); 421/// Retrieves a <see cref="StringSegment"/> that represents a substring from this <see cref="StringSegment"/>. 422/// The <see cref="StringSegment"/> starts at the position specified by <paramref name="offset"/> and has the specified <paramref name="length"/>. 424/// <param name="offset">The zero-based starting character position of a substring in this <see cref="StringSegment"/>.</param> 426/// <returns>A <see cref="StringSegment"/> that is equivalent to the substring of <paramref name="length"/> that begins at <paramref name="offset"/> in this <see cref="StringSegment"/>.</returns> 431public StringSegment Subsegment(int offset, int length) 442/// Gets the zero-based index of the first occurrence of the character <paramref name="c"/> in this <see cref="StringSegment"/>. 448/// <returns>The zero-based index position of <paramref name="c"/> from the beginning of the <see cref="StringSegment"/> if that character is found, or -1 if it is not.</returns> 481/// Gets the zero-based index of the first occurrence of the character <paramref name="c"/> in this <see cref="StringSegment"/>. 486/// <returns>The zero-based index position of <paramref name="c"/> from the beginning of the <see cref="StringSegment"/> if that character is found, or -1 if it is not.</returns> 493/// Gets the zero-based index of the first occurrence of the character <paramref name="c"/> in this <see cref="StringSegment"/>. 496/// <returns>The zero-based index position of <paramref name="c"/> from the beginning of the <see cref="StringSegment"/> if that character is found, or -1 if it is not.</returns> 584/// <returns>The trimmed <see cref="StringSegment"/>.</returns> 585public StringSegment Trim() => TrimStart().TrimEnd(); 590/// <returns>The trimmed <see cref="StringSegment"/>.</returns> 591public StringSegment TrimStart() 610/// <returns>The trimmed <see cref="StringSegment"/>.</returns> 611public StringSegment TrimEnd() 628/// Splits a string into <see cref="StringSegment"/>s that are based on the characters in an array. 632/// <returns>An <see cref="StringTokenizer"/> whose elements contain the <see cref="StringSegment"/>s from this instance 640/// Indicates whether the specified <see cref="StringSegment"/> is null or an Empty string. 642/// <param name="value">The <see cref="StringSegment"/> to test.</param> 644public static bool IsNullOrEmpty(StringSegment value) 657/// Returns the <see cref="string"/> represented by this <see cref="StringSegment"/> or <see cref="string.Empty" /> if the <see cref="StringSegment"/> does not contain a value. 659/// <returns>The <see cref="string"/> represented by this <see cref="StringSegment"/> or <see cref="string.Empty" /> if the <see cref="StringSegment"/> does not contain a value.</returns>
StringSegmentComparer.cs (22)
10/// Compares two <see cref="StringSegment"/> objects. 12public class StringSegmentComparer : IComparer<StringSegment>, IEqualityComparer<StringSegment> 15/// Gets a <see cref="StringSegmentComparer"/> object that performs a case-sensitive ordinal <see cref="StringSegment"/> comparison. 21/// Gets a <see cref="StringSegmentComparer"/> object that performs a case-insensitive ordinal <see cref="StringSegment"/> comparison. 36/// Compares two <see cref="StringSegment"/> objects and returns an indication of their relative sort order. 38/// <param name="x">The first <see cref="StringSegment"/> to compare.</param> 39/// <param name="y">The second <see cref="StringSegment"/> to compare.</param> 41public int Compare(StringSegment x, StringSegment y) 43return StringSegment.Compare(x, y, Comparison); 47/// Determines whether two <see cref="StringSegment"/> objects are equal. 49/// <param name="x">The first <see cref="StringSegment"/> to compare.</param> 50/// <param name="y">The second <see cref="StringSegment"/> to compare.</param> 51/// <returns><see langword="true"/> if the two <see cref="StringSegment"/> objects are equal; otherwise, <see langword="false"/>.</returns> 52public bool Equals(StringSegment x, StringSegment y) 54return StringSegment.Equals(x, y, Comparison); 58/// Returns a hash code for a <see cref="StringSegment"/> object. 60/// <param name="obj">The <see cref="StringSegment"/> to get a hash code for.</param> 61/// <returns>A hash code for a <see cref="StringSegment"/>, suitable for use in hashing algorithms and data structures like a hash table.</returns> 62public int GetHashCode(StringSegment obj)
StringTokenizer.cs (16)
11/// Tokenizes a <see cref="string"/> into <see cref="StringSegment">StringSegments</see>. 13public readonly struct StringTokenizer : IEnumerable<StringSegment> 15private readonly StringSegment _value; 42/// <param name="value">The <see cref="StringSegment"/> to tokenize.</param> 44public StringTokenizer(StringSegment value, char[] separators) 66IEnumerator<StringSegment> IEnumerable<StringSegment>.GetEnumerator() => GetEnumerator(); 71/// Enumerates the <see cref="string"/> tokens represented by <see cref="StringSegment"/>. 73public struct Enumerator : IEnumerator<StringSegment> 75private readonly StringSegment _value; 79internal Enumerator(in StringSegment value, char[] separators) 95Current = default(StringSegment); 100/// Gets the current <see cref="StringSegment"/> from the <see cref="StringTokenizer"/>. 102public StringSegment Current { get; private set; } 121Current = default(StringSegment); 143Current = default(StringSegment);
Microsoft.Net.Http.Headers (333)
BaseHeaderParser.cs (3)
15protected abstract int GetParsedValueLength(StringSegment value, int startIndex, out T? parsedValue); 17public sealed override bool TryParseValue(StringSegment value, ref int index, out T? parsedValue) 26if (StringSegment.IsNullOrEmpty(value) || (index == value.Length))
CacheControlHeaderValue.cs (32)
85private static readonly Action<StringSegment> CheckIsValidTokenAction = CheckIsValidToken; 88private ICollection<StringSegment>? _noCacheHeaders; 99private ICollection<StringSegment>? _privateHeaders; 129public ICollection<StringSegment> NoCacheHeaders 135_noCacheHeaders = new ObjectCollection<StringSegment>(CheckIsValidTokenAction); 275public ICollection<StringSegment> PrivateHeaders 281_privateHeaders = new ObjectCollection<StringSegment>(CheckIsValidTokenAction); 458foreach (var noCacheHeader in _noCacheHeaders) 466foreach (var privateHeader in _privateHeaders) 488public static CacheControlHeaderValue Parse(StringSegment input) 506public static bool TryParse(StringSegment input, [NotNullWhen(true)] out CacheControlHeaderValue? parsedValue) 518private static int GetCacheControlLength(StringSegment input, int startIndex, out CacheControlHeaderValue? parsedValue) 524if (StringSegment.IsNullOrEmpty(input) || (startIndex >= input.Length)) 571var name = nameValue.Name; 577if (StringSegment.Equals(PublicString, name, StringComparison.OrdinalIgnoreCase)) 588if (StringSegment.Equals(MaxAgeString, name, StringComparison.OrdinalIgnoreCase)) 592else if (StringSegment.Equals(PrivateString, name, StringComparison.OrdinalIgnoreCase)) 603if (StringSegment.Equals(NoCacheString, name, StringComparison.OrdinalIgnoreCase)) 607else if (StringSegment.Equals(NoStoreString, name, StringComparison.OrdinalIgnoreCase)) 611else if (StringSegment.Equals(SharedMaxAgeString, name, StringComparison.OrdinalIgnoreCase)) 622if (StringSegment.Equals(MaxStaleString, name, StringComparison.OrdinalIgnoreCase)) 630else if (StringSegment.Equals(MinFreshString, name, StringComparison.OrdinalIgnoreCase)) 641if (StringSegment.Equals(NoTransformString, name, StringComparison.OrdinalIgnoreCase)) 652if (StringSegment.Equals(OnlyIfCachedString, name, StringComparison.OrdinalIgnoreCase)) 663if (StringSegment.Equals(MustRevalidateString, name, StringComparison.OrdinalIgnoreCase)) 674if (StringSegment.Equals(ProxyRevalidateString, name, StringComparison.OrdinalIgnoreCase)) 712ref ICollection<StringSegment>? destination) 722var valueString = nameValue.Value; 753destination = new ObjectCollection<StringSegment>(CheckIsValidTokenAction); 806private static void AppendValues(StringBuilder sb, IEnumerable<StringSegment> values) 809foreach (var value in values) 824private static void CheckIsValidToken(StringSegment item)
ContentDispositionHeaderValue.cs (43)
48private StringSegment _dispositionType; 58/// <param name="dispositionType">A <see cref="StringSegment"/> that represents a content disposition type.</param> 59public ContentDispositionHeaderValue(StringSegment dispositionType) 68public StringSegment DispositionType 98public StringSegment Name 108public StringSegment FileName 118public StringSegment FileNameStar 161var sizeString = sizeParameter.Value; 200public void SetHttpFileName(StringSegment fileName) 202if (!StringSegment.IsNullOrEmpty(fileName)) 218public void SetMimeFileName(StringSegment fileName) 256public static ContentDispositionHeaderValue Parse(StringSegment input) 268public static bool TryParse(StringSegment input, [NotNullWhen(true)] out ContentDispositionHeaderValue? parsedValue) 274private static int GetDispositionTypeLength(StringSegment input, int startIndex, out ContentDispositionHeaderValue? parsedValue) 280if (StringSegment.IsNullOrEmpty(input) || (startIndex >= input.Length)) 286var dispositionTypeLength = GetDispositionTypeExpressionLength(input, startIndex, out var dispositionType); 314private static int GetDispositionTypeExpressionLength(StringSegment input, int startIndex, out StringSegment dispositionType) 334private static void CheckDispositionTypeFormat(StringSegment dispositionType, string parameterName) 336if (StringSegment.IsNullOrEmpty(dispositionType)) 342var dispositionTypeLength = GetDispositionTypeExpressionLength(dispositionType, 0, out var tempDispositionType); 357var dateString = dateParameter.Value; 401private StringSegment GetName(string parameter) 430private void SetName(StringSegment parameter, StringSegment value) 433if (StringSegment.IsNullOrEmpty(value)) 443StringSegment processedValue; 465private StringSegment EncodeAndQuoteMime(StringSegment input) 467var result = input; 502private static StringSegment Sanitize(StringSegment input) 504var result = input; 525private static bool IsQuoted(StringSegment value) 534private static bool RequiresEncoding(StringSegment input) 544private string EncodeMimeWithQuotes(StringSegment input) 574private static bool TryDecodeMime(StringSegment input, [NotNullWhen(true)] out string? output) 579var processedInput = input; 618private static string Encode5987(StringSegment input) 703private static bool TryDecode5987(StringSegment input, [NotNullWhen(true)] out string? output) 719var dataString = parts[2]; 764private static bool IsHexEncoding(StringSegment pattern, int index) 796private static byte HexUnescape(StringSegment pattern, ref int index)
ContentDispositionHeaderValueIdentityExtensions.cs (4)
23&& (!StringSegment.IsNullOrEmpty(header.FileName) || !StringSegment.IsNullOrEmpty(header.FileNameStar)); 36&& StringSegment.IsNullOrEmpty(header.FileName) && StringSegment.IsNullOrEmpty(header.FileNameStar);
ContentRangeHeaderValue.cs (12)
20private StringSegment _unit; 97public StringSegment Unit 152StringSegment.Equals(Unit, other.Unit, StringComparison.OrdinalIgnoreCase)); 209public static ContentRangeHeaderValue Parse(StringSegment input) 221public static bool TryParse(StringSegment input, [NotNullWhen(true)] out ContentRangeHeaderValue? parsedValue) 227private static int GetContentRangeLength(StringSegment input, int startIndex, out ContentRangeHeaderValue? parsedValue) 233if (StringSegment.IsNullOrEmpty(input) || (startIndex >= input.Length)) 246var unit = input.Subsegment(startIndex, unitLength); 299private static bool TryGetLengthLength(StringSegment input, ref int current, out int lengthLength) 324private static bool TryGetRangeLength(StringSegment input, ref int current, out int fromLength, out int toStartIndex, out int toLength) 381StringSegment input, 382StringSegment unit,
CookieHeaderParser.cs (1)
15public override bool TryParseValue(StringSegment value, ref int index, out CookieHeaderValue? cookieValue)
CookieHeaderValue.cs (15)
19private StringSegment _name; 20private StringSegment _value; 31public CookieHeaderValue(StringSegment name) 32: this(name, StringSegment.Empty) 45public CookieHeaderValue(StringSegment name, StringSegment value) 64public StringSegment Name 77public StringSegment Value 105public static CookieHeaderValue Parse(StringSegment input) 117public static bool TryParse(StringSegment input, [NotNullWhen(true)] out CookieHeaderValue? parsedValue) 165internal static void CheckNameFormat(StringSegment name, string parameterName) 178internal static void CheckValueFormat(StringSegment value, string parameterName) 186var result = CookieHeaderParserShared.GetCookieValue(value, ref offset); 203return StringSegment.Equals(_name, other._name, StringComparison.OrdinalIgnoreCase) 204&& StringSegment.Equals(_value, other._value, StringComparison.OrdinalIgnoreCase);
EntityTagHeaderValue.cs (15)
26private StringSegment _tag; 37/// <param name="tag">A <see cref="StringSegment"/> that contains an <see cref="EntityTagHeaderValue"/>.</param> 38public EntityTagHeaderValue(StringSegment tag) 46/// <param name="tag">A <see cref="StringSegment"/> that contains an <see cref="EntityTagHeaderValue"/>.</param> 48public EntityTagHeaderValue(StringSegment tag, bool isWeak) 50if (StringSegment.IsNullOrEmpty(tag)) 55if (!isWeak && StringSegment.Equals(tag, "*", StringComparison.Ordinal)) 80public StringSegment Tag => _tag; 109return obj is EntityTagHeaderValue other && _isWeak == other._isWeak && StringSegment.Equals(_tag, other._tag, StringComparison.Ordinal); 137return !IsWeak && !other.IsWeak && StringSegment.Equals(Tag, other.Tag, StringComparison.Ordinal); 141return StringSegment.Equals(Tag, other.Tag, StringComparison.Ordinal); 150public static EntityTagHeaderValue Parse(StringSegment input) 162public static bool TryParse(StringSegment input, [NotNullWhen(true)] out EntityTagHeaderValue? parsedValue) 210internal static int GetEntityTagLength(StringSegment input, int startIndex, out EntityTagHeaderValue? parsedValue) 216if (StringSegment.IsNullOrEmpty(input) || (startIndex >= input.Length))
GenericHeaderParser.cs (2)
10internal delegate int GetParsedValueLengthDelegate(StringSegment value, int startIndex, out T? parsedValue); 22protected override int GetParsedValueLength(StringSegment value, int startIndex, out T? parsedValue)
HeaderUtilities.cs (21)
71internal static void CheckValidToken(StringSegment value, string parameterName) 73if (StringSegment.IsNullOrEmpty(value)) 151StringSegment input, 370public static bool TryParseNonNegativeInt32(StringSegment value, out int result) 382/// Try to convert a <see cref="StringSegment"/> representation of a positive number to its 64-bit signed 386/// A <see cref="StringSegment"/> containing a number to convert. 391/// the <see cref="StringSegment"/> is null or String.Empty, is not of the correct format, is negative, or 396public static bool TryParseNonNegativeInt64(StringSegment value, out long result) 409internal static bool TryParseQualityDouble(StringSegment input, int startIndex, out double quality, out int length) 549public static bool TryParseDate(StringSegment input, out DateTimeOffset result) 589public static StringSegment RemoveQuotes(StringSegment input) 603public static bool IsQuoted(StringSegment input) 605return !StringSegment.IsNullOrEmpty(input) && input.Length >= 2 && input[0] == '"' && input[input.Length - 1] == '"'; 614public static StringSegment UnescapeAsQuotedString(StringSegment input) 654private static int CountBackslashesForDecodingQuotedString(StringSegment input) 679/// Escapes a <see cref="StringSegment"/> as a quoted-string, which is defined by 690public static StringSegment EscapeAsQuotedString(StringSegment input) 719private static int CountAndCheckCharactersNeedingBackslashesWhenEncoding(StringSegment input)
HttpHeaderParser.cs (2)
29public abstract bool TryParseValue(StringSegment value, ref int index, out T? parsedValue); 31public T? ParseValue(StringSegment value, ref int index)
MediaTypeHeaderValue.cs (53)
37private StringSegment _mediaType; 48/// <param name="mediaType">A <see cref="StringSegment"/> representation of a media type. 50public MediaTypeHeaderValue(StringSegment mediaType) 59/// <param name="mediaType">A <see cref="StringSegment"/> representation of a media type. 62public MediaTypeHeaderValue(StringSegment mediaType, double quality) 69/// Gets or sets the value of the charset parameter. Returns <see cref="StringSegment.Empty"/> 72public StringSegment Charset 84if (StringSegment.IsNullOrEmpty(value)) 114var charset = Charset; 117if (charset.HasValue && !StringSegment.IsNullOrEmpty(charset)) 145/// Gets or sets the value of the boundary parameter. Returns <see cref="StringSegment.Empty"/> 148public StringSegment Boundary 152return NameValueHeaderValue.Find(_parameters, BoundaryString)?.Value ?? default(StringSegment); 158if (StringSegment.IsNullOrEmpty(value)) 218/// Gets or sets the value of the media type. Returns <see cref="StringSegment.Empty"/> 225public StringSegment MediaType 243public StringSegment Type 259public StringSegment SubType 268/// Gets subtype of the <see cref="MediaTypeHeaderValue"/>, excluding any structured syntax suffix. Returns <see cref="StringSegment.Empty"/> 275public StringSegment SubTypeWithoutSuffix 279var subType = SubType; 300public StringSegment Suffix 304var subType = SubType; 308return default(StringSegment); 326public IEnumerable<StringSegment> Facets 444/// <param name="otherMediaType">The <see cref="StringSegment"/> to compare.</param> 453public bool MatchesMediaType(StringSegment otherMediaType) 455if (StringSegment.IsNullOrEmpty(otherMediaType)) 459GetMediaTypeExpressionLength(otherMediaType, 0, out var mediaType); 497/// <param name="input">The <see cref="StringSegment"/> with the media type.</param> 499public static MediaTypeHeaderValue Parse(StringSegment input) 508/// <param name="input">The <see cref="StringSegment"/> with the media type. The media type constructed here must not have an y</param> 511public static bool TryParse(StringSegment input, [NotNullWhen(true)] out MediaTypeHeaderValue? parsedValue) 560private static int GetMediaTypeLength(StringSegment input, int startIndex, out MediaTypeHeaderValue? parsedValue) 566if (StringSegment.IsNullOrEmpty(input) || (startIndex >= input.Length)) 572var mediaTypeLength = MediaTypeHeaderValue.GetMediaTypeExpressionLength(input, startIndex, out var mediaType); 604private static int GetMediaTypeExpressionLength(StringSegment input, int startIndex, out StringSegment mediaType) 653private static void CheckMediaTypeFormat(StringSegment mediaType, string parameterName) 655if (StringSegment.IsNullOrEmpty(mediaType)) 662var mediaTypeLength = GetMediaTypeExpressionLength(mediaType, 0, out var tempMediaType); 675private bool MatchesType(StringSegment mediaType) 677var type = mediaType.Subsegment(0, mediaType.IndexOf(ForwardSlashCharacter)); 710private bool MatchesSubtype(StringSegment mediaType) 717var subType = mediaType.Subsegment(mediaType.IndexOf(ForwardSlashCharacter) + 1); 719StringSegment suffix; 723suffix = default(StringSegment); 756private bool MatchesSubtypeWithoutSuffix(StringSegment subType, int startOfSuffix) 758StringSegment subTypeWithoutSuffix; 777private bool MatchesEitherSubtypeOrSuffix(StringSegment subType, StringSegment suffix) 812if (!StringSegment.Equals(parameter.Value, localParameter.Value, StringComparison.OrdinalIgnoreCase)) 828private bool MatchesSubtypeSuffix(StringSegment suffix)
NameValueHeaderValue.cs (28)
25private StringSegment _name; 26private StringSegment _value; 38public NameValueHeaderValue(StringSegment name) 48public NameValueHeaderValue(StringSegment name, StringSegment value) 59public StringSegment Name 67public StringSegment Value 122if (!StringSegment.IsNullOrEmpty(_value)) 156if (StringSegment.IsNullOrEmpty(_value)) 158return StringSegment.IsNullOrEmpty(other._value); 177public StringSegment GetUnescapedValue() 190public void SetAndEscapeValue(StringSegment value) 193if (StringSegment.IsNullOrEmpty(value) || (GetValueLength(value, 0) == value.Length)) 208public static NameValueHeaderValue Parse(StringSegment input) 220public static bool TryParse(StringSegment input, [NotNullWhen(true)] out NameValueHeaderValue? parsedValue) 271if (!StringSegment.IsNullOrEmpty(_value)) 299if (!StringSegment.IsNullOrEmpty(values[i].Value)) 336private static int GetNameValueLength(StringSegment input, int startIndex, out NameValueHeaderValue? parsedValue) 342if (StringSegment.IsNullOrEmpty(input) || (startIndex >= input.Length)) 356var name = input.Subsegment(startIndex, nameLength); 389StringSegment input, 396if ((StringSegment.IsNullOrEmpty(input)) || (startIndex >= input.Length)) 434public static NameValueHeaderValue? Find(IList<NameValueHeaderValue>? values, StringSegment name) 454internal static int GetValueLength(StringSegment input, int startIndex) 475private static void CheckNameValueFormat(StringSegment name, StringSegment value) 481private static void CheckValueFormat(StringSegment value) 484if (!(StringSegment.IsNullOrEmpty(value) || (GetValueLength(value, 0) == value.Length)))
RangeConditionHeaderValue.cs (4)
115public static RangeConditionHeaderValue Parse(StringSegment input) 127public static bool TryParse(StringSegment input, [NotNullWhen(true)] out RangeConditionHeaderValue? parsedValue) 133private static int GetRangeConditionLength(StringSegment input, int startIndex, out RangeConditionHeaderValue? parsedValue) 140if (StringSegment.IsNullOrEmpty(input) || (startIndex + 1 >= input.Length))
RangeHeaderValue.cs (7)
23private StringSegment _unit; 50public StringSegment Unit 112return StringSegment.Equals(_unit, other._unit, StringComparison.OrdinalIgnoreCase) && 134public static RangeHeaderValue Parse(StringSegment input) 146public static bool TryParse(StringSegment input, [NotNullWhen(true)] out RangeHeaderValue? parsedValue) 152private static int GetRangeLength(StringSegment input, int startIndex, out RangeHeaderValue? parsedValue) 158if (StringSegment.IsNullOrEmpty(input) || (startIndex >= input.Length))
RangeItemHeaderValue.cs (4)
104StringSegment input, 112if ((StringSegment.IsNullOrEmpty(input)) || (startIndex >= input.Length)) 154internal static int GetRangeItemLength(StringSegment input, int startIndex, out RangeItemHeaderValue? parsedValue) 162if (StringSegment.IsNullOrEmpty(input) || (startIndex >= input.Length))
SetCookieHeaderValue.cs (47)
43private StringSegment _name; 44private StringSegment _value; 45private List<StringSegment>? _extensions; 56public SetCookieHeaderValue(StringSegment name) 57: this(name, StringSegment.Empty) 66public SetCookieHeaderValue(StringSegment name, StringSegment value) 85public StringSegment Name 98public StringSegment Value 136public StringSegment Domain { get; set; } 146public StringSegment Path { get; set; } 182public IList<StringSegment> Extensions 184get => _extensions ??= new List<StringSegment>(); 246foreach (var extension in _extensions) 304foreach (var extension in _extensions) 312private static void AppendSegment(ref Span<char> span, StringSegment name, StringSegment value) 389foreach (var extension in _extensions) 396private static void AppendSegment(StringBuilder builder, StringSegment name, StringSegment value) 412public static SetCookieHeaderValue Parse(StringSegment input) 424public static bool TryParse(StringSegment input, [NotNullWhen(true)] out SetCookieHeaderValue? parsedValue) 473private static int GetSetCookieLength(StringSegment input, int startIndex, out SetCookieHeaderValue? parsedValue) 480if (StringSegment.IsNullOrEmpty(input) || (offset >= input.Length)) 534var token = input.Subsegment(offset, itemLength); 538if (StringSegment.Equals(token, ExpiresToken, StringComparison.OrdinalIgnoreCase)) 546var dateString = ReadToSemicolonOrEnd(input, ref offset, includeComma: false); 556else if (StringSegment.Equals(token, MaxAgeToken, StringComparison.OrdinalIgnoreCase)) 577var numberString = input.Subsegment(offset, itemLength); 595else if (StringSegment.Equals(token, DomainToken, StringComparison.OrdinalIgnoreCase)) 607else if (StringSegment.Equals(token, PathToken, StringComparison.OrdinalIgnoreCase)) 618else if (StringSegment.Equals(token, SecureToken, StringComparison.OrdinalIgnoreCase)) 624else if (StringSegment.Equals(token, SameSiteToken, StringComparison.OrdinalIgnoreCase)) 632var enforcementMode = ReadToSemicolonOrEnd(input, ref offset); 634if (StringSegment.Equals(enforcementMode, SameSiteStrictToken, StringComparison.OrdinalIgnoreCase)) 638else if (StringSegment.Equals(enforcementMode, SameSiteLaxToken, StringComparison.OrdinalIgnoreCase)) 642else if (StringSegment.Equals(enforcementMode, SameSiteNoneToken, StringComparison.OrdinalIgnoreCase)) 653else if (StringSegment.Equals(token, HttpOnlyToken, StringComparison.OrdinalIgnoreCase)) 670private static bool ReadEqualsSign(StringSegment input, ref int offset) 681private static StringSegment ReadToSemicolonOrEnd(StringSegment input, ref int offset, bool includeComma = true) 708var result = input.Subsegment(offset, itemLength); 723return StringSegment.Equals(_name, other._name, StringComparison.OrdinalIgnoreCase) 724&& StringSegment.Equals(_value, other._value, StringComparison.OrdinalIgnoreCase) 727&& StringSegment.Equals(Domain, other.Domain, StringComparison.OrdinalIgnoreCase) 728&& StringSegment.Equals(Path, other.Path, StringComparison.OrdinalIgnoreCase) 750foreach (var extension in _extensions)
src\Http\Shared\CookieHeaderParserShared.cs (17)
37if (parsedName == null || StringSegment.IsNullOrEmpty(parsedName.Value) 38|| parsedValue == null || StringSegment.IsNullOrEmpty(parsedValue.Value)) 59public static bool TryParseValue(StringSegment value, ref int index, bool supportsMultipleValues, [NotNullWhen(true)] out StringSegment? parsedName, [NotNullWhen(true)] out StringSegment? parsedValue) 69if (StringSegment.IsNullOrEmpty(value) || (index == value.Length)) 108private static int GetNextNonEmptyOrWhitespaceIndex(StringSegment input, int startIndex, bool skipEmptyValues, out bool separatorFound) 140internal static bool TryGetCookieLength(StringSegment input, ref int offset, [NotNullWhen(true)] out StringSegment? parsedName, [NotNullWhen(true)] out StringSegment? parsedValue) 147if (StringSegment.IsNullOrEmpty(input) || (offset >= input.Length)) 182internal static StringSegment GetCookieValue(StringSegment input, ref int offset) 191return StringSegment.Empty; 216return StringSegment.Empty; 227return StringSegment.Empty; 230private static bool ReadEqualsSign(StringSegment input, ref int offset)
src\Shared\HttpRuleParser.cs (7)
54internal static int GetTokenLength(StringSegment input, int startIndex) 68internal static int GetWhitespaceLength(StringSegment input, int startIndex) 111internal static int GetNumberLength(StringSegment input, int startIndex, bool allowDecimal) 155internal static HttpParseResult GetQuotedStringLength(StringSegment input, int startIndex, out int length) 163internal static HttpParseResult GetQuotedPairLength(StringSegment input, int startIndex, out int length) 187internal static bool TryStringToDate(StringSegment input, out DateTimeOffset result) 211StringSegment input,
StringWithQualityHeaderValue.cs (12)
21private StringSegment _value; 32/// <param name="value">The <see cref="StringSegment"/> used to initialize the new instance.</param> 33public StringWithQualityHeaderValue(StringSegment value) 43/// <param name="value">The <see cref="StringSegment"/> used to initialize the new instance.</param> 45public StringWithQualityHeaderValue(StringSegment value, double quality) 61public StringSegment Value => _value; 89if (!StringSegment.Equals(_value, other._value, StringComparison.OrdinalIgnoreCase)) 125public static StringWithQualityHeaderValue Parse(StringSegment input) 137public static bool TryParse(StringSegment input, [NotNullWhen(true)] out StringWithQualityHeaderValue? parsedValue) 185private static int GetStringWithQualityLength(StringSegment input, int startIndex, out StringWithQualityHeaderValue? parsedValue) 191if (StringSegment.IsNullOrEmpty(input) || (startIndex >= input.Length)) 228private static bool TryReadQuality(StringSegment input, StringWithQualityHeaderValue result, ref int index)
StringWithQualityHeaderValueComparer.cs (4)
17private static readonly StringSegment Any = new("*"); 58if (!StringSegment.Equals(stringWithQuality1.Value, stringWithQuality2.Value, StringComparison.OrdinalIgnoreCase)) 60if (StringSegment.Equals(stringWithQuality1.Value, Any, StringComparison.Ordinal)) 64else if (StringSegment.Equals(stringWithQuality2.Value, Any, StringComparison.Ordinal))
Microsoft.Net.Http.Headers.Tests (20)
HeaderUtilitiesTest.cs (7)
232var actual = HeaderUtilities.RemoveQuotes(input); 259var actual = HeaderUtilities.UnescapeAsQuotedString(input); 276var actual = HeaderUtilities.EscapeAsQuotedString(input); 287Assert.Throws<FormatException>(() => { var actual = HeaderUtilities.EscapeAsQuotedString(input); }); 293Assert.Throws<FormatException>(() => { var actual = HeaderUtilities.EscapeAsQuotedString($"{(char)0x7F}"); }); 351var input = new StringSegment(inputString); 403var input = new StringSegment(inputString);
MediaTypeHeaderValueTest.cs (7)
893public static TheoryData<string, List<StringSegment>> MediaTypesWithFacets => 894new TheoryData<string, List<StringSegment>> 897new List<StringSegment>(){ "vdn", "github" } }, 899new List<StringSegment>(){ "vdn", "github" } }, 901new List<StringSegment>(){ "vdn", "github", "v3" } }, 903new List<StringSegment>(){ "vdn", "github", "" } }, 908public void Facets_TestPositiveCases(string input, List<StringSegment> expected)
NameValueHeaderValueTest.cs (6)
582var actual = header.GetUnescapedValue(); 603var actual = header.Value; 626var valueHeader = header.GetUnescapedValue(); 629var actual = header.Value; 641var valueHeader = header.GetUnescapedValue(); 643var actual = header.Value;