System.Net.Cache.HttpRequestCacheValidator.ParseHeaderValues C# (CSharp) Method

ParseHeaderValues() static private method

static private ParseHeaderValues ( string values, ParseCallback calback, IList list ) : void
values string
calback ParseCallback
list IList
return void
        internal static void ParseHeaderValues(string[] values, ParseCallback calback, IList list) {

            if (values == null) {
                return;
            }
            for (int i = 0; i < values.Length; ++i) {
                string val = values[i];

                int end = 0;
                int start = 0;
                while (end < val.Length) {
                    //skip spaces
                    while (start < val.Length && val[start] == ' ') {
                        ++start;
                    }

                    if (start == val.Length ) {
                        //empty header value
                        break;
                    }

                    // find comma or quote
                    end = start;
                find_comma:
                    while (end < val.Length && val[end] != ',' && val[end] != '\"') {
                        ++end;
                    }

                    if (end == val.Length ) {
                        calback(val, start, end-1, list);
                        break;
                    }

                    if (val[end] == '\"') {
                        while (++end < val.Length && val[end] != '"') {
                            ;
                        }
                        if (end == val.Length ) {
                            //warning: no closing quote, accepting
                            calback(val, start, end-1, list);
                            break;
                        }
                        goto find_comma;
                    }
                    else {
                        //Comma
                        calback(val, start, end-1, list);
                        // skip leading spaces
                        while (++end < val.Length && val[end] == ' ') {
                            ;
                        }
                        if (end >= val.Length) {
                            break;
                        }
                        start = end;
                    }
                }
            }
        }
    }