private void SplitHeader(AppendableCharSequence sb) { byte[] chars = sb.Bytes; int length = sb.Count; int nameEnd; int colonEnd; int nameStart = FindNonWhitespace(chars, 0, length, false); for (nameEnd = nameStart; nameEnd < length; nameEnd++) { byte ch = chars[nameEnd]; // https://tools.ietf.org/html/rfc7230#section-3.2.4 // // No whitespace is allowed between the header field-name and colon. In // the past, differences in the handling of such whitespace have led to // security vulnerabilities in request routing and response handling. A // server MUST reject any received request message that contains // whitespace between a header field-name and colon with a response code // of 400 (Bad Request). A proxy MUST remove any such whitespace from a // response message before forwarding the message downstream. if (ch == ':' || // In case of decoding a request we will just continue processing and header validation // is done in the DefaultHttpHeaders implementation. // // In the case of decoding a response we will "skip" the whitespace. (!IsDecodingRequest() && IsOWS(ch))) { break; } } if (0u >= (uint)(nameEnd - length)) { // There was no colon present at all. ThrowHelper.ThrowArgumentException_No_colon_found(); } for (colonEnd = nameEnd; colonEnd < length; colonEnd++) { if (chars[colonEnd] == HttpConstants.Colon) { colonEnd++; break; } } _name = sb.SubStringUnsafe(nameStart, nameEnd); int valueStart = FindNonWhitespace(chars, colonEnd, length, true); if (valueStart == length) { _value = AsciiString.Empty; } else { int valueEnd = FindEndOfString(chars, length); _value = sb.SubStringUnsafe(valueStart, valueEnd); } }