mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-28 19:27:05 +02:00
Create WireMock.Net.MimePart project (#1300)
* Create WireMock.Net.MimePart project * . * REFACTOR * ILRepack * -- * ... * x * x * . * fix * public class MimePartMatcher * shared * min * . * <!--<DelaySign>true</DelaySign>--> * Update README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
26
src/WireMock.Net.Minimal/Util/HttpVersionParser.cs
Normal file
26
src/WireMock.Net.Minimal/Util/HttpVersionParser.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
// Copyright © WireMock.Net
|
||||
|
||||
using System.Text.RegularExpressions;
|
||||
using Stef.Validation;
|
||||
using WireMock.Constants;
|
||||
|
||||
namespace WireMock.Util;
|
||||
|
||||
/// <summary>
|
||||
/// https://en.wikipedia.org/wiki/HTTP
|
||||
/// </summary>
|
||||
internal static class HttpVersionParser
|
||||
{
|
||||
private static readonly Regex HttpVersionRegex = new(@"HTTP/(\d+(\.\d+)?(?!\.))", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Compiled, RegexConstants.DefaultTimeout);
|
||||
|
||||
/// <summary>
|
||||
/// Try to extract the version (as a string) from the protocol.
|
||||
/// </summary>
|
||||
/// <param name="protocol">The protocol, something like "HTTP/1.1" or "HTTP/2".</param>
|
||||
/// <returns>The version ("1.1" or "2") if found and valid, else empty string.</returns>
|
||||
internal static string Parse(string protocol)
|
||||
{
|
||||
var match = HttpVersionRegex.Match(Guard.NotNull(protocol));
|
||||
return match.Success ? match.Groups[1].Value : string.Empty;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user