<commit_before>﻿using UnityEngine;
using System.Collections.Generic;
using System.Linq;

namespace UniHttp
{
	public sealed class ResponseHeaders
	{
		readonly Dictionary<string, List<string>> fields;

		public ResponseHeaders()
		{
			this.fields = new Dictionary<string, List<string>>();
		}

		public List<string> this[string name]
		{
			get { return fields[name.ToLower()]; }
		}

		public int Length
		{
			get { return fields.Count; }
		}

		public bool Exist(string name)
		{
			return fields.ContainsKey(name.ToLower());
		}

		public bool Exist(string name, string value)
		{
			return Exist(name) && this[name].Any(each => each.Contains(value));
		}

		public bool NotExist(string name)
		{
			return !Exist(name);
		}

		internal void Append(string name, List<string> values)
		{
			for(int i = 0; i < values.Count; i++) {
				Append(name, values[0]);
			}
		}

		internal void Append(string name, string value)
		{
			name = name.ToLower();
			if(fields.ContainsKey(name)) {
				fields[name].Add(value);
			} else {
				fields.Add(name, new List<string> { value });
			}
		}

		public override string ToString()
		{
			List<string> fieldLines = new List<string>();
			foreach(KeyValuePair<string, List<string>> kvPair in fields) {
				fieldLines.Add(Titleize(kvPair.Key) + ": " + string.Join(",", kvPair.Value.ToArray()));
			}<commit_msg>better string representation for multiple headers with same name<commit_after>﻿using UnityEngine;
using System.Collections.Generic;
using System.Linq;

namespace UniHttp
{
	public sealed class ResponseHeaders
	{
		readonly Dictionary<string, List<string>> fields;

		public ResponseHeaders()
		{
			this.fields = new Dictionary<string, List<string>>();
		}

		public List<string> this[string name]
		{
			get { return fields[name.ToLower()]; }
		}

		public int Length
		{
			get { return fields.Count; }
		}

		public bool Exist(string name)
		{
			return fields.ContainsKey(name.ToLower());
		}

		public bool Exist(string name, string value)
		{
			return Exist(name) && this[name].Any(each => each.Contains(value));
		}

		public bool NotExist(string name)
		{
			return !Exist(name);
		}

		internal void Append(string name, List<string> values)
		{
			for(int i = 0; i < values.Count; i++) {
				Append(name, values[0]);
			}
		}

		internal void Append(string name, string value)
		{
			name = name.ToLower();
			if(fields.ContainsKey(name)) {
				fields[name].Add(value);
			} else {
				fields.Add(name, new List<string> { value });
			}
		}

		public override string ToString()
		{
			List<string> fieldLines = new List<string>();
			foreach(KeyValuePair<string, List<string>> kvPair in fields) {
				foreach(string line in kvPair.Value) {
					fieldLines.Add(Titleize(kvPair.Key) + ": " + line);
				}
			}
{'fraction_non_alphanumeric': 0.13651137594799567, 'fraction_numerical': 0.001444564824846515, 'mean_word_length': 3.5785123966942147, 'pattern_counts': {'":': 2, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6809517', 'n_tokens_mistral': 1062, 'n_tokens_neox': 899, 'n_words': 215}