private ViaHeaderValue(ViaHeaderValue source) { Debug.Assert(source != null); _protocolName = source._protocolName; _protocolVersion = source._protocolVersion; _receivedBy = source._receivedBy; _comment = source._comment; }
public static bool TryParse(string input, out ViaHeaderValue parsedValue) { int index = 0; object output; parsedValue = null; if (GenericHeaderParser.SingleValueViaParser.TryParseValue(input, null, ref index, out output)) { parsedValue = (ViaHeaderValue)output; return(true); } return(false); }
public override bool Equals(object obj) { ViaHeaderValue other = obj as ViaHeaderValue; if (other == null) { return(false); } // Note that for token and host case-insensitive comparison is used. Comments are compared using case- // sensitive comparison. return(string.Equals(_protocolVersion, other._protocolVersion, StringComparison.OrdinalIgnoreCase) && string.Equals(_receivedBy, other._receivedBy, StringComparison.OrdinalIgnoreCase) && string.Equals(_protocolName, other._protocolName, StringComparison.OrdinalIgnoreCase) && string.Equals(_comment, other._comment, StringComparison.Ordinal)); }
internal static int GetViaLength(string input, int startIndex, out object parsedValue) { Debug.Assert(startIndex >= 0); parsedValue = null; if (string.IsNullOrEmpty(input) || (startIndex >= input.Length)) { return(0); } // Read <protocolName> and <protocolVersion> in '[<protocolName>/]<protocolVersion> <receivedBy> [<comment>]' string protocolName = null; string protocolVersion = null; int current = GetProtocolEndIndex(input, startIndex, out protocolName, out protocolVersion); // If we reached the end of the string after reading protocolName/Version we return (we expect at least // <receivedBy> to follow). If reading protocolName/Version read 0 bytes, we return. if ((current == startIndex) || (current == input.Length)) { return(0); } Debug.Assert(protocolVersion != null); // Read <receivedBy> in '[<protocolName>/]<protocolVersion> <receivedBy> [<comment>]' string receivedBy = null; int receivedByLength = HttpRuleParser.GetHostLength(input, current, true, out receivedBy); if (receivedByLength == 0) { return(0); } current = current + receivedByLength; current = current + HttpRuleParser.GetWhitespaceLength(input, current); string comment = null; if ((current < input.Length) && (input[current] == '(')) { // We have a <comment> in '[<protocolName>/]<protocolVersion> <receivedBy> [<comment>]' int commentLength = 0; if (HttpRuleParser.GetCommentLength(input, current, out commentLength) != HttpParseResult.Parsed) { return(0); // We found a '(' character but it wasn't a valid comment. Abort. } comment = input.Substring(current, commentLength); current = current + commentLength; current = current + HttpRuleParser.GetWhitespaceLength(input, current); } ViaHeaderValue result = new ViaHeaderValue(); result._protocolVersion = protocolVersion; result._protocolName = protocolName; result._receivedBy = receivedBy; result._comment = comment; parsedValue = result; return(current - startIndex); }