rename project

master
subhra74 2022-07-25 13:05:21 +05:30
parent c5fdaa7e66
commit 9d6711ff55
6 changed files with 1 additions and 472 deletions

View File

@ -57,9 +57,6 @@
<Compile Include="$(MSBuildThisFileDirectory)XDM.Core\Interop.WinHttp\Interop.SafeWinHttpHandle.cs" />
<Compile Include="$(MSBuildThisFileDirectory)XDM.Core\Interop.WinHttp\Interop.winhttp.cs" />
<Compile Include="$(MSBuildThisFileDirectory)XDM.Core\Interop.WinHttp\Interop.winhttp_types.cs" />
<Compile Include="$(MSBuildThisFileDirectory)XDM.Core\Lib\Clients\Http\CurlHttpClient.cs" />
<Compile Include="$(MSBuildThisFileDirectory)XDM.Core\Lib\Clients\Http\CurlResponseStream.cs" />
<Compile Include="$(MSBuildThisFileDirectory)XDM.Core\Lib\Clients\Http\CurlSession.cs" />
<Compile Include="$(MSBuildThisFileDirectory)XDM.Core\Lib\Clients\Http\DotNetHttpClient.cs" />
<Compile Include="$(MSBuildThisFileDirectory)XDM.Core\Lib\Clients\Http\DotNetHttpSession.cs" />
<Compile Include="$(MSBuildThisFileDirectory)XDM.Core\Lib\Clients\Http\HttpClientFactory.cs" />

View File

@ -1,128 +0,0 @@
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Runtime.InteropServices;
//using System.Text;
//using System.Threading;
//using XDM.Core.Interop.CURL;
//using XDM.Core.Lib.Common;
//namespace XDM.Core.Lib.Clients.Http
//{
// internal class CurlHttpClient : IHttpClient
// {
// private CancelFlag cancelFlag = new CancelFlag();
// private Thread multiRunner;
// private bool disposed;
// private Queue<IntPtr> resumeQueue = new();
// private Dictionary<IntPtr, CurlSession> sessions = new();
// public TimeSpan Timeout { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
// public CurlHttpClient()
// {
// this.multiRunner = new Thread(RunCurlMulti);
// this.multiRunner.Start();
// }
// public void Close()
// {
// cancelFlag.Cancel();
// }
// public HttpRequest CreateGetRequest(Uri uri, string method, Dictionary<string, List<string>>? headers = null, Dictionary<string, string>? cookies = null, AuthenticationInfo? authentication = null)
// {
// if (disposed)
// {
// throw new ObjectDisposedException("HttpWebRequestClient");
// }
// return new HttpRequest { /*Session = new CurlSession()*/ };
// }
// public HttpRequest CreateGetRequest(Uri uri, Dictionary<string, List<string>>? headers = null, Dictionary<string, string>? cookies = null, AuthenticationInfo? authentication = null)
// {
// if (disposed)
// {
// throw new ObjectDisposedException("HttpWebRequestClient");
// }
// throw new NotImplementedException();
// }
// public HttpRequest CreatePostRequest(Uri uri, Dictionary<string, List<string>>? headers = null, Dictionary<string, string>? cookies = null, AuthenticationInfo? authentication = null, byte[]? body = null)
// {
// throw new NotImplementedException();
// }
// public void Dispose()
// {
// cancelFlag.Cancel();
// }
// public HttpResponse Send(HttpRequest request)
// {
// throw new NotImplementedException();
// }
// private void RunCurlMulti()
// {
// int still_running = 0;
// var multi_handle = CurlNative.curl_multi_init();
// while (!cancelFlag.IsCancellationRequested)
// {
// IntPtr msg;
// int queued = 0;
// CurlNative.curl_multi_perform(multi_handle, ref still_running);
// CurlNative.curl_multi_poll(multi_handle, IntPtr.Zero, 0, 50, IntPtr.Zero);
// do
// {
// msg = CurlNative.curl_multi_info_read(multi_handle, ref queued);
// if (msg != IntPtr.Zero)
// {
// CurlNative.CURLMsg msgStruct = (CurlNative.CURLMsg)Marshal.PtrToStructure(msg, typeof(CurlNative.CURLMsg));
// if (msgStruct.msg == CurlNative.CURLMSG_DONE)
// {
// Console.WriteLine("Finished handle: " + msgStruct.easy_handle);
// Console.WriteLine("Result: " + msgStruct.result);
// lock (this)
// {
// if (sessions.TryGetValue(msgStruct.easy_handle, out CurlSession session))
// {
// session.Close();
// }
// }
// //if (msgStruct.easy_handle == easy1)
// //{
// // Event.Set();
// // continue;
// //}
// //else
// //{
// // Console.WriteLine("UnFinished handle: " + msgStruct.easy_handle);
// //}
// }
// }
// } while (msg != IntPtr.Zero);
// lock (this)
// {
// for (var i = 0; i < resumeQueue.Count; i++)
// {
// var easyHandle = resumeQueue.Dequeue();
// CurlNative.curl_easy_pause(easyHandle, CurlNative.CURLPAUSE_CONT);
// }
// }
// }
// CurlNative.curl_multi_cleanup(multi_handle);
// }
// internal void ResumeSession(IntPtr easyHandle)
// {
// lock (this)
// {
// resumeQueue.Enqueue(easyHandle);
// }
// }
// }
//}

View File

@ -1,86 +0,0 @@
//using System;
//using System.Collections.Generic;
//using System.IO;
//using System.Linq;
//using System.Text;
//using System.Threading;
//namespace XDM.Core.Lib.Clients.Http
//{
// internal class CurlResponseStream : Stream
// {
// private CurlSession session;
// private byte[]? excessData;
// public CurlResponseStream(CurlSession session)
// {
// this.session = session;
// }
// public override bool CanRead => true;
// public override bool CanSeek => false;
// public override bool CanWrite => false;
// public override long Length => -1;
// public override long Position { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
// public override void Flush()
// {
// }
// public override int Read(byte[] buffer, int offset, int count)
// {
// if (excessData != null)
// {
// if (count > excessData.Length)
// {
// var l = excessData.Length;
// Array.Copy(excessData, buffer, excessData.Length);
// excessData = null;
// return l;
// }
// else
// {
// Array.Copy(excessData, buffer, count);
// var bytes = new byte[excessData.Length - count];
// Array.Copy(excessData, count, bytes, 0, bytes.Length);
// excessData = bytes;
// return count;
// }
// }
// var len = session.ReadData(out byte[] data);
// if (len == 0) return 0;
// if (count > len)
// {
// Array.Copy(data, buffer, len);
// return len;
// }
// else
// {
// Array.Copy(data, buffer, count);
// excessData = new byte[len - count];
// Array.Copy(data, count, excessData, 0, excessData.Length);
// return count;
// }
// }
// public override long Seek(long offset, SeekOrigin origin)
// {
// return -1;
// }
// public override void SetLength(long value)
// {
// }
// public override void Write(byte[] buffer, int offset, int count)
// {
// }
// }
//}

View File

@ -1,254 +0,0 @@
//using System;
//using System.Collections.Generic;
//using System.IO;
//using System.Linq;
//using System.Net;
//using System.Runtime.InteropServices;
//using System.Text;
//using System.Threading;
//using TraceLog;
//using XDM.Core.Interop.CURL;
//using XDM.Core.Lib.Common;
//namespace XDM.Core.Lib.Clients.Http
//{
// internal class CurlSession : IHttpSession
// {
// private IntPtr easyHandle;
// private bool needData = false;
// private AutoResetEvent dataWaitHandle = new(false);
// private AutoResetEvent headerWaitHandle = new(false);
// private bool dataStarted = false, error = false, finished = false;
// private byte[] data;
// private StringBuilder responseHeaderBuffer = new();
// private CurlNative.CurlCallback cbHeader, cbData;
// private CurlResponseStream responseStream;
// private Uri responseUri;
// private HttpStatusCode statusCode;
// private string? statusDescription;
// private long contentLength;
// private string? contentType;
// private string? contentDispositionFileName;
// private DateTime lastModified = DateTime.Now;
// private long rangeStart = -1, rangeEnd = -1;
// public CurlSession(Uri uri, string method,
// Dictionary<string, List<string>>? headers = null,
// Dictionary<string, string>? cookies = null,
// AuthenticationInfo? authentication = null)
// {
// cbHeader = new CurlNative.CurlCallback(HeaderHandler);
// cbData = new CurlNative.CurlCallback(DataHandler);
// var easy = CurlNative.curl_easy_init();
// var ret = 0;
// ret = CurlNative.curl_easy_setopt(easy, CurlNative.CURLOPT_URL, uri.ToString());// "https://www.gyan.dev/ffmpeg/builds/packages/ffmpeg-4.3.2-essentials_build.zip");// "https://www.gyan.dev/ffmpeg/builds/packages/ffmpeg-4.3.2-essentials_build.zip");
// ret = CurlNative.curl_easy_setopt(easy, CurlNative.CURLOPT_FOLLOWLOCATION, 1);
// ret = CurlNative.curl_easy_setopt(easy, CurlNative.CURLOPT_SSL_VERIFYPEER, 0L);
// ret = CurlNative.curl_easy_setopt(easy, CurlNative.CURLOPT_HEADERFUNCTION, cbHeader);
// ret = CurlNative.curl_easy_setopt(easy, CurlNative.CURLOPT_WRITEFUNCTION, cbData);
// this.responseStream = new CurlResponseStream(this);
// }
// public string? ContentType => this.contentType;
// public string? ContentDispositionFileName => this.contentDispositionFileName;
// public long ContentLength => this.contentLength;
// public DateTime LastModified => this.lastModified;
// public HttpStatusCode StatusCode => this.statusCode;
// public Uri ResponseUri => responseUri;
// public long RangeEnd => rangeEnd;
// public long RangeStart => rangeStart;
// public void Abort()
// {
// Close();
// }
// public void AddRange(long range)
// {
// throw new NotImplementedException();
// }
// public void AddRange(long start, long end)
// {
// throw new NotImplementedException();
// }
// public void Close()
// {
// lock (this)
// {
// finished = true;
// dataWaitHandle.Set();
// CurlNative.curl_easy_cleanup(easyHandle);
// easyHandle = IntPtr.Zero;
// }
// }
// public void Dispose()
// {
// Close();
// }
// public void EnsureSuccessStatusCode()
// {
// if (statusCode != HttpStatusCode.OK && statusCode != HttpStatusCode.PartialContent)
// {
// throw new HttpException(statusDescription, null, statusCode);
// }
// }
// public Stream GetResponseStream()
// {
// return this.responseStream;
// }
// public string ReadAsString(CancelFlag cancellationToken)
// {
// throw new NotImplementedException();
// }
// private void ProcessHeaders()
// {
// string statusLine = null;
// string location = null;
// var headers = responseHeaderBuffer.ToString().Replace("\n", "").Split('\r');
// string headerName = null, headerValue = null;
// bool statusLineExpected = true;
// foreach (var header in headers)
// {
// //special case: header folding
// if (header.StartsWith(" ") || header.StartsWith("\t"))
// {
// headerValue += header;
// continue;
// }
// if (statusLineExpected)
// {
// statusLine = header;
// statusLineExpected = false;
// }
// if (header.Length == 0)
// {
// statusLineExpected = true;
// continue;
// }
// var sep = header.IndexOf(':');
// if (sep < 1)
// {
// Log.Debug($"Invalid header: {header}");
// continue;
// }
// var key = header.Substring(0, sep).ToLowerInvariant();
// var value = header.Substring(sep + 1).Trim();
// switch (key)
// {
// case "content-length":
// this.contentLength = Int64.Parse(value);
// break;
// case "content-type":
// this.contentType = value;
// break;
// case "location":
// this.responseUri = new Uri(value);
// break;
// case "content-disposition":
// this.contentDispositionFileName = WebRequestExtensions.GetContentDispositionFileName(value);
// break;
// default:
// break;
// }
// }
// }
// private uint HeaderHandler(IntPtr data, uint size, uint nmemb, IntPtr userdata)
// {
// if (dataStarted) return size * nmemb;
// var managedArray = new byte[size * nmemb];
// Marshal.Copy(data, managedArray, 0, (int)(size * nmemb));
// var str = Encoding.UTF8.GetString(managedArray, 0, (int)(size * nmemb));
// Console.WriteLine($"Curl-Header: {str}");
// responseHeaderBuffer.Append(str);
// return size * nmemb;
// }
// private uint DataHandler(IntPtr data, uint size, uint nmemb, IntPtr userdata)
// {
// if (!dataStarted)
// {
// dataStarted = true;
// ProcessHeaders();
// headerWaitHandle.Set();
// }
// var dataRequired = false;
// lock (this)
// {
// dataRequired = needData;
// }
// if (dataRequired)
// {
// var managedArray = new byte[size * nmemb];
// Marshal.Copy(data, managedArray, 0, (int)(size * nmemb));
// this.data = managedArray;
// dataWaitHandle.Set();
// return size * nmemb;
// }
// return CurlNative.CURL_WRITEFUNC_PAUSE;
// }
// internal int ReadData(out byte[] data)
// {
// needData = true;
// if (ResumeCallback())
// {
// lock (this)
// {
// needData = false;
// }
// data = this.data;
// return this.data.Length;
// }
// else
// {
// if (error)
// {
// throw new IOException("Error from curl");
// }
// if (finished)
// {
// data = new byte[0];
// return 0;
// }
// else
// {
// throw new IOException("Neither error not finished");
// }
// }
// }
// public bool ResumeCallback()
// {
// if (easyHandle == IntPtr.Zero)
// {
// return false;
// }
// dataWaitHandle.WaitOne();
// if (easyHandle == IntPtr.Zero)
// {
// return false;
// }
// return true;
// }
// }
//}

View File

@ -18,7 +18,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.editorconfig = .editorconfig
EndProjectSection
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "XDM.App.Core", "XDM.App.Core\XDM.App.Core.shproj", "{5BBEA202-65D2-481A-B457-6D8FCC8970D7}"
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "XDM.Core", "XDM.App.Core\XDM.Core.shproj", "{5BBEA202-65D2-481A-B457-6D8FCC8970D7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XDM.Tests", "XDM.Tests\XDM.Tests.csproj", "{559A3ABB-6A04-4169-A605-8C068EF77DB7}"
EndProject