<commit_before>package com.mantono.webserver;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;

import com.mantono.webserver.rest.HeaderField;
import com.mantono.webserver.rest.Response;
import com.mantono.webserver.rest.ResponseCode;

public class WebPage implements Response
{
	private final ResponseCode code;
	private final Map<HeaderField, String> header;
	private final String body;
	
	public WebPage()
	{
		this.code = ResponseCode.OK;
		this.body = "";
		this.header = setDefaultHeader();
	}
	
	public WebPage(final ResponseCode code)
	{
		this.code = code;
		this.body = "";
		this.header = setDefaultHeader();
	}
	
	public WebPage(final String body)
	{
		this.code = ResponseCode.OK;
		this.body = body;
		this.header = setDefaultHeader();
	}

	private Map<HeaderField, String> setDefaultHeader()
	{
		Map<HeaderField, String> args = new HashMap<HeaderField, String>();
		
		args.put(HeaderField.DATE, LocalDateTime.now().toString());
		args.put(HeaderField.SERVER, "REST-in-Peace");
		args.put(HeaderField.CONTENT_LENGTH, "" + body.length()*2);
		args.put(HeaderField.CONTENT_TYPE, "text/html");
		
		return args;
	}<commit_msg>Added UTF-8 as default charset for responses in header.<commit_after>package com.mantono.webserver;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;

import com.mantono.webserver.rest.HeaderField;
import com.mantono.webserver.rest.Response;
import com.mantono.webserver.rest.ResponseCode;

public class WebPage implements Response
{
	private final ResponseCode code;
	private final Map<HeaderField, String> header;
	private final String body;
	
	public WebPage()
	{
		this.code = ResponseCode.OK;
		this.body = "";
		this.header = setDefaultHeader();
	}
	
	public WebPage(final ResponseCode code)
	{
		this.code = code;
		this.body = "";
		this.header = setDefaultHeader();
	}
	
	public WebPage(final String body)
	{
		this.code = ResponseCode.OK;
		this.body = body;
		this.header = setDefaultHeader();
	}

	private Map<HeaderField, String> setDefaultHeader()
	{
		Map<HeaderField, String> args = new HashMap<HeaderField, String>();
		
		args.put(HeaderField.DATE, LocalDateTime.now().toString());
		args.put(HeaderField.SERVER, "REST-in-Peace");
		args.put(HeaderField.CONTENT_LENGTH, "" + body.length()*2);
		args.put(HeaderField.CONTENT_TYPE, "text/html; charset=utf-8");
		
		return args;
	}
{'fraction_non_alphanumeric': 0.12595573440643862, 'fraction_numerical': 0.0016096579476861167, 'mean_word_length': 4.714942528735632, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '6704758', 'n_tokens_mistral': 860, 'n_tokens_neox': 791, 'n_words': 169}