<commit_before>﻿using System;
using System.Net;
using System.Threading;
using Kayak;
using Kayak.Http;

namespace HttpMock
{
	public interface IHttpServer : IDisposable
	{
		RequestHandler Stub(Func<RequestProcessor, RequestHandler> func);
		IStubHttp WithNewContext();
		IStubHttp WithNewContext(string baseUri);
		void Start();
	}

	public class HttpServer : IHttpServer, IStubHttp
	{
		protected RequestProcessor _requestProcessor;
		private ISchedulerDelegate _schedulerDelegate;
		protected KayakScheduler _scheduler;
		private Thread _thread;
		private Uri _uri;

		public HttpServer(Uri uri)
		{
			_uri = uri;
			_schedulerDelegate = new SchedulerDelegate();
			_scheduler = new KayakScheduler(_schedulerDelegate);
			_requestProcessor = new RequestProcessor();
			

			
		}

		public KayakScheduler Scheduler {
			get { return _scheduler; }
		}

		public void Start() {
			IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Any, _uri.Port);
			_scheduler.Post(() => 
			                Begin(ipEndPoint));

			_thread = new Thread(_scheduler.Start);
			_thread.Start();
		}

		private IDisposable Begin(IPEndPoint ipEndPoint) {
			IDisposable disposable = KayakServer.Factory<commit_msg>Inline scheduler delegate use ISchedulerInterface<commit_after>﻿using System;
using System.Net;
using System.Threading;
using Kayak;
using Kayak.Http;

namespace HttpMock
{
	public interface IHttpServer : IDisposable
	{
		RequestHandler Stub(Func<RequestProcessor, RequestHandler> func);
		IStubHttp WithNewContext();
		IStubHttp WithNewContext(string baseUri);
		void Start();
	}

	public class HttpServer : IHttpServer, IStubHttp
	{
		protected RequestProcessor _requestProcessor;
		protected IScheduler _scheduler;
		private Thread _thread;
		private Uri _uri;

		public HttpServer(Uri uri)
		{
			_uri = uri;
			_scheduler = new KayakScheduler(new SchedulerDelegate());
			_requestProcessor = new RequestProcessor();
			

			
		}

		public void Start() {
			IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Any, _uri.Port);
			_scheduler.Post(() => 
			                Listen(ipEndPoint));

			_thread = new Thread(_scheduler.Start);
			_thread.Start();
		}

		private IDisposable Listen(IPEndPoint ipEndPoint) {
			IDisposable disposable = KayakServer.Factory
{'fraction_non_alphanumeric': 0.08237378210806023, 'fraction_numerical': 0.0, 'mean_word_length': 4.327830188679245, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '2457928', 'n_tokens_mistral': 779, 'n_tokens_neox': 676, 'n_words': 168}