Esempio n. 1
0
        /// <summary>
        /// Creates a new HTTP method with the specified name.  You will not need to
        /// create a new method unless you are implementing a protocol derived from
        /// HTTP, such as
        /// http://en.wikipedia.org/wiki/Real_Time_Streaming_Protocol and
        /// http://en.wikipedia.org/wiki/Internet_Content_Adaptation_Protocol
        /// </summary>
        /// <param name="name"></param>
        public HttpMethod(string name)
        {
            if (name is null)
            {
                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.name);
            }

            name = name.Trim();
            if (string.IsNullOrEmpty(name))
            {
                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.name);
            }

            for (int i = 0; i < name.Length; i++)
            {
                char c = name[i];
                if (CharUtil.IsISOControl(c) || char.IsWhiteSpace(c))
                {
                    ThrowHelper.ThrowArgumentException_InvalidMethodName(c, name);
                }
            }

            this.name = AsciiString.Cached(name);
        }