Geeks With Blogs

.Nettuce Code Salad
        public static NameValueCollection HeaderNameValueCollection(this string header)
        {
            var nameValueCollection = new NameValueCollection();
            Regex.Matches(header@"(\w+)="".*?""").Cast<Match>().Select(x => x.Value.TrimEnd('"').Split(new[] { "=\"" }, StringSplitOptions.None)).ForEach(x => nameValueCollection.Add(x[0], x.Length == 2 ? x[1] : string.Empty));
            return nameValueCollection;
        }
Posted on Monday, August 15, 2011 10:12 PM | Back to top


Comments on this post: Return a NameValueCollection From A HTTP Header

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Jon Canning | Powered by: GeeksWithBlogs.net