mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 03:14:47 +00:00
提交帧同步案例
This commit is contained in:
parent
3a345ab966
commit
68c4d5e811
50
JNFrame/App.config
Normal file
50
JNFrame/App.config
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?><configuration>
|
||||||
|
<runtime>
|
||||||
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="mscorlib" publicKeyToken="b77a5c561934e089" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="netstandard" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System" publicKeyToken="b77a5c561934e089" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Core" publicKeyToken="b77a5c561934e089" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Data" publicKeyToken="b77a5c561934e089" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Security.Cryptography.Algorithms" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.2.2.0" newVersion="4.2.2.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Web" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Xml" publicKeyToken="b77a5c561934e089" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
</assemblyBinding>
|
||||||
|
</runtime>
|
||||||
|
</configuration>
|
63
JNFrame/Assembly-CSharp-Editor.csproj
Normal file
63
JNFrame/Assembly-CSharp-Editor.csproj
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<LangVersion>9.0</LangVersion>
|
||||||
|
<_TargetFrameworkDirectories>non_empty_path_generated_by_unity.rider.package</_TargetFrameworkDirectories>
|
||||||
|
<_FullFrameworkReferenceAssemblyPaths>non_empty_path_generated_by_unity.rider.package</_FullFrameworkReferenceAssemblyPaths>
|
||||||
|
<DisableHandlePackageFileConflicts>true</DisableHandlePackageFileConflicts>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProductVersion>10.0.20506</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<RootNamespace></RootNamespace>
|
||||||
|
<ProjectGuid>{520fb43a-8c94-8ecf-d51a-d5407030f9ec}</ProjectGuid>
|
||||||
|
<ProjectTypeGuids>{E097FAD1-6243-4DAD-9C02-E9B9EFC3FFC1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<AssemblyName>Assembly-CSharp-Editor</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<BaseDirectory>.</BaseDirectory>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>Temp\Bin\Debug\Unity.Rider.Editor\</OutputPath>
|
||||||
|
<DefineConstants>UNITY_EDITOR</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<NoWarn>0169,0649</NoWarn>
|
||||||
|
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
|
||||||
|
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<NoConfig>true</NoConfig>
|
||||||
|
<NoStdLib>true</NoStdLib>
|
||||||
|
<AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
|
||||||
|
<ImplicitlyExpandNETStandardFacades>false</ImplicitlyExpandNETStandardFacades>
|
||||||
|
<ImplicitlyExpandDesignTimeFacades>false</ImplicitlyExpandDesignTimeFacades>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Assets\NuGet\Editor" />
|
||||||
|
<Reference Include="UnityEngine">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.CoreModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEditor">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEditor.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
2531
JNFrame/Assembly-CSharp-firstpass.csproj
Normal file
2531
JNFrame/Assembly-CSharp-firstpass.csproj
Normal file
File diff suppressed because it is too large
Load Diff
801
JNFrame/Assembly-CSharp.csproj
Normal file
801
JNFrame/Assembly-CSharp.csproj
Normal file
@ -0,0 +1,801 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<LangVersion>9.0</LangVersion>
|
||||||
|
<_TargetFrameworkDirectories>non_empty_path_generated_by_unity.rider.package</_TargetFrameworkDirectories>
|
||||||
|
<_FullFrameworkReferenceAssemblyPaths>non_empty_path_generated_by_unity.rider.package</_FullFrameworkReferenceAssemblyPaths>
|
||||||
|
<DisableHandlePackageFileConflicts>true</DisableHandlePackageFileConflicts>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProductVersion>10.0.20506</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<RootNamespace></RootNamespace>
|
||||||
|
<ProjectGuid>{3ca4410c-c33b-25ce-55bc-3a432b9830ed}</ProjectGuid>
|
||||||
|
<ProjectTypeGuids>{E097FAD1-6243-4DAD-9C02-E9B9EFC3FFC1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<AssemblyName>Assembly-CSharp</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<BaseDirectory>.</BaseDirectory>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>Temp\Bin\Debug\Assembly-CSharp\</OutputPath>
|
||||||
|
<DefineConstants>UNITY_2021_3_27;UNITY_2021_3;UNITY_2021;UNITY_5_3_OR_NEWER;UNITY_5_4_OR_NEWER;UNITY_5_5_OR_NEWER;UNITY_5_6_OR_NEWER;UNITY_2017_1_OR_NEWER;UNITY_2017_2_OR_NEWER;UNITY_2017_3_OR_NEWER;UNITY_2017_4_OR_NEWER;UNITY_2018_1_OR_NEWER;UNITY_2018_2_OR_NEWER;UNITY_2018_3_OR_NEWER;UNITY_2018_4_OR_NEWER;UNITY_2019_1_OR_NEWER;UNITY_2019_2_OR_NEWER;UNITY_2019_3_OR_NEWER;UNITY_2019_4_OR_NEWER;UNITY_2020_1_OR_NEWER;UNITY_2020_2_OR_NEWER;UNITY_2020_3_OR_NEWER;UNITY_2021_1_OR_NEWER;UNITY_2021_2_OR_NEWER;UNITY_2021_3_OR_NEWER;PLATFORM_ARCH_64;UNITY_64;UNITY_INCLUDE_TESTS;ENABLE_AR;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_EVENT_QUEUE;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_TEXTURE_STREAMING;ENABLE_VIRTUALTEXTURING;ENABLE_UNET;ENABLE_LZMA;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_UNITYWEBREQUEST;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_SERVICES_USE_WEBREQUEST;ENABLE_CLOUD_SERVICES_CRASH_REPORTING;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_HUB_LICENSE;ENABLE_WEBSOCKET_CLIENT;ENABLE_DIRECTOR_AUDIO;ENABLE_DIRECTOR_TEXTURE;ENABLE_MANAGED_JOBS;ENABLE_MANAGED_TRANSFORM_JOBS;ENABLE_MANAGED_ANIMATION_JOBS;ENABLE_MANAGED_AUDIO_JOBS;ENABLE_MANAGED_UNITYTLS;INCLUDE_DYNAMIC_GI;ENABLE_SCRIPTING_GC_WBARRIERS;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;ENABLE_VIDEO;ENABLE_ACCELERATOR_CLIENT_DEBUGGING;PLATFORM_STANDALONE;TEXTCORE_1_0_OR_NEWER;PLATFORM_STANDALONE_WIN;UNITY_STANDALONE_WIN;UNITY_STANDALONE;UNITY_UGP_API;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_NVIDIA;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_UNITY_GAME_SERVICES_ANALYTICS_SUPPORT;ENABLE_OUT_OF_PROCESS_CRASH_HANDLER;ENABLE_CLUSTER_SYNC;ENABLE_CLUSTERINPUT;PLATFORM_UPDATES_TIME_OUTSIDE_OF_PLAYER_LOOP;GFXDEVICE_WAITFOREVENT_MESSAGEPUMP;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;NET_STANDARD_2_0;NET_STANDARD;NET_STANDARD_2_1;NETSTANDARD;NETSTANDARD2_1;ENABLE_PROFILER;DEBUG;TRACE;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_IG;UNITY_EDITOR_64;UNITY_EDITOR_WIN;ENABLE_UNITY_COLLECTIONS_CHECKS;ENABLE_BURST_AOT;UNITY_TEAM_LICENSE;ENABLE_CUSTOM_RENDER_TEXTURE;ENABLE_DIRECTOR;ENABLE_LOCALIZATION;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_TILEMAP;ENABLE_TIMELINE;ENABLE_LEGACY_INPUT_MANAGER;TEXTCORE_FONT_ENGINE_1_5_OR_NEWER;CSHARP_7_OR_LATER;CSHARP_7_3_OR_NEWER</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<NoWarn>0169,0649</NoWarn>
|
||||||
|
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
|
||||||
|
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<NoConfig>true</NoConfig>
|
||||||
|
<NoStdLib>true</NoStdLib>
|
||||||
|
<AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
|
||||||
|
<ImplicitlyExpandNETStandardFacades>false</ImplicitlyExpandNETStandardFacades>
|
||||||
|
<ImplicitlyExpandDesignTimeFacades>false</ImplicitlyExpandDesignTimeFacades>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Assets\Script\App.cs" />
|
||||||
|
<Compile Include="Assets\Script\Main.cs" />
|
||||||
|
<Compile Include="Assets\Script\AppImpl\JNGSocket.cs" />
|
||||||
|
<Compile Include="Assets\Script\UIMain.cs" />
|
||||||
|
<Compile Include="Assets\Script\battle\GBattleModeManager.cs" />
|
||||||
|
<Compile Include="Assets\Script\AppImpl\JNGSyncFrame.cs" />
|
||||||
|
<Compile Include="Assets\Script\battle\GBaseMode.cs" />
|
||||||
|
<Folder Include="Assets" />
|
||||||
|
<Folder Include="Assets\Script" />
|
||||||
|
<Folder Include="Assets\Packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0" />
|
||||||
|
<Folder Include="Assets\Packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib" />
|
||||||
|
<Folder Include="Assets\Script\battle" />
|
||||||
|
<Folder Include="Assets\Packages\Google.Protobuf.3.15.8\lib" />
|
||||||
|
<Folder Include="Assets\Packages\System.Runtime.CompilerServices.Unsafe.4.5.2" />
|
||||||
|
<None Include="Assets\Packages\Google.Protobuf.3.15.8\lib\netstandard2.0\Google.Protobuf.xml" />
|
||||||
|
<Folder Include="Assets\Packages" />
|
||||||
|
<Folder Include="Assets\NuGet\Resources" />
|
||||||
|
<None Include="Assets\Packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.xml" />
|
||||||
|
<None Include="Assets\Packages\System.Runtime.CompilerServices.Unsafe.4.5.2\version.txt" />
|
||||||
|
<Folder Include="Assets\NuGet" />
|
||||||
|
<Folder Include="Assets\Packages\Google.Protobuf.3.15.8\lib\netstandard2.0" />
|
||||||
|
<Folder Include="Assets\Script\AppImpl" />
|
||||||
|
<Folder Include="Assets\Packages\Google.Protobuf.3.15.8" />
|
||||||
|
<None Include="Assets\Packages\System.Runtime.CompilerServices.Unsafe.4.5.2\useSharedDesignerContext.txt" />
|
||||||
|
<Folder Include="Assets\Scenes" />
|
||||||
|
<Folder Include="Assets\Resources" />
|
||||||
|
<Reference Include="UnityEngine">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.AIModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.AIModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.ARModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.ARModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.AccessibilityModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.AccessibilityModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.AndroidJNIModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.AndroidJNIModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.AnimationModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.AnimationModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.AssetBundleModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.AssetBundleModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.AudioModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.AudioModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.ClothModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.ClothModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.ClusterInputModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.ClusterInputModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.ClusterRendererModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.ClusterRendererModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.CoreModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.CrashReportingModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.CrashReportingModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.DSPGraphModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.DSPGraphModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.DirectorModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.DirectorModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.GIModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.GIModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.GameCenterModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.GameCenterModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.GridModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.GridModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.HotReloadModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.HotReloadModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.IMGUIModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.IMGUIModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.ImageConversionModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.ImageConversionModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.InputModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.InputModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.InputLegacyModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.InputLegacyModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.JSONSerializeModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.JSONSerializeModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.LocalizationModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.LocalizationModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.ParticleSystemModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.ParticleSystemModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.PerformanceReportingModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.PerformanceReportingModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.PhysicsModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.PhysicsModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.Physics2DModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.Physics2DModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.ProfilerModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.ProfilerModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.RuntimeInitializeOnLoadManagerInitializerModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.RuntimeInitializeOnLoadManagerInitializerModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.ScreenCaptureModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.ScreenCaptureModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.SharedInternalsModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.SharedInternalsModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.SpriteMaskModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.SpriteMaskModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.SpriteShapeModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.SpriteShapeModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.StreamingModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.StreamingModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.SubstanceModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.SubstanceModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.SubsystemsModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.SubsystemsModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.TLSModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.TLSModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.TerrainModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.TerrainModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.TerrainPhysicsModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.TerrainPhysicsModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.TextCoreFontEngineModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.TextCoreFontEngineModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.TextCoreTextEngineModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.TextCoreTextEngineModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.TextRenderingModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.TextRenderingModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.TilemapModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.TilemapModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.UIModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.UIModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.UIElementsModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.UIElementsModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.UIElementsNativeModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.UIElementsNativeModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.UIWidgetsModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.UIWidgetsModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.UNETModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.UNETModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.UmbraModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.UmbraModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.UnityAnalyticsModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.UnityAnalyticsModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.UnityAnalyticsCommonModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.UnityAnalyticsCommonModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.UnityConnectModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.UnityConnectModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.UnityCurlModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.UnityCurlModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.UnityTestProtocolModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.UnityTestProtocolModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.UnityWebRequestModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.UnityWebRequestModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.UnityWebRequestAssetBundleModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.UnityWebRequestAssetBundleModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.UnityWebRequestAudioModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.UnityWebRequestAudioModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.UnityWebRequestTextureModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.UnityWebRequestTextureModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.UnityWebRequestWWWModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.UnityWebRequestWWWModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.VFXModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.VFXModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.VRModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.VRModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.VehiclesModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.VehiclesModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.VideoModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.VideoModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.VirtualTexturingModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.VirtualTexturingModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.WindModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.WindModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.XRModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEngine.XRModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEditor">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEditor.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEditor.CoreModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEditor.CoreModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEditor.DeviceSimulatorModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEditor.DeviceSimulatorModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEditor.DiagnosticsModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEditor.DiagnosticsModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEditor.GraphViewModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEditor.GraphViewModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEditor.PackageManagerUIModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEditor.PackageManagerUIModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEditor.QuickSearchModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEditor.QuickSearchModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEditor.SceneTemplateModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEditor.SceneTemplateModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEditor.TextCoreFontEngineModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEditor.TextCoreFontEngineModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEditor.TextCoreTextEngineModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEditor.TextCoreTextEngineModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEditor.UIBuilderModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEditor.UIBuilderModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEditor.UIElementsModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEditor.UIElementsModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEditor.UIElementsSamplesModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEditor.UIElementsSamplesModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEditor.UIServiceModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEditor.UIServiceModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEditor.UnityConnectModule">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\Managed\UnityEngine\UnityEditor.UnityConnectModule.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Google.Protobuf">
|
||||||
|
<HintPath>D:\myproject\unity\JNFrame\Assets\Packages\Google.Protobuf.3.15.8\lib\netstandard2.0\Google.Protobuf.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Runtime.CompilerServices.Unsafe">
|
||||||
|
<HintPath>D:\myproject\unity\JNFrame\Assets\Packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Unity.VisualScripting.Antlr3.Runtime">
|
||||||
|
<HintPath>D:\myproject\unity\JNFrame\Library\PackageCache\com.unity.visualscripting@1.8.0\Runtime\VisualScripting.Flow\Dependencies\NCalc\Unity.VisualScripting.Antlr3.Runtime.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="ReportGeneratorMerged">
|
||||||
|
<HintPath>D:\myproject\unity\JNFrame\Library\PackageCache\com.unity.testtools.codecoverage@1.2.3\lib\ReportGenerator\ReportGeneratorMerged.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="netstandard">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\ref\2.1.0\netstandard.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Win32.Primitives">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\Microsoft.Win32.Primitives.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.AppContext">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.AppContext.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Buffers">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Buffers.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Collections.Concurrent">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Collections.Concurrent.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Collections">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Collections.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Collections.NonGeneric">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Collections.NonGeneric.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Collections.Specialized">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Collections.Specialized.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.ComponentModel">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.ComponentModel.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.ComponentModel.EventBasedAsync">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.ComponentModel.EventBasedAsync.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.ComponentModel.Primitives">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.ComponentModel.Primitives.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.ComponentModel.TypeConverter">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.ComponentModel.TypeConverter.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Console">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Console.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Data.Common">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Data.Common.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Diagnostics.Contracts">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Diagnostics.Contracts.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Diagnostics.Debug">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Diagnostics.Debug.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Diagnostics.FileVersionInfo">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Diagnostics.FileVersionInfo.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Diagnostics.Process">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Diagnostics.Process.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Diagnostics.StackTrace">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Diagnostics.StackTrace.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Diagnostics.TextWriterTraceListener">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Diagnostics.TextWriterTraceListener.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Diagnostics.Tools">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Diagnostics.Tools.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Diagnostics.TraceSource">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Diagnostics.TraceSource.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Diagnostics.Tracing">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Diagnostics.Tracing.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Drawing.Primitives">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Drawing.Primitives.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Dynamic.Runtime">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Dynamic.Runtime.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Globalization.Calendars">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Globalization.Calendars.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Globalization">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Globalization.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Globalization.Extensions">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Globalization.Extensions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.IO.Compression">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.IO.Compression.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.IO.Compression.ZipFile">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.IO.Compression.ZipFile.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.IO">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.IO.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.IO.FileSystem">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.IO.FileSystem.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.IO.FileSystem.DriveInfo">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.IO.FileSystem.DriveInfo.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.IO.FileSystem.Primitives">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.IO.FileSystem.Primitives.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.IO.FileSystem.Watcher">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.IO.FileSystem.Watcher.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.IO.IsolatedStorage">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.IO.IsolatedStorage.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.IO.MemoryMappedFiles">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.IO.MemoryMappedFiles.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.IO.Pipes">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.IO.Pipes.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.IO.UnmanagedMemoryStream">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.IO.UnmanagedMemoryStream.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Linq">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Linq.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Linq.Expressions">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Linq.Expressions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Linq.Parallel">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Linq.Parallel.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Linq.Queryable">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Linq.Queryable.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Memory">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Memory.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Net.Http">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Net.Http.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Net.NameResolution">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Net.NameResolution.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Net.NetworkInformation">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Net.NetworkInformation.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Net.Ping">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Net.Ping.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Net.Primitives">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Net.Primitives.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Net.Requests">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Net.Requests.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Net.Security">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Net.Security.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Net.Sockets">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Net.Sockets.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Net.WebHeaderCollection">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Net.WebHeaderCollection.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Net.WebSockets.Client">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Net.WebSockets.Client.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Net.WebSockets">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Net.WebSockets.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Numerics.Vectors">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Numerics.Vectors.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.ObjectModel">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.ObjectModel.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Reflection.DispatchProxy">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Reflection.DispatchProxy.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Reflection">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Reflection.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Reflection.Emit">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Reflection.Emit.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Reflection.Emit.ILGeneration">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Reflection.Emit.ILGeneration.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Reflection.Emit.Lightweight">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Reflection.Emit.Lightweight.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Reflection.Extensions">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Reflection.Extensions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Reflection.Primitives">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Reflection.Primitives.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Resources.Reader">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Resources.Reader.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Resources.ResourceManager">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Resources.ResourceManager.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Resources.Writer">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Resources.Writer.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Runtime.CompilerServices.VisualC">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Runtime.CompilerServices.VisualC.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Runtime">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Runtime.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Runtime.Extensions">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Runtime.Extensions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Runtime.Handles">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Runtime.Handles.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Runtime.InteropServices">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Runtime.InteropServices.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Runtime.InteropServices.RuntimeInformation">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Runtime.Numerics">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Runtime.Numerics.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Runtime.Serialization.Formatters">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Runtime.Serialization.Formatters.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Runtime.Serialization.Json">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Runtime.Serialization.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Runtime.Serialization.Primitives">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Runtime.Serialization.Primitives.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Runtime.Serialization.Xml">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Runtime.Serialization.Xml.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Security.Claims">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Security.Claims.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Security.Cryptography.Algorithms">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Security.Cryptography.Algorithms.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Security.Cryptography.Csp">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Security.Cryptography.Csp.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Security.Cryptography.Encoding">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Security.Cryptography.Encoding.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Security.Cryptography.Primitives">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Security.Cryptography.Primitives.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Security.Cryptography.X509Certificates">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Security.Cryptography.X509Certificates.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Security.Principal">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Security.Principal.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Security.SecureString">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Security.SecureString.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Text.Encoding">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Text.Encoding.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Text.Encoding.Extensions">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Text.Encoding.Extensions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Text.RegularExpressions">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Text.RegularExpressions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Threading">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Threading.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Threading.Overlapped">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Threading.Overlapped.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Threading.Tasks">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Threading.Tasks.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Threading.Tasks.Extensions">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Threading.Tasks.Parallel">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Threading.Tasks.Parallel.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Threading.Thread">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Threading.Thread.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Threading.ThreadPool">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Threading.ThreadPool.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Threading.Timer">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Threading.Timer.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.ValueTuple">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.ValueTuple.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Xml.ReaderWriter">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Xml.ReaderWriter.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Xml.XDocument">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Xml.XDocument.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Xml.XmlDocument">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Xml.XmlDocument.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Xml.XmlSerializer">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Xml.XmlSerializer.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Xml.XPath">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Xml.XPath.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Xml.XPath.XDocument">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netstandard\System.Xml.XPath.XDocument.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Runtime.InteropServices.WindowsRuntime">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\Extensions\2.0.0\System.Runtime.InteropServices.WindowsRuntime.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="mscorlib">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netfx\mscorlib.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.ComponentModel.Composition">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netfx\System.ComponentModel.Composition.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Core">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netfx\System.Core.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Data">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netfx\System.Data.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netfx\System.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Drawing">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netfx\System.Drawing.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.IO.Compression.FileSystem">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netfx\System.IO.Compression.FileSystem.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Net">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netfx\System.Net.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Numerics">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netfx\System.Numerics.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Runtime.Serialization">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netfx\System.Runtime.Serialization.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.ServiceModel.Web">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netfx\System.ServiceModel.Web.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Transactions">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netfx\System.Transactions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Web">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netfx\System.Web.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Windows">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netfx\System.Windows.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Xml">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netfx\System.Xml.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Xml.Linq">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netfx\System.Xml.Linq.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Xml.Serialization">
|
||||||
|
<HintPath>D:\Unity\2021.3.27f1c2\Editor\Data\NetStandard\compat\2.1.0\shims\netfx\System.Xml.Serialization.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Unity.VisualScripting.Flow.Editor">
|
||||||
|
<HintPath>D:\myproject\unity\JNFrame\Library\ScriptAssemblies\Unity.VisualScripting.Flow.Editor.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Unity.VSCode.Editor">
|
||||||
|
<HintPath>D:\myproject\unity\JNFrame\Library\ScriptAssemblies\Unity.VSCode.Editor.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Unity.VisualScripting.Shared.Editor">
|
||||||
|
<HintPath>D:\myproject\unity\JNFrame\Library\ScriptAssemblies\Unity.VisualScripting.Shared.Editor.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Unity.TextMeshPro.Editor">
|
||||||
|
<HintPath>D:\myproject\unity\JNFrame\Library\ScriptAssemblies\Unity.TextMeshPro.Editor.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Unity.VisualStudio.Editor">
|
||||||
|
<HintPath>D:\myproject\unity\JNFrame\Library\ScriptAssemblies\Unity.VisualStudio.Editor.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Unity.Performance.Profile-Analyzer.Editor">
|
||||||
|
<HintPath>D:\myproject\unity\JNFrame\Library\ScriptAssemblies\Unity.Performance.Profile-Analyzer.Editor.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Unity.TestTools.CodeCoverage.Editor.OpenCover.Model">
|
||||||
|
<HintPath>D:\myproject\unity\JNFrame\Library\ScriptAssemblies\Unity.TestTools.CodeCoverage.Editor.OpenCover.Model.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Unity.Timeline.Editor">
|
||||||
|
<HintPath>D:\myproject\unity\JNFrame\Library\ScriptAssemblies\Unity.Timeline.Editor.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Unity.Timeline">
|
||||||
|
<HintPath>D:\myproject\unity\JNFrame\Library\ScriptAssemblies\Unity.Timeline.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Unity.VisualScripting.Core.Editor">
|
||||||
|
<HintPath>D:\myproject\unity\JNFrame\Library\ScriptAssemblies\Unity.VisualScripting.Core.Editor.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Unity.TextMeshPro">
|
||||||
|
<HintPath>D:\myproject\unity\JNFrame\Library\ScriptAssemblies\Unity.TextMeshPro.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Unity.VisualScripting.State.Editor">
|
||||||
|
<HintPath>D:\myproject\unity\JNFrame\Library\ScriptAssemblies\Unity.VisualScripting.State.Editor.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Unity.VisualScripting.SettingsProvider.Editor">
|
||||||
|
<HintPath>D:\myproject\unity\JNFrame\Library\ScriptAssemblies\Unity.VisualScripting.SettingsProvider.Editor.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Unity.TestTools.CodeCoverage.Editor.OpenCover.Mono.Reflection">
|
||||||
|
<HintPath>D:\myproject\unity\JNFrame\Library\ScriptAssemblies\Unity.TestTools.CodeCoverage.Editor.OpenCover.Mono.Reflection.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Unity.VisualScripting.Flow">
|
||||||
|
<HintPath>D:\myproject\unity\JNFrame\Library\ScriptAssemblies\Unity.VisualScripting.Flow.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEditor.UI">
|
||||||
|
<HintPath>D:\myproject\unity\JNFrame\Library\ScriptAssemblies\UnityEditor.UI.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Unity.PlasticSCM.Editor">
|
||||||
|
<HintPath>D:\myproject\unity\JNFrame\Library\ScriptAssemblies\Unity.PlasticSCM.Editor.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Unity.Rider.Editor">
|
||||||
|
<HintPath>D:\myproject\unity\JNFrame\Library\ScriptAssemblies\Unity.Rider.Editor.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Unity.TestTools.CodeCoverage.Editor">
|
||||||
|
<HintPath>D:\myproject\unity\JNFrame\Library\ScriptAssemblies\Unity.TestTools.CodeCoverage.Editor.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine.UI">
|
||||||
|
<HintPath>D:\myproject\unity\JNFrame\Library\ScriptAssemblies\UnityEngine.UI.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Unity.VisualScripting.State">
|
||||||
|
<HintPath>D:\myproject\unity\JNFrame\Library\ScriptAssemblies\Unity.VisualScripting.State.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Unity.VisualScripting.Core">
|
||||||
|
<HintPath>D:\myproject\unity\JNFrame\Library\ScriptAssemblies\Unity.VisualScripting.Core.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Unity.EditorCoroutines.Editor">
|
||||||
|
<HintPath>D:\myproject\unity\JNFrame\Library\ScriptAssemblies\Unity.EditorCoroutines.Editor.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="Assembly-CSharp-firstpass.csproj">
|
||||||
|
<Project>{e5544f0c-cd3e-f7be-dc52-046b131df43d}</Project>
|
||||||
|
<Name>Assembly-CSharp-firstpass</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="UniTask.TextMeshPro.csproj">
|
||||||
|
<Project>{4b964c85-7c9d-2d07-a2e0-8595262e4e96}</Project>
|
||||||
|
<Name>UniTask.TextMeshPro</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="UniTask.DOTween.csproj">
|
||||||
|
<Project>{99c4c7d2-ca96-1038-95e0-77e225df2b06}</Project>
|
||||||
|
<Name>UniTask.DOTween</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="UniTask.csproj">
|
||||||
|
<Project>{39f5acb9-cdbb-9f48-497c-14159a0afd38}</Project>
|
||||||
|
<Name>UniTask</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="UniTask.Addressables.csproj">
|
||||||
|
<Project>{6d8bd378-3e5b-6997-5e5e-288243f0f72b}</Project>
|
||||||
|
<Name>UniTask.Addressables</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="UniTask.Linq.csproj">
|
||||||
|
<Project>{7f60f694-1f75-f2f0-5fde-36ccb7fd82d1}</Project>
|
||||||
|
<Name>UniTask.Linq</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
16
JNFrame/Assets/NuGet.config
Normal file
16
JNFrame/Assets/NuGet.config
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<packageSources>
|
||||||
|
<clear />
|
||||||
|
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
|
||||||
|
</packageSources>
|
||||||
|
<disabledPackageSources />
|
||||||
|
<activePackageSource>
|
||||||
|
<add key="All" value="(Aggregate source)" />
|
||||||
|
</activePackageSource>
|
||||||
|
<config>
|
||||||
|
<add key="repositoryPath" value="./Packages" />
|
||||||
|
<add key="PackagesConfigDirectoryPath" value="." />
|
||||||
|
<add key="slimRestore" value="true" />
|
||||||
|
</config>
|
||||||
|
</configuration>
|
23
JNFrame/Assets/NuGet.config.meta
Normal file
23
JNFrame/Assets/NuGet.config.meta
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ce5d180ef4cefe947b2cd08b26c11bc1
|
||||||
|
labels:
|
||||||
|
- NuGetForUnity
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
JNFrame/Assets/NuGet.meta
Normal file
8
JNFrame/Assets/NuGet.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: dbf134857daf7df428aa31cdd055514f
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
9
JNFrame/Assets/NuGet/Editor.meta
Normal file
9
JNFrame/Assets/NuGet/Editor.meta
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b3fad56c531ac5a4db190a745f589a8e
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1510280304
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
BIN
JNFrame/Assets/NuGet/Editor/NugetForUnity.dll
Normal file
BIN
JNFrame/Assets/NuGet/Editor/NugetForUnity.dll
Normal file
Binary file not shown.
33
JNFrame/Assets/NuGet/Editor/NugetForUnity.dll.meta
Normal file
33
JNFrame/Assets/NuGet/Editor/NugetForUnity.dll.meta
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8dc1be91775c4bb469f6b74cef450eaa
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
- first:
|
||||||
|
Windows Store Apps: WindowsStoreApps
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: AnyCPU
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
21
JNFrame/Assets/NuGet/LICENSE
Normal file
21
JNFrame/Assets/NuGet/LICENSE
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2018 Patrick McCarthy
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
8
JNFrame/Assets/NuGet/LICENSE.meta
Normal file
8
JNFrame/Assets/NuGet/LICENSE.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1d9014b99ad06af428514a5902d29ff3
|
||||||
|
timeCreated: 1573248500
|
||||||
|
licenseType: Pro
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
BIN
JNFrame/Assets/NuGet/README.pdf
Normal file
BIN
JNFrame/Assets/NuGet/README.pdf
Normal file
Binary file not shown.
8
JNFrame/Assets/NuGet/README.pdf.meta
Normal file
8
JNFrame/Assets/NuGet/README.pdf.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 83c5d2001771f15429a88d67e81366d6
|
||||||
|
timeCreated: 1517876157
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
9
JNFrame/Assets/NuGet/Resources.meta
Normal file
9
JNFrame/Assets/NuGet/Resources.meta
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1738075a39a390447b7a620ca6962142
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1510280362
|
||||||
|
licenseType: Free
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
BIN
JNFrame/Assets/NuGet/Resources/defaultIcon.png
Normal file
BIN
JNFrame/Assets/NuGet/Resources/defaultIcon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
88
JNFrame/Assets/NuGet/Resources/defaultIcon.png.meta
Normal file
88
JNFrame/Assets/NuGet/Resources/defaultIcon.png.meta
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: eec19781926cd2248b7c9abfde8db555
|
||||||
|
TextureImporter:
|
||||||
|
fileIDToRecycleName: {}
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 9
|
||||||
|
mipmaps:
|
||||||
|
mipMapMode: 0
|
||||||
|
enableMipMap: 1
|
||||||
|
sRGBTexture: 1
|
||||||
|
linearTexture: 0
|
||||||
|
fadeOut: 0
|
||||||
|
borderMipMap: 0
|
||||||
|
mipMapsPreserveCoverage: 0
|
||||||
|
alphaTestReferenceValue: 0.5
|
||||||
|
mipMapFadeDistanceStart: 1
|
||||||
|
mipMapFadeDistanceEnd: 3
|
||||||
|
bumpmap:
|
||||||
|
convertToNormalMap: 0
|
||||||
|
externalNormalMap: 0
|
||||||
|
heightScale: 0.25
|
||||||
|
normalMapFilter: 0
|
||||||
|
isReadable: 0
|
||||||
|
streamingMipmaps: 0
|
||||||
|
streamingMipmapsPriority: 0
|
||||||
|
grayScaleToAlpha: 0
|
||||||
|
generateCubemap: 6
|
||||||
|
cubemapConvolution: 0
|
||||||
|
seamlessCubemap: 0
|
||||||
|
textureFormat: -1
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
filterMode: -1
|
||||||
|
aniso: -1
|
||||||
|
mipBias: -100
|
||||||
|
wrapU: 1
|
||||||
|
wrapV: 1
|
||||||
|
wrapW: 1
|
||||||
|
nPOTScale: 0
|
||||||
|
lightmap: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
spriteMode: 1
|
||||||
|
spriteExtrude: 1
|
||||||
|
spriteMeshType: 1
|
||||||
|
alignment: 0
|
||||||
|
spritePivot: {x: 0.5, y: 0.5}
|
||||||
|
spritePixelsToUnits: 100
|
||||||
|
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
spriteGenerateFallbackPhysicsShape: 1
|
||||||
|
alphaUsage: 1
|
||||||
|
alphaIsTransparency: 1
|
||||||
|
spriteTessellationDetail: -1
|
||||||
|
textureType: 8
|
||||||
|
textureShape: 1
|
||||||
|
singleChannelComponent: 0
|
||||||
|
maxTextureSizeSet: 0
|
||||||
|
compressionQualitySet: 0
|
||||||
|
textureFormatSet: 0
|
||||||
|
platformSettings:
|
||||||
|
- serializedVersion: 2
|
||||||
|
buildTarget: DefaultTexturePlatform
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
spriteSheet:
|
||||||
|
serializedVersion: 2
|
||||||
|
sprites: []
|
||||||
|
outline: []
|
||||||
|
physicsShape: []
|
||||||
|
bones: []
|
||||||
|
spriteID: 215e43cda847e6d44af8b40376eeed8a
|
||||||
|
vertices: []
|
||||||
|
indices:
|
||||||
|
edges: []
|
||||||
|
weights: []
|
||||||
|
spritePackingTag:
|
||||||
|
pSDRemoveMatte: 0
|
||||||
|
pSDShowRemoveMatteOption: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
JNFrame/Assets/Packages.meta
Normal file
8
JNFrame/Assets/Packages.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f5ddeed46214a6549ad76520afa1f466
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
JNFrame/Assets/Packages/Google.Protobuf.3.15.8.meta
Normal file
8
JNFrame/Assets/Packages/Google.Protobuf.3.15.8.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4e6b7d62fcb9ab846a7e98ef1d3266dd
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
BIN
JNFrame/Assets/Packages/Google.Protobuf.3.15.8/.signature.p7s
vendored
Normal file
BIN
JNFrame/Assets/Packages/Google.Protobuf.3.15.8/.signature.p7s
vendored
Normal file
Binary file not shown.
30
JNFrame/Assets/Packages/Google.Protobuf.3.15.8/Google.Protobuf.nuspec
vendored
Normal file
30
JNFrame/Assets/Packages/Google.Protobuf.3.15.8/Google.Protobuf.nuspec
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
|
||||||
|
<metadata>
|
||||||
|
<id>Google.Protobuf</id>
|
||||||
|
<version>3.15.8</version>
|
||||||
|
<authors>Google Inc.</authors>
|
||||||
|
<owners>Google Inc.</owners>
|
||||||
|
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||||
|
<licenseUrl>https://github.com/protocolbuffers/protobuf/blob/master/LICENSE</licenseUrl>
|
||||||
|
<projectUrl>https://github.com/protocolbuffers/protobuf</projectUrl>
|
||||||
|
<description>C# runtime library for Protocol Buffers - Google's data interchange format.</description>
|
||||||
|
<releaseNotes>C# proto3 support</releaseNotes>
|
||||||
|
<copyright>Copyright 2015, Google Inc.</copyright>
|
||||||
|
<tags>Protocol Buffers Binary Serialization Format Google proto proto3</tags>
|
||||||
|
<repository type="git" url="https://github.com/protocolbuffers/protobuf.git" commit="436bd7880e458532901c58f4d9d1ea23fa7edd52" />
|
||||||
|
<dependencies>
|
||||||
|
<group targetFramework=".NETFramework4.5">
|
||||||
|
<dependency id="System.Memory" version="4.5.3" exclude="Build,Analyzers" />
|
||||||
|
</group>
|
||||||
|
<group targetFramework=".NETStandard1.1">
|
||||||
|
<dependency id="NETStandard.Library" version="1.6.1" exclude="Build,Analyzers" />
|
||||||
|
<dependency id="System.Memory" version="4.5.3" exclude="Build,Analyzers" />
|
||||||
|
</group>
|
||||||
|
<group targetFramework=".NETStandard2.0">
|
||||||
|
<dependency id="System.Memory" version="4.5.3" exclude="Build,Analyzers" />
|
||||||
|
<dependency id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" exclude="Build,Analyzers" />
|
||||||
|
</group>
|
||||||
|
</dependencies>
|
||||||
|
</metadata>
|
||||||
|
</package>
|
7
JNFrame/Assets/Packages/Google.Protobuf.3.15.8/Google.Protobuf.nuspec.meta
vendored
Normal file
7
JNFrame/Assets/Packages/Google.Protobuf.3.15.8/Google.Protobuf.nuspec.meta
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f251e4c06aaa618458c77025c57ea05c
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
JNFrame/Assets/Packages/Google.Protobuf.3.15.8/lib.meta
vendored
Normal file
8
JNFrame/Assets/Packages/Google.Protobuf.3.15.8/lib.meta
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c3a32c58ec0f04f43b8a83eaaee0fad6
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
JNFrame/Assets/Packages/Google.Protobuf.3.15.8/lib/netstandard2.0.meta
vendored
Normal file
8
JNFrame/Assets/Packages/Google.Protobuf.3.15.8/lib/netstandard2.0.meta
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0d6bbee8d0e4206419e6a1f3d21c49d6
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
BIN
JNFrame/Assets/Packages/Google.Protobuf.3.15.8/lib/netstandard2.0/Google.Protobuf.dll
vendored
Normal file
BIN
JNFrame/Assets/Packages/Google.Protobuf.3.15.8/lib/netstandard2.0/Google.Protobuf.dll
vendored
Normal file
Binary file not shown.
23
JNFrame/Assets/Packages/Google.Protobuf.3.15.8/lib/netstandard2.0/Google.Protobuf.dll.meta
vendored
Normal file
23
JNFrame/Assets/Packages/Google.Protobuf.3.15.8/lib/netstandard2.0/Google.Protobuf.dll.meta
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 57fb929cf6fba524c850bd783eeff4a7
|
||||||
|
labels:
|
||||||
|
- NuGetForUnity
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
10097
JNFrame/Assets/Packages/Google.Protobuf.3.15.8/lib/netstandard2.0/Google.Protobuf.xml
vendored
Normal file
10097
JNFrame/Assets/Packages/Google.Protobuf.3.15.8/lib/netstandard2.0/Google.Protobuf.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
7
JNFrame/Assets/Packages/Google.Protobuf.3.15.8/lib/netstandard2.0/Google.Protobuf.xml.meta
vendored
Normal file
7
JNFrame/Assets/Packages/Google.Protobuf.3.15.8/lib/netstandard2.0/Google.Protobuf.xml.meta
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 64f78998eaa18134589fb236352aab0d
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1435edfef9c5969418a51104922af85c
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
BIN
JNFrame/Assets/Packages/System.Runtime.CompilerServices.Unsafe.4.5.2/.signature.p7s
vendored
Normal file
BIN
JNFrame/Assets/Packages/System.Runtime.CompilerServices.Unsafe.4.5.2/.signature.p7s
vendored
Normal file
Binary file not shown.
23
JNFrame/Assets/Packages/System.Runtime.CompilerServices.Unsafe.4.5.2/LICENSE.TXT
vendored
Normal file
23
JNFrame/Assets/Packages/System.Runtime.CompilerServices.Unsafe.4.5.2/LICENSE.TXT
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) .NET Foundation and Contributors
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
7
JNFrame/Assets/Packages/System.Runtime.CompilerServices.Unsafe.4.5.2/LICENSE.TXT.meta
vendored
Normal file
7
JNFrame/Assets/Packages/System.Runtime.CompilerServices.Unsafe.4.5.2/LICENSE.TXT.meta
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 730c983d2c070864992ba21ba91d94c9
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
|
||||||
|
<metadata minClientVersion="2.12">
|
||||||
|
<id>System.Runtime.CompilerServices.Unsafe</id>
|
||||||
|
<version>4.5.2</version>
|
||||||
|
<title>System.Runtime.CompilerServices.Unsafe</title>
|
||||||
|
<authors>Microsoft</authors>
|
||||||
|
<owners>microsoft,dotnetframework</owners>
|
||||||
|
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||||
|
<licenseUrl>https://github.com/dotnet/corefx/blob/master/LICENSE.TXT</licenseUrl>
|
||||||
|
<projectUrl>https://dot.net/</projectUrl>
|
||||||
|
<iconUrl>http://go.microsoft.com/fwlink/?LinkID=288859</iconUrl>
|
||||||
|
<description>Provides the System.Runtime.CompilerServices.Unsafe class, which provides generic, low-level functionality for manipulating pointers.
|
||||||
|
|
||||||
|
Commonly Used Types:
|
||||||
|
System.Runtime.CompilerServices.Unsafe
|
||||||
|
|
||||||
|
02b11eeee1fbc5f3ef43a1452fe07efd25fa1715
|
||||||
|
When using NuGet 3.x this package requires at least version 3.4.</description>
|
||||||
|
<releaseNotes>https://go.microsoft.com/fwlink/?LinkID=799421</releaseNotes>
|
||||||
|
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
|
||||||
|
<serviceable>true</serviceable>
|
||||||
|
<dependencies>
|
||||||
|
<group targetFramework=".NETFramework4.5" />
|
||||||
|
<group targetFramework=".NETCoreApp2.0" />
|
||||||
|
<group targetFramework=".NETStandard1.0">
|
||||||
|
<dependency id="System.Runtime" version="4.3.0" />
|
||||||
|
</group>
|
||||||
|
<group targetFramework=".NETStandard2.0" />
|
||||||
|
<group targetFramework=".NETPortable4.5-Profile259" />
|
||||||
|
<group targetFramework="Windows8.0" />
|
||||||
|
<group targetFramework="WindowsPhone8.0" />
|
||||||
|
<group targetFramework="WindowsPhoneApp8.1" />
|
||||||
|
</dependencies>
|
||||||
|
</metadata>
|
||||||
|
</package>
|
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0ad80367ad9e0fd418de576d0bc7197c
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
309
JNFrame/Assets/Packages/System.Runtime.CompilerServices.Unsafe.4.5.2/THIRD-PARTY-NOTICES.TXT
vendored
Normal file
309
JNFrame/Assets/Packages/System.Runtime.CompilerServices.Unsafe.4.5.2/THIRD-PARTY-NOTICES.TXT
vendored
Normal file
@ -0,0 +1,309 @@
|
|||||||
|
.NET Core uses third-party libraries or other resources that may be
|
||||||
|
distributed under licenses different than the .NET Core software.
|
||||||
|
|
||||||
|
In the event that we accidentally failed to list a required notice, please
|
||||||
|
bring it to our attention. Post an issue or email us:
|
||||||
|
|
||||||
|
dotnet@microsoft.com
|
||||||
|
|
||||||
|
The attached notices are provided for information only.
|
||||||
|
|
||||||
|
License notice for Slicing-by-8
|
||||||
|
-------------------------------
|
||||||
|
|
||||||
|
http://sourceforge.net/projects/slicing-by-8/
|
||||||
|
|
||||||
|
Copyright (c) 2004-2006 Intel Corporation - All Rights Reserved
|
||||||
|
|
||||||
|
|
||||||
|
This software program is licensed subject to the BSD License, available at
|
||||||
|
http://www.opensource.org/licenses/bsd-license.html.
|
||||||
|
|
||||||
|
|
||||||
|
License notice for Unicode data
|
||||||
|
-------------------------------
|
||||||
|
|
||||||
|
http://www.unicode.org/copyright.html#License
|
||||||
|
|
||||||
|
Copyright © 1991-2017 Unicode, Inc. All rights reserved.
|
||||||
|
Distributed under the Terms of Use in http://www.unicode.org/copyright.html.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of the Unicode data files and any associated documentation
|
||||||
|
(the "Data Files") or Unicode software and any associated documentation
|
||||||
|
(the "Software") to deal in the Data Files or Software
|
||||||
|
without restriction, including without limitation the rights to use,
|
||||||
|
copy, modify, merge, publish, distribute, and/or sell copies of
|
||||||
|
the Data Files or Software, and to permit persons to whom the Data Files
|
||||||
|
or Software are furnished to do so, provided that either
|
||||||
|
(a) this copyright and permission notice appear with all copies
|
||||||
|
of the Data Files or Software, or
|
||||||
|
(b) this copyright and permission notice appear in associated
|
||||||
|
Documentation.
|
||||||
|
|
||||||
|
THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
|
||||||
|
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||||
|
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT OF THIRD PARTY RIGHTS.
|
||||||
|
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS
|
||||||
|
NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL
|
||||||
|
DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||||
|
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||||
|
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
PERFORMANCE OF THE DATA FILES OR SOFTWARE.
|
||||||
|
|
||||||
|
Except as contained in this notice, the name of a copyright holder
|
||||||
|
shall not be used in advertising or otherwise to promote the sale,
|
||||||
|
use or other dealings in these Data Files or Software without prior
|
||||||
|
written authorization of the copyright holder.
|
||||||
|
|
||||||
|
License notice for Zlib
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
https://github.com/madler/zlib
|
||||||
|
http://zlib.net/zlib_license.html
|
||||||
|
|
||||||
|
/* zlib.h -- interface of the 'zlib' general purpose compression library
|
||||||
|
version 1.2.11, January 15th, 2017
|
||||||
|
|
||||||
|
Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
|
||||||
|
Jean-loup Gailly Mark Adler
|
||||||
|
jloup@gzip.org madler@alumni.caltech.edu
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
License notice for Mono
|
||||||
|
-------------------------------
|
||||||
|
|
||||||
|
http://www.mono-project.com/docs/about-mono/
|
||||||
|
|
||||||
|
Copyright (c) .NET Foundation Contributors
|
||||||
|
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the Software), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
License notice for International Organization for Standardization
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
|
||||||
|
Portions (C) International Organization for Standardization 1986:
|
||||||
|
Permission to copy in any form is granted for use with
|
||||||
|
conforming SGML systems and applications as defined in
|
||||||
|
ISO 8879, provided this notice is included in all copies.
|
||||||
|
|
||||||
|
License notice for Intel
|
||||||
|
------------------------
|
||||||
|
|
||||||
|
"Copyright (c) 2004-2006 Intel Corporation - All Rights Reserved
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
License notice for Xamarin and Novell
|
||||||
|
-------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2015 Xamarin, Inc (http://www.xamarin.com)
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
Copyright (c) 2011 Novell, Inc (http://www.novell.com)
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
Third party notice for W3C
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
"W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE
|
||||||
|
Status: This license takes effect 13 May, 2015.
|
||||||
|
This work is being provided by the copyright holders under the following license.
|
||||||
|
License
|
||||||
|
By obtaining and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions.
|
||||||
|
Permission to copy, modify, and distribute this work, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the work or portions thereof, including modifications:
|
||||||
|
The full text of this NOTICE in a location viewable to users of the redistributed or derivative work.
|
||||||
|
Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C Software and Document Short Notice should be included.
|
||||||
|
Notice of any changes or modifications, through a copyright statement on the new code or document such as "This software or document includes material copied from or derived from [title and URI of the W3C document]. Copyright © [YEAR] W3C® (MIT, ERCIM, Keio, Beihang)."
|
||||||
|
Disclaimers
|
||||||
|
THIS WORK IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENT WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
|
||||||
|
COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENT.
|
||||||
|
The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the work without specific, written prior permission. Title to copyright in this work will at all times remain with copyright holders."
|
||||||
|
|
||||||
|
License notice for Bit Twiddling Hacks
|
||||||
|
--------------------------------------
|
||||||
|
|
||||||
|
Bit Twiddling Hacks
|
||||||
|
|
||||||
|
By Sean Eron Anderson
|
||||||
|
seander@cs.stanford.edu
|
||||||
|
|
||||||
|
Individually, the code snippets here are in the public domain (unless otherwise
|
||||||
|
noted) — feel free to use them however you please. The aggregate collection and
|
||||||
|
descriptions are © 1997-2005 Sean Eron Anderson. The code and descriptions are
|
||||||
|
distributed in the hope that they will be useful, but WITHOUT ANY WARRANTY and
|
||||||
|
without even the implied warranty of merchantability or fitness for a particular
|
||||||
|
purpose.
|
||||||
|
|
||||||
|
License notice for Brotli
|
||||||
|
--------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2009, 2010, 2013-2016 by the Brotli Authors.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
compress_fragment.c:
|
||||||
|
Copyright (c) 2011, Google Inc.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
|
in the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
* Neither the name of Google Inc. nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
decode_fuzzer.c:
|
||||||
|
Copyright (c) 2015 The Chromium Authors. All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
|
in the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
* Neither the name of Google Inc. nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||||
|
|
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 495cf1a0b48abaf439035bd6e3ba0226
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
JNFrame/Assets/Packages/System.Runtime.CompilerServices.Unsafe.4.5.2/lib.meta
vendored
Normal file
8
JNFrame/Assets/Packages/System.Runtime.CompilerServices.Unsafe.4.5.2/lib.meta
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 736ce6b581f4a124b9ff225ee55ca2b8
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
JNFrame/Assets/Packages/System.Runtime.CompilerServices.Unsafe.4.5.2/lib/netstandard2.0.meta
vendored
Normal file
8
JNFrame/Assets/Packages/System.Runtime.CompilerServices.Unsafe.4.5.2/lib/netstandard2.0.meta
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4238dd05a5a67de4ea235923baaa8b9a
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Binary file not shown.
@ -0,0 +1,23 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6dc30032884285a4c9d2e3474a13121d
|
||||||
|
labels:
|
||||||
|
- NuGetForUnity
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,200 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?><doc>
|
||||||
|
<assembly>
|
||||||
|
<name>System.Runtime.CompilerServices.Unsafe</name>
|
||||||
|
</assembly>
|
||||||
|
<members>
|
||||||
|
<member name="T:System.Runtime.CompilerServices.Unsafe">
|
||||||
|
<summary>Contains generic, low-level functionality for manipulating pointers.</summary>
|
||||||
|
</member>
|
||||||
|
<member name="M:System.Runtime.CompilerServices.Unsafe.Add``1(``0@,System.Int32)">
|
||||||
|
<summary>Adds an element offset to the given reference.</summary>
|
||||||
|
<param name="source">The reference to add the offset to.</param>
|
||||||
|
<param name="elementOffset">The offset to add.</param>
|
||||||
|
<typeparam name="T">The type of reference.</typeparam>
|
||||||
|
<returns>A new reference that reflects the addition of offset to pointer.</returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:System.Runtime.CompilerServices.Unsafe.Add``1(``0@,System.IntPtr)">
|
||||||
|
<summary>Adds an element offset to the given reference.</summary>
|
||||||
|
<param name="source">The reference to add the offset to.</param>
|
||||||
|
<param name="elementOffset">The offset to add.</param>
|
||||||
|
<typeparam name="T">The type of reference.</typeparam>
|
||||||
|
<returns>A new reference that reflects the addition of offset to pointer.</returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:System.Runtime.CompilerServices.Unsafe.AddByteOffset``1(``0@,System.IntPtr)">
|
||||||
|
<summary>Adds a byte offset to the given reference.</summary>
|
||||||
|
<param name="source">The reference to add the offset to.</param>
|
||||||
|
<param name="byteOffset">The offset to add.</param>
|
||||||
|
<typeparam name="T">The type of reference.</typeparam>
|
||||||
|
<returns>A new reference that reflects the addition of byte offset to pointer.</returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:System.Runtime.CompilerServices.Unsafe.AreSame``1(``0@,``0@)">
|
||||||
|
<summary>Determines whether the specified references point to the same location.</summary>
|
||||||
|
<param name="left">The first reference to compare.</param>
|
||||||
|
<param name="right">The second reference to compare.</param>
|
||||||
|
<typeparam name="T">The type of reference.</typeparam>
|
||||||
|
<returns>true if <paramref name="left">left</paramref> and <paramref name="right">right</paramref> point to the same location; otherwise, false.</returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:System.Runtime.CompilerServices.Unsafe.As``1(System.Object)">
|
||||||
|
<summary>Casts the given object to the specified type.</summary>
|
||||||
|
<param name="o">The object to cast.</param>
|
||||||
|
<typeparam name="T">The type which the object will be cast to.</typeparam>
|
||||||
|
<returns>The original object, casted to the given type.</returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:System.Runtime.CompilerServices.Unsafe.As``2(``0@)">
|
||||||
|
<summary>Reinterprets the given reference as a reference to a value of type <typeparamref name="TTo">TTo</typeparamref>.</summary>
|
||||||
|
<param name="source">The reference to reinterpret.</param>
|
||||||
|
<typeparam name="TFrom">The type of reference to reinterpret..</typeparam>
|
||||||
|
<typeparam name="TTo">The desired type of the reference.</typeparam>
|
||||||
|
<returns>A reference to a value of type <typeparamref name="TTo">TTo</typeparamref>.</returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:System.Runtime.CompilerServices.Unsafe.AsPointer``1(``0@)">
|
||||||
|
<summary>Returns a pointer to the given by-ref parameter.</summary>
|
||||||
|
<param name="value">The object whose pointer is obtained.</param>
|
||||||
|
<typeparam name="T">The type of object.</typeparam>
|
||||||
|
<returns>A pointer to the given value.</returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:System.Runtime.CompilerServices.Unsafe.AsRef``1(System.Void*)">
|
||||||
|
<summary>Reinterprets the given location as a reference to a value of type <typeparamref name="T">T</typeparamref>.</summary>
|
||||||
|
<param name="source">The location of the value to reference.</param>
|
||||||
|
<typeparam name="T">The type of the interpreted location.</typeparam>
|
||||||
|
<returns>A reference to a value of type <typeparamref name="T">T</typeparamref>.</returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:System.Runtime.CompilerServices.Unsafe.ByteOffset``1(``0@,``0@)">
|
||||||
|
<summary>Determines the byte offset from origin to target from the given references.</summary>
|
||||||
|
<param name="origin">The reference to origin.</param>
|
||||||
|
<param name="target">The reference to target.</param>
|
||||||
|
<typeparam name="T">The type of reference.</typeparam>
|
||||||
|
<returns>Byte offset from origin to target i.e. <paramref name="target">target</paramref> - <paramref name="origin">origin</paramref>.</returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:System.Runtime.CompilerServices.Unsafe.Copy``1(System.Void*,``0@)">
|
||||||
|
<summary>Copies a value of type <typeparamref name="T">T</typeparamref> to the given location.</summary>
|
||||||
|
<param name="destination">The location to copy to.</param>
|
||||||
|
<param name="source">A reference to the value to copy.</param>
|
||||||
|
<typeparam name="T">The type of value to copy.</typeparam>
|
||||||
|
</member>
|
||||||
|
<member name="M:System.Runtime.CompilerServices.Unsafe.Copy``1(``0@,System.Void*)">
|
||||||
|
<summary>Copies a value of type <typeparamref name="T">T</typeparamref> to the given location.</summary>
|
||||||
|
<param name="destination">The location to copy to.</param>
|
||||||
|
<param name="source">A pointer to the value to copy.</param>
|
||||||
|
<typeparam name="T">The type of value to copy.</typeparam>
|
||||||
|
</member>
|
||||||
|
<member name="M:System.Runtime.CompilerServices.Unsafe.CopyBlock(System.Byte@,System.Byte@,System.UInt32)">
|
||||||
|
<summary>Copies bytes from the source address to the destination address.</summary>
|
||||||
|
<param name="destination">The destination address to copy to.</param>
|
||||||
|
<param name="source">The source address to copy from.</param>
|
||||||
|
<param name="byteCount">The number of bytes to copy.</param>
|
||||||
|
</member>
|
||||||
|
<member name="M:System.Runtime.CompilerServices.Unsafe.CopyBlock(System.Void*,System.Void*,System.UInt32)">
|
||||||
|
<summary>Copies bytes from the source address to the destination address.</summary>
|
||||||
|
<param name="destination">The destination address to copy to.</param>
|
||||||
|
<param name="source">The source address to copy from.</param>
|
||||||
|
<param name="byteCount">The number of bytes to copy.</param>
|
||||||
|
</member>
|
||||||
|
<member name="M:System.Runtime.CompilerServices.Unsafe.CopyBlockUnaligned(System.Void*,System.Void*,System.UInt32)">
|
||||||
|
<summary>Copies bytes from the source address to the destination address
|
||||||
|
without assuming architecture dependent alignment of the addresses.</summary>
|
||||||
|
<param name="destination">The destination address to copy to.</param>
|
||||||
|
<param name="source">The source address to copy from.</param>
|
||||||
|
<param name="byteCount">The number of bytes to copy.</param>
|
||||||
|
</member>
|
||||||
|
<member name="M:System.Runtime.CompilerServices.Unsafe.CopyBlockUnaligned(System.Byte@,System.Byte@,System.UInt32)">
|
||||||
|
<summary>Copies bytes from the source address to the destination address
|
||||||
|
without assuming architecture dependent alignment of the addresses.</summary>
|
||||||
|
<param name="destination">The destination address to copy to.</param>
|
||||||
|
<param name="source">The source address to copy from.</param>
|
||||||
|
<param name="byteCount">The number of bytes to copy.</param>
|
||||||
|
</member>
|
||||||
|
<member name="M:System.Runtime.CompilerServices.Unsafe.InitBlock(System.Byte@,System.Byte,System.UInt32)">
|
||||||
|
<summary>Initializes a block of memory at the given location with a given initial value.</summary>
|
||||||
|
<param name="startAddress">The address of the start of the memory block to initialize.</param>
|
||||||
|
<param name="value">The value to initialize the block to.</param>
|
||||||
|
<param name="byteCount">The number of bytes to initialize.</param>
|
||||||
|
</member>
|
||||||
|
<member name="M:System.Runtime.CompilerServices.Unsafe.InitBlock(System.Void*,System.Byte,System.UInt32)">
|
||||||
|
<summary>Initializes a block of memory at the given location with a given initial value.</summary>
|
||||||
|
<param name="startAddress">The address of the start of the memory block to initialize.</param>
|
||||||
|
<param name="value">The value to initialize the block to.</param>
|
||||||
|
<param name="byteCount">The number of bytes to initialize.</param>
|
||||||
|
</member>
|
||||||
|
<member name="M:System.Runtime.CompilerServices.Unsafe.InitBlockUnaligned(System.Byte@,System.Byte,System.UInt32)">
|
||||||
|
<summary>Initializes a block of memory at the given location with a given initial value
|
||||||
|
without assuming architecture dependent alignment of the address.</summary>
|
||||||
|
<param name="startAddress">The address of the start of the memory block to initialize.</param>
|
||||||
|
<param name="value">The value to initialize the block to.</param>
|
||||||
|
<param name="byteCount">The number of bytes to initialize.</param>
|
||||||
|
</member>
|
||||||
|
<member name="M:System.Runtime.CompilerServices.Unsafe.InitBlockUnaligned(System.Void*,System.Byte,System.UInt32)">
|
||||||
|
<summary>Initializes a block of memory at the given location with a given initial value
|
||||||
|
without assuming architecture dependent alignment of the address.</summary>
|
||||||
|
<param name="startAddress">The address of the start of the memory block to initialize.</param>
|
||||||
|
<param name="value">The value to initialize the block to.</param>
|
||||||
|
<param name="byteCount">The number of bytes to initialize.</param>
|
||||||
|
</member>
|
||||||
|
<member name="M:System.Runtime.CompilerServices.Unsafe.Read``1(System.Void*)">
|
||||||
|
<summary>Reads a value of type <typeparamref name="T">T</typeparamref> from the given location.</summary>
|
||||||
|
<param name="source">The location to read from.</param>
|
||||||
|
<typeparam name="T">The type to read.</typeparam>
|
||||||
|
<returns>An object of type <typeparamref name="T">T</typeparamref> read from the given location.</returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:System.Runtime.CompilerServices.Unsafe.ReadUnaligned``1(System.Byte@)">
|
||||||
|
<summary>Reads a value of type <typeparamref name="T">T</typeparamref> from the given location
|
||||||
|
without assuming architecture dependent alignment of the addresses.</summary>
|
||||||
|
<param name="source">The location to read from.</param>
|
||||||
|
<typeparam name="T">The type to read.</typeparam>
|
||||||
|
<returns>An object of type <typeparamref name="T">T</typeparamref> read from the given location.</returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:System.Runtime.CompilerServices.Unsafe.ReadUnaligned``1(System.Void*)">
|
||||||
|
<summary>Reads a value of type <typeparamref name="T">T</typeparamref> from the given location
|
||||||
|
without assuming architecture dependent alignment of the addresses.</summary>
|
||||||
|
<param name="source">The location to read from.</param>
|
||||||
|
<typeparam name="T">The type to read.</typeparam>
|
||||||
|
<returns>An object of type <typeparamref name="T">T</typeparamref> read from the given location.</returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:System.Runtime.CompilerServices.Unsafe.SizeOf``1">
|
||||||
|
<summary>Returns the size of an object of the given type parameter.</summary>
|
||||||
|
<typeparam name="T">The type of object whose size is retrieved.</typeparam>
|
||||||
|
<returns>The size of an object of type <typeparamref name="T">T</typeparamref>.</returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:System.Runtime.CompilerServices.Unsafe.Subtract``1(``0@,System.Int32)">
|
||||||
|
<summary>Subtracts an element offset from the given reference.</summary>
|
||||||
|
<param name="source">The reference to subtract the offset from.</param>
|
||||||
|
<param name="elementOffset">The offset to subtract.</param>
|
||||||
|
<typeparam name="T">The type of reference.</typeparam>
|
||||||
|
<returns>A new reference that reflects the subraction of offset from pointer.</returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:System.Runtime.CompilerServices.Unsafe.Subtract``1(``0@,System.IntPtr)">
|
||||||
|
<summary>Subtracts an element offset from the given reference.</summary>
|
||||||
|
<param name="source">The reference to subtract the offset from.</param>
|
||||||
|
<param name="elementOffset">The offset to subtract.</param>
|
||||||
|
<typeparam name="T">The type of reference.</typeparam>
|
||||||
|
<returns>A new reference that reflects the subraction of offset from pointer.</returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:System.Runtime.CompilerServices.Unsafe.SubtractByteOffset``1(``0@,System.IntPtr)">
|
||||||
|
<summary>Subtracts a byte offset from the given reference.</summary>
|
||||||
|
<param name="source">The reference to subtract the offset from.</param>
|
||||||
|
<param name="byteOffset"></param>
|
||||||
|
<typeparam name="T">The type of reference.</typeparam>
|
||||||
|
<returns>A new reference that reflects the subraction of byte offset from pointer.</returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:System.Runtime.CompilerServices.Unsafe.Write``1(System.Void*,``0)">
|
||||||
|
<summary>Writes a value of type <typeparamref name="T">T</typeparamref> to the given location.</summary>
|
||||||
|
<param name="destination">The location to write to.</param>
|
||||||
|
<param name="value">The value to write.</param>
|
||||||
|
<typeparam name="T">The type of value to write.</typeparam>
|
||||||
|
</member>
|
||||||
|
<member name="M:System.Runtime.CompilerServices.Unsafe.WriteUnaligned``1(System.Byte@,``0)">
|
||||||
|
<summary>Writes a value of type <typeparamref name="T">T</typeparamref> to the given location
|
||||||
|
without assuming architecture dependent alignment of the addresses.</summary>
|
||||||
|
<param name="destination">The location to write to.</param>
|
||||||
|
<param name="value">The value to write.</param>
|
||||||
|
<typeparam name="T">The type of value to write.</typeparam>
|
||||||
|
</member>
|
||||||
|
<member name="M:System.Runtime.CompilerServices.Unsafe.WriteUnaligned``1(System.Void*,``0)">
|
||||||
|
<summary>Writes a value of type <typeparamref name="T">T</typeparamref> to the given location
|
||||||
|
without assuming architecture dependent alignment of the addresses.</summary>
|
||||||
|
<param name="destination">The location to write to.</param>
|
||||||
|
<param name="value">The value to write.</param>
|
||||||
|
<typeparam name="T">The type of value to write.</typeparam>
|
||||||
|
</member>
|
||||||
|
</members>
|
||||||
|
</doc>
|
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2861a8d84ffb5fd43a88e4c52b8ce4f0
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6ebb778c1b6cae64aa3983e2f5abdbe2
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
1
JNFrame/Assets/Packages/System.Runtime.CompilerServices.Unsafe.4.5.2/version.txt
vendored
Normal file
1
JNFrame/Assets/Packages/System.Runtime.CompilerServices.Unsafe.4.5.2/version.txt
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
02b11eeee1fbc5f3ef43a1452fe07efd25fa1715
|
7
JNFrame/Assets/Packages/System.Runtime.CompilerServices.Unsafe.4.5.2/version.txt.meta
vendored
Normal file
7
JNFrame/Assets/Packages/System.Runtime.CompilerServices.Unsafe.4.5.2/version.txt.meta
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 48d11621921abb349a5ac31a6e0b8a95
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
JNFrame/Assets/Plugins.meta
Normal file
8
JNFrame/Assets/Plugins.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0c7f1863e7cce884fa6118afce008274
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
JNFrame/Assets/Plugins/BestHTTP.meta
Normal file
8
JNFrame/Assets/Plugins/BestHTTP.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 74209c3e8feb2fa4c93547e19081d34b
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
7
JNFrame/Assets/Plugins/BestHTTP/BestHTTP.meta
Normal file
7
JNFrame/Assets/Plugins/BestHTTP/BestHTTP.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: dc57aabb2dd648642bdfb021906367b1
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e9dc42aeefc20544bb572bce27e3b7b1
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,63 @@
|
|||||||
|
namespace BestHTTP.Authentication
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Authentication types that supported by BestHTTP.
|
||||||
|
/// The authentication is defined by the server, so the Basic and Digest are not interchangeable. If you don't know what to use, the preferred way is to choose Unknow.
|
||||||
|
/// </summary>
|
||||||
|
public enum AuthenticationTypes
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// If the authentication type is not known this will do a challenge turn to receive what methode should be choosen.
|
||||||
|
/// </summary>
|
||||||
|
Unknown,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The most basic authentication type. It's easy to do, and easy to crack. ;)
|
||||||
|
/// </summary>
|
||||||
|
Basic,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
Digest
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Hold all information that required to authenticate to a remote server.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class Credentials
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The type of the Authentication. If you don't know what to use, the preferred way is to choose Unknow.
|
||||||
|
/// </summary>
|
||||||
|
public AuthenticationTypes Type { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The username to authenticate on the remote server.
|
||||||
|
/// </summary>
|
||||||
|
public string UserName { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The password to use in the authentication process. The password will be stored only in this class.
|
||||||
|
/// </summary>
|
||||||
|
public string Password { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set up the authentication credentials with the username and password. The Type will be set to Unknown.
|
||||||
|
/// </summary>
|
||||||
|
public Credentials(string userName, string password)
|
||||||
|
:this(AuthenticationTypes.Unknown, userName, password)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set up the authentication credentials with the given authentication type, username and password.
|
||||||
|
/// </summary>
|
||||||
|
public Credentials(AuthenticationTypes type, string userName, string password)
|
||||||
|
{
|
||||||
|
this.Type = type;
|
||||||
|
this.UserName = userName;
|
||||||
|
this.Password = password;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a6a6217993b733a4e8555355d5d62776
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,280 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace BestHTTP.Authentication
|
||||||
|
{
|
||||||
|
using BestHTTP.Extensions;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Internal class that stores all information that received from a server in a WWW-Authenticate and need to construct a valid Authorization header. Based on rfc 2617 (http://tools.ietf.org/html/rfc2617).
|
||||||
|
/// Used only internally by the plugin.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class Digest
|
||||||
|
{
|
||||||
|
#region Public Properties
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The Uri that this Digest is bound to.
|
||||||
|
/// </summary>
|
||||||
|
public Uri Uri { get; private set; }
|
||||||
|
|
||||||
|
public AuthenticationTypes Type { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A string to be displayed to users so they know which username and password to use.
|
||||||
|
/// This string should contain at least the name of the host performing the authentication and might additionally indicate the collection of users who might have access.
|
||||||
|
/// </summary>
|
||||||
|
public string Realm { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A flag, indicating that the previous request from the client was rejected because the nonce value was stale.
|
||||||
|
/// If stale is TRUE (case-insensitive), the client may wish to simply retry the request with a new encrypted response, without the user for a new username and password.
|
||||||
|
/// The server should only set stale to TRUE if it receives a request for which the nonce is invalid but with a valid digest for that nonce
|
||||||
|
/// (indicating that the client knows the correct username/password).
|
||||||
|
/// If stale is FALSE, or anything other than TRUE, or the stale directive is not present, the username and/or password are invalid, and new values must be obtained.
|
||||||
|
/// </summary>
|
||||||
|
public bool Stale { get; private set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Private Properties
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A server-specified data string which should be uniquely generated each time a 401 response is made.
|
||||||
|
/// Specifically, since the string is passed in the header lines as a quoted string, the double-quote character is not allowed.
|
||||||
|
/// </summary>
|
||||||
|
private string Nonce { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A string of data, specified by the server, which should be returned by the client unchanged in the Authorization header of subsequent requests with URIs in the same protection space.
|
||||||
|
/// It is recommended that this string be base64 or data.
|
||||||
|
/// </summary>
|
||||||
|
private string Opaque { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A string indicating a pair of algorithms used to produce the digest and a checksum. If this is not present it is assumed to be "MD5".
|
||||||
|
/// If the algorithm is not understood, the challenge should be ignored (and a different one used, if there is more than one).
|
||||||
|
/// </summary>
|
||||||
|
private string Algorithm { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List of URIs, as specified in RFC XURI, that define the protection space.
|
||||||
|
/// If a URI is an abs_path, it is relative to the canonical root URL (see section 1.2 above) of the server being accessed.
|
||||||
|
/// An absoluteURI in this list may refer to a different server than the one being accessed.
|
||||||
|
/// The client can use this list to determine the set of URIs for which the same authentication information may be sent:
|
||||||
|
/// any URI that has a URI in this list as a prefix (after both have been made absolute) may be assumed to be in the same protection space.
|
||||||
|
/// If this directive is omitted or its value is empty, the client should assume that the protection space consists of all URIs on the responding server.
|
||||||
|
/// </summary>
|
||||||
|
public List<string> ProtectedUris { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If present, it is a quoted string of one or more tokens indicating the "quality of protection" values supported by the server.
|
||||||
|
/// The value "auth" indicates authentication. The value "auth-int" indicates authentication with integrity protection.
|
||||||
|
/// </summary>
|
||||||
|
private string QualityOfProtections { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// his MUST be specified if a qop directive is sent (see above), and MUST NOT be specified if the server did not send a qop directive in the WWW-Authenticate header field.
|
||||||
|
/// The nc-value is the hexadecimal count of the number of requests (including the current request) that the client has sent with the nonce value in this request.
|
||||||
|
/// </summary>
|
||||||
|
private int NonceCount { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Used to store the last HA1 that can be used in the next header generation when Algorithm is set to "md5-sess".
|
||||||
|
/// </summary>
|
||||||
|
private string HA1Sess { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
internal Digest(Uri uri)
|
||||||
|
{
|
||||||
|
this.Uri = uri;
|
||||||
|
this.Algorithm = "md5";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parses a WWW-Authenticate header's value to retrive all information.
|
||||||
|
/// </summary>
|
||||||
|
public void ParseChallange(string header)
|
||||||
|
{
|
||||||
|
// Reset some values to its defaults.
|
||||||
|
this.Type = AuthenticationTypes.Unknown;
|
||||||
|
this.Stale = false;
|
||||||
|
this.Opaque = null;
|
||||||
|
this.HA1Sess = null;
|
||||||
|
this.NonceCount = 0;
|
||||||
|
this.QualityOfProtections = null;
|
||||||
|
|
||||||
|
if (this.ProtectedUris != null)
|
||||||
|
this.ProtectedUris.Clear();
|
||||||
|
|
||||||
|
// Parse the header
|
||||||
|
WWWAuthenticateHeaderParser qpl = new WWWAuthenticateHeaderParser(header);
|
||||||
|
|
||||||
|
// Then process
|
||||||
|
foreach (var qp in qpl.Values)
|
||||||
|
switch (qp.Key)
|
||||||
|
{
|
||||||
|
case "basic": this.Type = AuthenticationTypes.Basic; break;
|
||||||
|
case "digest": this.Type = AuthenticationTypes.Digest; break;
|
||||||
|
case "realm": this.Realm = qp.Value; break;
|
||||||
|
case "domain":
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(qp.Value) || qp.Value.Length == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (this.ProtectedUris == null)
|
||||||
|
this.ProtectedUris = new List<string>();
|
||||||
|
|
||||||
|
int idx = 0;
|
||||||
|
string val = qp.Value.Read(ref idx, ' ');
|
||||||
|
do
|
||||||
|
{
|
||||||
|
this.ProtectedUris.Add(val);
|
||||||
|
val = qp.Value.Read(ref idx, ' ');
|
||||||
|
} while (idx < qp.Value.Length);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "nonce": this.Nonce = qp.Value; break;
|
||||||
|
case "qop": this.QualityOfProtections = qp.Value; break;
|
||||||
|
case "stale": this.Stale = bool.Parse(qp.Value); break;
|
||||||
|
case "opaque": this.Opaque = qp.Value; break;
|
||||||
|
case "algorithm": this.Algorithm = qp.Value; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Generates a string that can be set to an Authorization header.
|
||||||
|
/// </summary>
|
||||||
|
public string GenerateResponseHeader(HTTPRequest request, Credentials credentials, bool isProxy = false)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (Type)
|
||||||
|
{
|
||||||
|
case AuthenticationTypes.Basic:
|
||||||
|
return string.Concat("Basic ", Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format("{0}:{1}", credentials.UserName, credentials.Password))));
|
||||||
|
|
||||||
|
case AuthenticationTypes.Digest:
|
||||||
|
{
|
||||||
|
NonceCount++;
|
||||||
|
|
||||||
|
string HA1 = string.Empty;
|
||||||
|
|
||||||
|
// The cnonce-value is an opaque quoted string value provided by the client and used by both client and server to avoid chosen plaintext attacks, to provide mutual
|
||||||
|
// authentication, and to provide some message integrity protection.
|
||||||
|
string cnonce = new System.Random(request.GetHashCode()).Next(int.MinValue, int.MaxValue).ToString("X8");
|
||||||
|
|
||||||
|
string ncvalue = NonceCount.ToString("X8");
|
||||||
|
switch (Algorithm.TrimAndLower())
|
||||||
|
{
|
||||||
|
case "md5":
|
||||||
|
HA1 = string.Format("{0}:{1}:{2}", credentials.UserName, Realm, credentials.Password).CalculateMD5Hash();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "md5-sess":
|
||||||
|
if (string.IsNullOrEmpty(this.HA1Sess))
|
||||||
|
this.HA1Sess = string.Format("{0}:{1}:{2}:{3}:{4}", credentials.UserName, Realm, credentials.Password, Nonce, ncvalue).CalculateMD5Hash();
|
||||||
|
HA1 = this.HA1Sess;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: //throw new NotSupportedException("Not supported hash algorithm found in Web Authentication: " + Algorithm);
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A string of 32 hex digits, which proves that the user knows a password. Set according to the qop value.
|
||||||
|
string response = string.Empty;
|
||||||
|
|
||||||
|
// The server sent QoP-value can be a list of supported methodes(if sent at all - in this case it's null).
|
||||||
|
// The rfc is not specify that this is a space or comma separeted list. So it can be "auth, auth-int" or "auth auth-int".
|
||||||
|
// We will first check the longer value("auth-int") then the short one ("auth"). If one matches we will reset the qop to the exact value.
|
||||||
|
string qop = this.QualityOfProtections != null ? this.QualityOfProtections.TrimAndLower() : null;
|
||||||
|
|
||||||
|
// When we authenticate with a proxy and we want to tunnel the request, we have to use the CONNECT method instead of the
|
||||||
|
// request's, as the proxy will not know about the request itself.
|
||||||
|
string method = isProxy ? "CONNECT" : request.MethodType.ToString().ToUpper();
|
||||||
|
|
||||||
|
// When we authenticate with a proxy and we want to tunnel the request, the uri must match what we are sending in the CONNECT request's
|
||||||
|
// Host header.
|
||||||
|
string uri = isProxy ? request.CurrentUri.Host + ":" + request.CurrentUri.Port : request.CurrentUri.GetRequestPathAndQueryURL();
|
||||||
|
|
||||||
|
if (qop == null)
|
||||||
|
{
|
||||||
|
string HA2 = string.Concat(request.MethodType.ToString().ToUpper(), ":", request.CurrentUri.GetRequestPathAndQueryURL()).CalculateMD5Hash();
|
||||||
|
response = string.Format("{0}:{1}:{2}", HA1, Nonce, HA2).CalculateMD5Hash();
|
||||||
|
}
|
||||||
|
else if (qop.Contains("auth-int"))
|
||||||
|
{
|
||||||
|
qop = "auth-int";
|
||||||
|
|
||||||
|
byte[] entityBody = request.GetEntityBody();
|
||||||
|
|
||||||
|
if (entityBody == null)
|
||||||
|
entityBody = VariableSizedBufferPool.NoData; //string.Empty.GetASCIIBytes();
|
||||||
|
|
||||||
|
string HA2 = string.Format("{0}:{1}:{2}", method, uri, entityBody.CalculateMD5Hash()).CalculateMD5Hash();
|
||||||
|
|
||||||
|
response = string.Format("{0}:{1}:{2}:{3}:{4}:{5}", HA1, Nonce, ncvalue, cnonce, qop, HA2).CalculateMD5Hash();
|
||||||
|
}
|
||||||
|
else if (qop.Contains("auth"))
|
||||||
|
{
|
||||||
|
qop = "auth";
|
||||||
|
string HA2 = string.Concat(method, ":", uri).CalculateMD5Hash();
|
||||||
|
|
||||||
|
response = string.Format("{0}:{1}:{2}:{3}:{4}:{5}", HA1, Nonce, ncvalue, cnonce, qop, HA2).CalculateMD5Hash();
|
||||||
|
}
|
||||||
|
else //throw new NotSupportedException("Unrecognized Quality of Protection value found: " + this.QualityOfProtections);
|
||||||
|
return string.Empty;
|
||||||
|
|
||||||
|
string result = string.Format("Digest username=\"{0}\", realm=\"{1}\", nonce=\"{2}\", uri=\"{3}\", cnonce=\"{4}\", response=\"{5}\"",
|
||||||
|
credentials.UserName, Realm, Nonce, uri, cnonce, response);
|
||||||
|
|
||||||
|
if (qop != null)
|
||||||
|
result += String.Concat(", qop=\"", qop, "\", nc=", ncvalue);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(Opaque))
|
||||||
|
result = String.Concat(result, ", opaque=\"", Opaque, "\"");
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}// end of case "digest":
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsUriProtected(Uri uri)
|
||||||
|
{
|
||||||
|
// http://tools.ietf.org/html/rfc2617#section-3.2.1
|
||||||
|
// An absoluteURI in this list may refer to
|
||||||
|
// a different server than the one being accessed. The client can use
|
||||||
|
// this list to determine the set of URIs for which the same
|
||||||
|
// authentication information may be sent: any URI that has a URI in
|
||||||
|
// this list as a prefix (after both have been made absolute) may be
|
||||||
|
// assumed to be in the same protection space. If this directive is
|
||||||
|
// omitted or its value is empty, the client should assume that the
|
||||||
|
// protection space consists of all URIs on the responding server.
|
||||||
|
|
||||||
|
if (string.CompareOrdinal(uri.Host, this.Uri.Host) != 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
string uriStr = uri.ToString();
|
||||||
|
|
||||||
|
if (ProtectedUris != null && ProtectedUris.Count > 0)
|
||||||
|
for (int i = 0; i < ProtectedUris.Count; ++i)
|
||||||
|
if (uriStr.Contains(ProtectedUris[i]))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 424d976119ee3fc438fe98095013859f
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,73 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace BestHTTP.Authentication
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Stores and manages already received digest infos.
|
||||||
|
/// </summary>
|
||||||
|
public static class DigestStore
|
||||||
|
{
|
||||||
|
private static Dictionary<string, Digest> Digests = new Dictionary<string, Digest>();
|
||||||
|
|
||||||
|
private static object Locker = new object();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Array of algorithms that the plugin supports. It's in the order of priority(first has the highest priority).
|
||||||
|
/// </summary>
|
||||||
|
private static string[] SupportedAlgorithms = new string[] { "digest", "basic" };
|
||||||
|
|
||||||
|
public static Digest Get(Uri uri)
|
||||||
|
{
|
||||||
|
lock (Locker)
|
||||||
|
{
|
||||||
|
Digest digest = null;
|
||||||
|
if (Digests.TryGetValue(uri.Host, out digest))
|
||||||
|
if (!digest.IsUriProtected(uri))
|
||||||
|
return null;
|
||||||
|
return digest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// It will retrive or create a new Digest for the given Uri.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uri"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static Digest GetOrCreate(Uri uri)
|
||||||
|
{
|
||||||
|
lock (Locker)
|
||||||
|
{
|
||||||
|
Digest digest = null;
|
||||||
|
if (!Digests.TryGetValue(uri.Host, out digest))
|
||||||
|
Digests.Add(uri.Host, digest = new Digest(uri));
|
||||||
|
return digest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Remove(Uri uri)
|
||||||
|
{
|
||||||
|
lock(Locker)
|
||||||
|
Digests.Remove(uri.Host);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string FindBest(List<string> authHeaders)
|
||||||
|
{
|
||||||
|
if (authHeaders == null || authHeaders.Count == 0)
|
||||||
|
return string.Empty;
|
||||||
|
|
||||||
|
List<string> headers = new List<string>(authHeaders.Count);
|
||||||
|
for (int i = 0; i < authHeaders.Count; ++i)
|
||||||
|
headers.Add(authHeaders[i].ToLower());
|
||||||
|
|
||||||
|
for (int i = 0; i < SupportedAlgorithms.Length; ++i)
|
||||||
|
{
|
||||||
|
int idx = headers.FindIndex((header) => header.StartsWith(SupportedAlgorithms[i]));
|
||||||
|
if (idx != -1)
|
||||||
|
return authHeaders[idx];
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0f808b023553ee2419249f92eb8ac31f
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
7
JNFrame/Assets/Plugins/BestHTTP/BestHTTP/Caching.meta
Normal file
7
JNFrame/Assets/Plugins/BestHTTP/BestHTTP/Caching.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 26e64cd0d1567634fb40b1386ba0c48d
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,394 @@
|
|||||||
|
#if !BESTHTTP_DISABLE_CACHING
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace BestHTTP.Caching
|
||||||
|
{
|
||||||
|
using BestHTTP.Extensions;
|
||||||
|
using BestHTTP.PlatformSupport.FileSystem;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Holds all metadata that need for efficient caching, so we don't need to touch the disk to load headers.
|
||||||
|
/// </summary>
|
||||||
|
public class HTTPCacheFileInfo : IComparable<HTTPCacheFileInfo>
|
||||||
|
{
|
||||||
|
#region Properties
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The uri that this HTTPCacheFileInfo belongs to.
|
||||||
|
/// </summary>
|
||||||
|
internal Uri Uri { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The last access time to this cache entity. The date is in UTC.
|
||||||
|
/// </summary>
|
||||||
|
internal DateTime LastAccess { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The length of the cache entity's body.
|
||||||
|
/// </summary>
|
||||||
|
public int BodyLength { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ETag of the entity.
|
||||||
|
/// </summary>
|
||||||
|
private string ETag { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LastModified date of the entity.
|
||||||
|
/// </summary>
|
||||||
|
private string LastModified { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// When the cache will expire.
|
||||||
|
/// </summary>
|
||||||
|
private DateTime Expires { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The age that came with the response
|
||||||
|
/// </summary>
|
||||||
|
private long Age { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Maximum how long the entry should served from the cache without revalidation.
|
||||||
|
/// </summary>
|
||||||
|
private long MaxAge { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The Date that came with the response.
|
||||||
|
/// </summary>
|
||||||
|
private DateTime Date { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates whether the entity must be revalidated with the server or can be serverd directly from the cache without touching the server.
|
||||||
|
/// </summary>
|
||||||
|
private bool MustRevalidate { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The date and time when the HTTPResponse received.
|
||||||
|
/// </summary>
|
||||||
|
private DateTime Received { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Cached path.
|
||||||
|
/// </summary>
|
||||||
|
private string ConstructedPath { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This is the index of the entity. Filenames are generated from this value.
|
||||||
|
/// </summary>
|
||||||
|
internal UInt64 MappedNameIDX { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
|
internal HTTPCacheFileInfo(Uri uri)
|
||||||
|
:this(uri, DateTime.UtcNow, -1)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
internal HTTPCacheFileInfo(Uri uri, DateTime lastAcces, int bodyLength)
|
||||||
|
{
|
||||||
|
this.Uri = uri;
|
||||||
|
this.LastAccess = lastAcces;
|
||||||
|
this.BodyLength = bodyLength;
|
||||||
|
this.MaxAge = -1;
|
||||||
|
|
||||||
|
this.MappedNameIDX = HTTPCacheService.GetNameIdx();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal HTTPCacheFileInfo(Uri uri, System.IO.BinaryReader reader, int version)
|
||||||
|
{
|
||||||
|
this.Uri = uri;
|
||||||
|
this.LastAccess = DateTime.FromBinary(reader.ReadInt64());
|
||||||
|
this.BodyLength = reader.ReadInt32();
|
||||||
|
|
||||||
|
switch(version)
|
||||||
|
{
|
||||||
|
case 2:
|
||||||
|
this.MappedNameIDX = reader.ReadUInt64();
|
||||||
|
goto case 1;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
this.ETag = reader.ReadString();
|
||||||
|
this.LastModified = reader.ReadString();
|
||||||
|
this.Expires = DateTime.FromBinary(reader.ReadInt64());
|
||||||
|
this.Age = reader.ReadInt64();
|
||||||
|
this.MaxAge = reader.ReadInt64();
|
||||||
|
this.Date = DateTime.FromBinary(reader.ReadInt64());
|
||||||
|
this.MustRevalidate = reader.ReadBoolean();
|
||||||
|
this.Received = DateTime.FromBinary(reader.ReadInt64());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Helper Functions
|
||||||
|
|
||||||
|
internal void SaveTo(System.IO.BinaryWriter writer)
|
||||||
|
{
|
||||||
|
writer.Write(LastAccess.ToBinary());
|
||||||
|
writer.Write(BodyLength);
|
||||||
|
writer.Write(MappedNameIDX);
|
||||||
|
writer.Write(ETag);
|
||||||
|
writer.Write(LastModified);
|
||||||
|
writer.Write(Expires.ToBinary());
|
||||||
|
writer.Write(Age);
|
||||||
|
writer.Write(MaxAge);
|
||||||
|
writer.Write(Date.ToBinary());
|
||||||
|
writer.Write(MustRevalidate);
|
||||||
|
writer.Write(Received.ToBinary());
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetPath()
|
||||||
|
{
|
||||||
|
if (ConstructedPath != null)
|
||||||
|
return ConstructedPath;
|
||||||
|
|
||||||
|
return ConstructedPath = System.IO.Path.Combine(HTTPCacheService.CacheFolder, MappedNameIDX.ToString("X"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsExists()
|
||||||
|
{
|
||||||
|
if (!HTTPCacheService.IsSupported)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return HTTPManager.IOService.FileExists(GetPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void Delete()
|
||||||
|
{
|
||||||
|
if (!HTTPCacheService.IsSupported)
|
||||||
|
return;
|
||||||
|
|
||||||
|
string path = GetPath();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
HTTPManager.IOService.FileDelete(path);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{ }
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Reset()
|
||||||
|
{
|
||||||
|
// MappedNameIDX will remain the same. When we re-save an entity, it will not reset the MappedNameIDX.
|
||||||
|
this.BodyLength = -1;
|
||||||
|
this.ETag = string.Empty;
|
||||||
|
this.Expires = DateTime.FromBinary(0);
|
||||||
|
this.LastModified = string.Empty;
|
||||||
|
this.Age = 0;
|
||||||
|
this.MaxAge = -1;
|
||||||
|
this.Date = DateTime.FromBinary(0);
|
||||||
|
this.MustRevalidate = false;
|
||||||
|
this.Received = DateTime.FromBinary(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Caching
|
||||||
|
|
||||||
|
private void SetUpCachingValues(HTTPResponse response)
|
||||||
|
{
|
||||||
|
response.CacheFileInfo = this;
|
||||||
|
|
||||||
|
this.ETag = response.GetFirstHeaderValue("ETag").ToStrOrEmpty();
|
||||||
|
this.Expires = response.GetFirstHeaderValue("Expires").ToDateTime(DateTime.FromBinary(0));
|
||||||
|
this.LastModified = response.GetFirstHeaderValue("Last-Modified").ToStrOrEmpty();
|
||||||
|
|
||||||
|
this.Age = response.GetFirstHeaderValue("Age").ToInt64(0);
|
||||||
|
|
||||||
|
this.Date = response.GetFirstHeaderValue("Date").ToDateTime(DateTime.FromBinary(0));
|
||||||
|
|
||||||
|
string cacheControl = response.GetFirstHeaderValue("cache-control");
|
||||||
|
if (!string.IsNullOrEmpty(cacheControl))
|
||||||
|
{
|
||||||
|
string[] kvp = cacheControl.FindOption("max-age");
|
||||||
|
if (kvp != null)
|
||||||
|
{
|
||||||
|
// Some cache proxies will return float values
|
||||||
|
double maxAge;
|
||||||
|
if (double.TryParse(kvp[1], out maxAge))
|
||||||
|
this.MaxAge = (int)maxAge;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.MustRevalidate = cacheControl.ToLower().Contains("must-revalidate");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Received = DateTime.UtcNow;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal bool WillExpireInTheFuture()
|
||||||
|
{
|
||||||
|
if (!IsExists())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (MustRevalidate)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.2.4 :
|
||||||
|
// The max-age directive takes priority over Expires
|
||||||
|
if (MaxAge != -1)
|
||||||
|
{
|
||||||
|
// Age calculation:
|
||||||
|
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.2.3
|
||||||
|
|
||||||
|
long apparent_age = Math.Max(0, (long)(Received - Date).TotalSeconds);
|
||||||
|
long corrected_received_age = Math.Max(apparent_age, Age);
|
||||||
|
long resident_time = (long)(DateTime.UtcNow - Date).TotalSeconds;
|
||||||
|
long current_age = corrected_received_age + resident_time;
|
||||||
|
|
||||||
|
return current_age < MaxAge;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Expires > DateTime.UtcNow;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void SetUpRevalidationHeaders(HTTPRequest request)
|
||||||
|
{
|
||||||
|
if (!IsExists())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// -If an entity tag has been provided by the origin server, MUST use that entity tag in any cache-conditional request (using If-Match or If-None-Match).
|
||||||
|
// -If only a Last-Modified value has been provided by the origin server, SHOULD use that value in non-subrange cache-conditional requests (using If-Modified-Since).
|
||||||
|
// -If both an entity tag and a Last-Modified value have been provided by the origin server, SHOULD use both validators in cache-conditional requests. This allows both HTTP/1.0 and HTTP/1.1 caches to respond appropriately.
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(ETag))
|
||||||
|
request.SetHeader("If-None-Match", ETag);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(LastModified))
|
||||||
|
request.SetHeader("If-Modified-Since", LastModified);
|
||||||
|
}
|
||||||
|
|
||||||
|
public System.IO.Stream GetBodyStream(out int length)
|
||||||
|
{
|
||||||
|
if (!IsExists())
|
||||||
|
{
|
||||||
|
length = 0;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
length = BodyLength;
|
||||||
|
|
||||||
|
LastAccess = DateTime.UtcNow;
|
||||||
|
|
||||||
|
//FileStream stream = new FileStream(GetPath(), FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||||
|
Stream stream = HTTPManager.IOService.CreateFileStream(GetPath(), FileStreamModes.Open);
|
||||||
|
stream.Seek(-length, System.IO.SeekOrigin.End);
|
||||||
|
|
||||||
|
return stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal HTTPResponse ReadResponseTo(HTTPRequest request)
|
||||||
|
{
|
||||||
|
if (!IsExists())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
LastAccess = DateTime.UtcNow;
|
||||||
|
|
||||||
|
using (Stream stream = HTTPManager.IOService.CreateFileStream(GetPath(), FileStreamModes.Open)/*new FileStream(GetPath(), FileMode.Open, FileAccess.Read, FileShare.Read)*/)
|
||||||
|
{
|
||||||
|
var response = new HTTPResponse(request, stream, request.UseStreaming, true);
|
||||||
|
response.CacheFileInfo = this;
|
||||||
|
response.Receive(BodyLength);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void Store(HTTPResponse response)
|
||||||
|
{
|
||||||
|
if (!HTTPCacheService.IsSupported)
|
||||||
|
return;
|
||||||
|
|
||||||
|
string path = GetPath();
|
||||||
|
|
||||||
|
// Path name too long, we don't want to get exceptions
|
||||||
|
if (path.Length > HTTPManager.MaxPathLength)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (HTTPManager.IOService.FileExists(path))
|
||||||
|
Delete();
|
||||||
|
|
||||||
|
using (Stream writer = HTTPManager.IOService.CreateFileStream(GetPath(), FileStreamModes.Create) /*new FileStream(path, FileMode.Create)*/)
|
||||||
|
{
|
||||||
|
writer.WriteLine("HTTP/1.1 {0} {1}", response.StatusCode, response.Message);
|
||||||
|
foreach (var kvp in response.Headers)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < kvp.Value.Count; ++i)
|
||||||
|
writer.WriteLine("{0}: {1}", kvp.Key, kvp.Value[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
writer.WriteLine();
|
||||||
|
|
||||||
|
writer.Write(response.Data, 0, response.Data.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
BodyLength = response.Data.Length;
|
||||||
|
LastAccess = DateTime.UtcNow;
|
||||||
|
|
||||||
|
SetUpCachingValues(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal System.IO.Stream GetSaveStream(HTTPResponse response)
|
||||||
|
{
|
||||||
|
if (!HTTPCacheService.IsSupported)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
LastAccess = DateTime.UtcNow;
|
||||||
|
|
||||||
|
string path = GetPath();
|
||||||
|
|
||||||
|
if (HTTPManager.IOService.FileExists(path))
|
||||||
|
Delete();
|
||||||
|
|
||||||
|
// Path name too long, we don't want to get exceptions
|
||||||
|
if (path.Length > HTTPManager.MaxPathLength)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// First write out the headers
|
||||||
|
using (Stream writer = HTTPManager.IOService.CreateFileStream(GetPath(), FileStreamModes.Create) /*new FileStream(path, FileMode.Create)*/)
|
||||||
|
{
|
||||||
|
writer.WriteLine("HTTP/1.1 {0} {1}", response.StatusCode, response.Message);
|
||||||
|
foreach (var kvp in response.Headers)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < kvp.Value.Count; ++i)
|
||||||
|
writer.WriteLine("{0}: {1}", kvp.Key, kvp.Value[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
writer.WriteLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
// If caching is enabled and the response is from cache, and no content-length header set, then we set one to the response.
|
||||||
|
if (response.IsFromCache && !response.Headers.ContainsKey("content-length"))
|
||||||
|
response.Headers.Add("content-length", new List<string> { BodyLength.ToString() });
|
||||||
|
|
||||||
|
SetUpCachingValues(response);
|
||||||
|
|
||||||
|
// then create the stream with Append FileMode
|
||||||
|
return HTTPManager.IOService.CreateFileStream(GetPath(), FileStreamModes.Append); //new FileStream(GetPath(), FileMode.Append);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region IComparable<HTTPCacheFileInfo>
|
||||||
|
|
||||||
|
public int CompareTo(HTTPCacheFileInfo other)
|
||||||
|
{
|
||||||
|
return this.LastAccess.CompareTo(other.LastAccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1f50da5c22225384fbe271e0453fe545
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,44 @@
|
|||||||
|
#if !BESTHTTP_DISABLE_CACHING
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace BestHTTP.Caching
|
||||||
|
{
|
||||||
|
sealed class HTTPCacheFileLock
|
||||||
|
{
|
||||||
|
private static Dictionary<Uri, object> FileLocks = new Dictionary<Uri, object>();
|
||||||
|
private static object SyncRoot = new object();
|
||||||
|
|
||||||
|
internal static object Acquire(Uri uri)
|
||||||
|
{
|
||||||
|
lock (SyncRoot)
|
||||||
|
{
|
||||||
|
object fileLock;
|
||||||
|
if (!FileLocks.TryGetValue(uri, out fileLock))
|
||||||
|
FileLocks.Add(uri, fileLock = new object());
|
||||||
|
|
||||||
|
return fileLock;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void Remove(Uri uri)
|
||||||
|
{
|
||||||
|
lock (SyncRoot)
|
||||||
|
{
|
||||||
|
if (FileLocks.ContainsKey(uri))
|
||||||
|
FileLocks.Remove(uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void Clear()
|
||||||
|
{
|
||||||
|
lock (SyncRoot)
|
||||||
|
{
|
||||||
|
FileLocks.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7b141dab023cd9d438e0585b93cf2826
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,27 @@
|
|||||||
|
#if !BESTHTTP_DISABLE_CACHING
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace BestHTTP.Caching
|
||||||
|
{
|
||||||
|
public sealed class HTTPCacheMaintananceParams
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Delete cache entries that accessed older then this value. If TimeSpan.FromSeconds(0) is used then all cache entries will be deleted. With TimeSpan.FromDays(2) entries that older then two days will be deleted.
|
||||||
|
/// </summary>
|
||||||
|
public TimeSpan DeleteOlder { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If the cache is larger then the MaxCacheSize after the first maintanance step, then the maintanance job will forcedelete cache entries starting with the oldest last accessed one.
|
||||||
|
/// </summary>
|
||||||
|
public ulong MaxCacheSize { get; private set; }
|
||||||
|
|
||||||
|
public HTTPCacheMaintananceParams(TimeSpan deleteOlder, ulong maxCacheSize)
|
||||||
|
{
|
||||||
|
this.DeleteOlder = deleteOlder;
|
||||||
|
this.MaxCacheSize = maxCacheSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3ce5552e539e38647a8f37ab36951bf7
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,716 @@
|
|||||||
|
#if !BESTHTTP_DISABLE_CACHING
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Version 1: Initial release
|
||||||
|
// Version 2: Filenames are generated from an index.
|
||||||
|
//
|
||||||
|
|
||||||
|
namespace BestHTTP.Caching
|
||||||
|
{
|
||||||
|
using BestHTTP.Extensions;
|
||||||
|
using BestHTTP.PlatformSupport.FileSystem;
|
||||||
|
|
||||||
|
public sealed class UriComparer : IEqualityComparer<Uri>
|
||||||
|
{
|
||||||
|
public bool Equals(Uri x, Uri y)
|
||||||
|
{
|
||||||
|
return Uri.Compare(x, y, UriComponents.HttpRequestUrl, UriFormat.SafeUnescaped, StringComparison.Ordinal) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetHashCode(Uri uri)
|
||||||
|
{
|
||||||
|
return uri.ToString().GetHashCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static class HTTPCacheService
|
||||||
|
{
|
||||||
|
#region Properties & Fields
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Library file-format versioning support
|
||||||
|
/// </summary>
|
||||||
|
private const int LibraryVersion = 2;
|
||||||
|
|
||||||
|
public static bool IsSupported
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (IsSupportCheckDone)
|
||||||
|
return isSupported;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// If DirectoryExists throws an exception we will set IsSupprted to false
|
||||||
|
|
||||||
|
HTTPManager.IOService.DirectoryExists(HTTPManager.GetRootCacheFolder());
|
||||||
|
isSupported = true;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
isSupported = false;
|
||||||
|
|
||||||
|
HTTPManager.Logger.Warning("HTTPCacheService", "Cache Service Disabled!");
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
IsSupportCheckDone = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return isSupported;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static bool isSupported;
|
||||||
|
private static bool IsSupportCheckDone;
|
||||||
|
|
||||||
|
private static Dictionary<Uri, HTTPCacheFileInfo> library;
|
||||||
|
private static Dictionary<Uri, HTTPCacheFileInfo> Library { get { LoadLibrary(); return library; } }
|
||||||
|
|
||||||
|
private static Dictionary<UInt64, HTTPCacheFileInfo> UsedIndexes = new Dictionary<ulong, HTTPCacheFileInfo>();
|
||||||
|
|
||||||
|
internal static string CacheFolder { get; private set; }
|
||||||
|
private static string LibraryPath { get; set; }
|
||||||
|
|
||||||
|
private static bool InClearThread;
|
||||||
|
private static bool InMaintainenceThread;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stores the index of the next stored entity. The entity's file name is generated from this index.
|
||||||
|
/// </summary>
|
||||||
|
private static UInt64 NextNameIDX;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
static HTTPCacheService()
|
||||||
|
{
|
||||||
|
NextNameIDX = 0x0001;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Common Functions
|
||||||
|
|
||||||
|
internal static void CheckSetup()
|
||||||
|
{
|
||||||
|
if (!HTTPCacheService.IsSupported)
|
||||||
|
return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SetupCacheFolder();
|
||||||
|
LoadLibrary();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void SetupCacheFolder()
|
||||||
|
{
|
||||||
|
if (!HTTPCacheService.IsSupported)
|
||||||
|
return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(CacheFolder) || string.IsNullOrEmpty(LibraryPath))
|
||||||
|
{
|
||||||
|
CacheFolder = System.IO.Path.Combine(HTTPManager.GetRootCacheFolder(), "HTTPCache");
|
||||||
|
if (!HTTPManager.IOService.DirectoryExists(CacheFolder))
|
||||||
|
HTTPManager.IOService.DirectoryCreate(CacheFolder);
|
||||||
|
|
||||||
|
LibraryPath = System.IO.Path.Combine(HTTPManager.GetRootCacheFolder(), "Library");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
isSupported = false;
|
||||||
|
|
||||||
|
HTTPManager.Logger.Warning("HTTPCacheService", "Cache Service Disabled!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static UInt64 GetNameIdx()
|
||||||
|
{
|
||||||
|
lock(Library)
|
||||||
|
{
|
||||||
|
UInt64 result = NextNameIDX;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
NextNameIDX = ++NextNameIDX % UInt64.MaxValue;
|
||||||
|
} while (UsedIndexes.ContainsKey(NextNameIDX));
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static bool HasEntity(Uri uri)
|
||||||
|
{
|
||||||
|
if (!IsSupported)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
lock (Library)
|
||||||
|
return Library.ContainsKey(uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool DeleteEntity(Uri uri, bool removeFromLibrary = true)
|
||||||
|
{
|
||||||
|
if (!IsSupported)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
object uriLocker = HTTPCacheFileLock.Acquire(uri);
|
||||||
|
|
||||||
|
// Just use lock now: http://forum.unity3d.com/threads/4-6-ios-64-bit-beta.290551/page-6#post-1937033
|
||||||
|
|
||||||
|
// To avoid a dead-lock we try acquire the lock on this uri only for a little time.
|
||||||
|
// If we can't acquire it, its better to just return without risking a deadlock.
|
||||||
|
//if (Monitor.TryEnter(uriLocker, TimeSpan.FromSeconds(0.5f)))
|
||||||
|
lock(uriLocker)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lock (Library)
|
||||||
|
{
|
||||||
|
HTTPCacheFileInfo info;
|
||||||
|
bool inStats = Library.TryGetValue(uri, out info);
|
||||||
|
if (inStats)
|
||||||
|
info.Delete();
|
||||||
|
|
||||||
|
if (inStats && removeFromLibrary)
|
||||||
|
{
|
||||||
|
Library.Remove(uri);
|
||||||
|
UsedIndexes.Remove(info.MappedNameIDX);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
//Monitor.Exit(uriLocker);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static bool IsCachedEntityExpiresInTheFuture(HTTPRequest request)
|
||||||
|
{
|
||||||
|
if (!IsSupported)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
HTTPCacheFileInfo info;
|
||||||
|
lock (Library)
|
||||||
|
if (Library.TryGetValue(request.CurrentUri, out info))
|
||||||
|
return info.WillExpireInTheFuture();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Utility function to set the cache control headers according to the spec.: http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.3.4
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
internal static void SetHeaders(HTTPRequest request)
|
||||||
|
{
|
||||||
|
if (!IsSupported)
|
||||||
|
return;
|
||||||
|
|
||||||
|
request.RemoveHeader("If-None-Match");
|
||||||
|
request.RemoveHeader("If-Modified-Since");
|
||||||
|
|
||||||
|
HTTPCacheFileInfo info;
|
||||||
|
lock (Library)
|
||||||
|
if (Library.TryGetValue(request.CurrentUri, out info))
|
||||||
|
info.SetUpRevalidationHeaders(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Get Functions
|
||||||
|
|
||||||
|
internal static HTTPCacheFileInfo GetEntity(Uri uri)
|
||||||
|
{
|
||||||
|
if (!IsSupported)
|
||||||
|
return null;
|
||||||
|
HTTPCacheFileInfo info = null;
|
||||||
|
lock (Library)
|
||||||
|
Library.TryGetValue(uri, out info);
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static HTTPResponse GetFullResponse(HTTPRequest request)
|
||||||
|
{
|
||||||
|
if (!IsSupported)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
HTTPCacheFileInfo info;
|
||||||
|
lock (Library)
|
||||||
|
if (Library.TryGetValue(request.CurrentUri, out info))
|
||||||
|
return info.ReadResponseTo(request);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Storing
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if the given response can be cached. http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.4
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Returns true if cacheable, false otherwise.</returns>
|
||||||
|
internal static bool IsCacheble(Uri uri, HTTPMethods method, HTTPResponse response)
|
||||||
|
{
|
||||||
|
if (!IsSupported)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (method != HTTPMethods.Get)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (response == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// https://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.12 - Cache Replacement
|
||||||
|
// It MAY insert it into cache storage and MAY, if it meets all other requirements, use it to respond to any future requests that would previously have caused the old response to be returned.
|
||||||
|
//if (response.StatusCode == 304)
|
||||||
|
// return false;
|
||||||
|
|
||||||
|
if (response.StatusCode < 200 || response.StatusCode >= 400)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
//http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.2
|
||||||
|
var cacheControls = response.GetHeaderValues("cache-control");
|
||||||
|
if (cacheControls != null)
|
||||||
|
{
|
||||||
|
if (cacheControls.Exists(headerValue => {
|
||||||
|
string value = headerValue.ToLower();
|
||||||
|
return value.Contains("no-store") || value.Contains("no-cache");
|
||||||
|
}))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var pragmas = response.GetHeaderValues("pragma");
|
||||||
|
if (pragmas != null)
|
||||||
|
{
|
||||||
|
if (pragmas.Exists(headerValue => {
|
||||||
|
string value = headerValue.ToLower();
|
||||||
|
return value.Contains("no-store") || value.Contains("no-cache");
|
||||||
|
}))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Responses with byte ranges not supported yet.
|
||||||
|
var byteRanges = response.GetHeaderValues("content-range");
|
||||||
|
if (byteRanges != null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static HTTPCacheFileInfo Store(Uri uri, HTTPMethods method, HTTPResponse response)
|
||||||
|
{
|
||||||
|
if (response == null || response.Data == null || response.Data.Length == 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if (!IsSupported)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
HTTPCacheFileInfo info = null;
|
||||||
|
|
||||||
|
lock (Library)
|
||||||
|
{
|
||||||
|
if (!Library.TryGetValue(uri, out info))
|
||||||
|
{
|
||||||
|
Library.Add(uri, info = new HTTPCacheFileInfo(uri));
|
||||||
|
UsedIndexes.Add(info.MappedNameIDX, info);
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
info.Store(response);
|
||||||
|
if (HTTPManager.Logger.Level == Logger.Loglevels.All)
|
||||||
|
HTTPManager.Logger.Verbose("HTTPCacheService", string.Format("{0} - Saved to cache", uri.ToString()));
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// If something happens while we write out the response, than we will delete it because it might be in an invalid state.
|
||||||
|
DeleteEntity(uri);
|
||||||
|
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static System.IO.Stream PrepareStreamed(Uri uri, HTTPResponse response)
|
||||||
|
{
|
||||||
|
if (!IsSupported)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
HTTPCacheFileInfo info;
|
||||||
|
|
||||||
|
lock (Library)
|
||||||
|
{
|
||||||
|
if (!Library.TryGetValue(uri, out info))
|
||||||
|
{
|
||||||
|
Library.Add(uri, info = new HTTPCacheFileInfo(uri));
|
||||||
|
UsedIndexes.Add(info.MappedNameIDX, info);
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return info.GetSaveStream(response);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// If something happens while we write out the response, than we will delete it because it might be in an invalid state.
|
||||||
|
DeleteEntity(uri);
|
||||||
|
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Public Maintenance Functions
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes all cache entity. Non blocking.
|
||||||
|
/// <remarks>Call it only if there no requests currently processed, because cache entries can be deleted while a server sends back a 304 result, so there will be no data to read from the cache!</remarks>
|
||||||
|
/// </summary>
|
||||||
|
public static void BeginClear()
|
||||||
|
{
|
||||||
|
if (!IsSupported)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (InClearThread)
|
||||||
|
return;
|
||||||
|
InClearThread = true;
|
||||||
|
|
||||||
|
SetupCacheFolder();
|
||||||
|
|
||||||
|
#if !NETFX_CORE
|
||||||
|
ThreadPool.QueueUserWorkItem(new WaitCallback((param) => ClearImpl(param)));
|
||||||
|
//new Thread(ClearImpl).Start();
|
||||||
|
#else
|
||||||
|
#pragma warning disable 4014
|
||||||
|
Windows.System.Threading.ThreadPool.RunAsync(ClearImpl);
|
||||||
|
#pragma warning restore 4014
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ClearImpl(object param)
|
||||||
|
{
|
||||||
|
if (!IsSupported)
|
||||||
|
return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// GetFiles will return a string array that contains the files in the folder with the full path
|
||||||
|
string[] cacheEntries = HTTPManager.IOService.GetFiles(CacheFolder);
|
||||||
|
|
||||||
|
for (int i = 0; i < cacheEntries.Length; ++i)
|
||||||
|
{
|
||||||
|
// We need a try-catch block because between the Directory.GetFiles call and the File.Delete calls a maintenance job, or other file operations can delete any file from the cache folder.
|
||||||
|
// So while there might be some problem with any file, we don't want to abort the whole for loop
|
||||||
|
try
|
||||||
|
{
|
||||||
|
HTTPManager.IOService.FileDelete(cacheEntries[i]);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
UsedIndexes.Clear();
|
||||||
|
library.Clear();
|
||||||
|
NextNameIDX = 0x0001;
|
||||||
|
|
||||||
|
SaveLibrary();
|
||||||
|
InClearThread = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes all expired cache entity.
|
||||||
|
/// <remarks>Call it only if there no requests currently processed, because cache entries can be deleted while a server sends back a 304 result, so there will be no data to read from the cache!</remarks>
|
||||||
|
/// </summary>
|
||||||
|
public static void BeginMaintainence(HTTPCacheMaintananceParams maintananceParam)
|
||||||
|
{
|
||||||
|
if (maintananceParam == null)
|
||||||
|
throw new ArgumentNullException("maintananceParams == null");
|
||||||
|
|
||||||
|
if (!HTTPCacheService.IsSupported)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (InMaintainenceThread)
|
||||||
|
return;
|
||||||
|
|
||||||
|
InMaintainenceThread = true;
|
||||||
|
|
||||||
|
SetupCacheFolder();
|
||||||
|
|
||||||
|
#if !NETFX_CORE
|
||||||
|
ThreadPool.QueueUserWorkItem(new WaitCallback((param) =>
|
||||||
|
//new Thread((param) =>
|
||||||
|
#else
|
||||||
|
#pragma warning disable 4014
|
||||||
|
Windows.System.Threading.ThreadPool.RunAsync((param) =>
|
||||||
|
#pragma warning restore 4014
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lock (Library)
|
||||||
|
{
|
||||||
|
// Delete cache entries older than the given time.
|
||||||
|
DateTime deleteOlderAccessed = DateTime.UtcNow - maintananceParam.DeleteOlder;
|
||||||
|
List<HTTPCacheFileInfo> removedEntities = new List<HTTPCacheFileInfo>();
|
||||||
|
foreach (var kvp in Library)
|
||||||
|
if (kvp.Value.LastAccess < deleteOlderAccessed)
|
||||||
|
{
|
||||||
|
if (DeleteEntity(kvp.Key, false))
|
||||||
|
removedEntities.Add(kvp.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < removedEntities.Count; ++i)
|
||||||
|
{
|
||||||
|
Library.Remove(removedEntities[i].Uri);
|
||||||
|
UsedIndexes.Remove(removedEntities[i].MappedNameIDX);
|
||||||
|
}
|
||||||
|
removedEntities.Clear();
|
||||||
|
|
||||||
|
ulong cacheSize = GetCacheSize();
|
||||||
|
|
||||||
|
// This step will delete all entries starting with the oldest LastAccess property while the cache size greater then the MaxCacheSize in the given param.
|
||||||
|
if (cacheSize > maintananceParam.MaxCacheSize)
|
||||||
|
{
|
||||||
|
List<HTTPCacheFileInfo> fileInfos = new List<HTTPCacheFileInfo>(library.Count);
|
||||||
|
|
||||||
|
foreach(var kvp in library)
|
||||||
|
fileInfos.Add(kvp.Value);
|
||||||
|
|
||||||
|
fileInfos.Sort();
|
||||||
|
|
||||||
|
int idx = 0;
|
||||||
|
while (cacheSize >= maintananceParam.MaxCacheSize && idx < fileInfos.Count)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var fi = fileInfos[idx];
|
||||||
|
ulong length = (ulong)fi.BodyLength;
|
||||||
|
|
||||||
|
DeleteEntity(fi.Uri);
|
||||||
|
|
||||||
|
cacheSize -= length;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
++idx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
SaveLibrary();
|
||||||
|
InMaintainenceThread = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#if !NETFX_CORE
|
||||||
|
));
|
||||||
|
#else
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int GetCacheEntityCount()
|
||||||
|
{
|
||||||
|
if (!HTTPCacheService.IsSupported)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
CheckSetup();
|
||||||
|
|
||||||
|
lock(Library)
|
||||||
|
return Library.Count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ulong GetCacheSize()
|
||||||
|
{
|
||||||
|
ulong size = 0;
|
||||||
|
|
||||||
|
if (!IsSupported)
|
||||||
|
return size;
|
||||||
|
|
||||||
|
CheckSetup();
|
||||||
|
|
||||||
|
lock (Library)
|
||||||
|
foreach (var kvp in Library)
|
||||||
|
if (kvp.Value.BodyLength > 0)
|
||||||
|
size += (ulong)kvp.Value.BodyLength;
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Cache Library Management
|
||||||
|
|
||||||
|
private static void LoadLibrary()
|
||||||
|
{
|
||||||
|
// Already loaded?
|
||||||
|
if (library != null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!IsSupported)
|
||||||
|
return;
|
||||||
|
|
||||||
|
library = new Dictionary<Uri, HTTPCacheFileInfo>(new UriComparer());
|
||||||
|
|
||||||
|
if (!HTTPManager.IOService.FileExists(LibraryPath))
|
||||||
|
{
|
||||||
|
DeleteUnusedFiles();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int version;
|
||||||
|
|
||||||
|
lock (library)
|
||||||
|
{
|
||||||
|
using (var fs = HTTPManager.IOService.CreateFileStream(LibraryPath, FileStreamModes.Open))
|
||||||
|
using (var br = new System.IO.BinaryReader(fs))
|
||||||
|
{
|
||||||
|
version = br.ReadInt32();
|
||||||
|
|
||||||
|
if (version > 1)
|
||||||
|
NextNameIDX = br.ReadUInt64();
|
||||||
|
|
||||||
|
int statCount = br.ReadInt32();
|
||||||
|
|
||||||
|
for (int i = 0; i < statCount; ++i)
|
||||||
|
{
|
||||||
|
Uri uri = new Uri(br.ReadString());
|
||||||
|
|
||||||
|
var entity = new HTTPCacheFileInfo(uri, br, version);
|
||||||
|
if (entity.IsExists())
|
||||||
|
{
|
||||||
|
library.Add(uri, entity);
|
||||||
|
|
||||||
|
if (version > 1)
|
||||||
|
UsedIndexes.Add(entity.MappedNameIDX, entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (version == 1)
|
||||||
|
BeginClear();
|
||||||
|
else
|
||||||
|
DeleteUnusedFiles();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void SaveLibrary()
|
||||||
|
{
|
||||||
|
if (library == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!IsSupported)
|
||||||
|
return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lock (Library)
|
||||||
|
{
|
||||||
|
using (var fs = HTTPManager.IOService.CreateFileStream(LibraryPath, FileStreamModes.Create))
|
||||||
|
using (var bw = new System.IO.BinaryWriter(fs))
|
||||||
|
{
|
||||||
|
bw.Write(LibraryVersion);
|
||||||
|
bw.Write(NextNameIDX);
|
||||||
|
|
||||||
|
bw.Write(Library.Count);
|
||||||
|
foreach (var kvp in Library)
|
||||||
|
{
|
||||||
|
bw.Write(kvp.Key.ToString());
|
||||||
|
|
||||||
|
kvp.Value.SaveTo(bw);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
internal static void SetBodyLength(Uri uri, int bodyLength)
|
||||||
|
{
|
||||||
|
if (!IsSupported)
|
||||||
|
return;
|
||||||
|
|
||||||
|
lock (Library)
|
||||||
|
{
|
||||||
|
HTTPCacheFileInfo fileInfo;
|
||||||
|
if (Library.TryGetValue(uri, out fileInfo))
|
||||||
|
fileInfo.BodyLength = bodyLength;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Library.Add(uri, fileInfo = new HTTPCacheFileInfo(uri, DateTime.UtcNow, bodyLength));
|
||||||
|
UsedIndexes.Add(fileInfo.MappedNameIDX, fileInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes all files from the cache folder that isn't in the Library.
|
||||||
|
/// </summary>
|
||||||
|
private static void DeleteUnusedFiles()
|
||||||
|
{
|
||||||
|
if (!IsSupported)
|
||||||
|
return;
|
||||||
|
|
||||||
|
CheckSetup();
|
||||||
|
|
||||||
|
// GetFiles will return a string array that contains the files in the folder with the full path
|
||||||
|
string[] cacheEntries = HTTPManager.IOService.GetFiles(CacheFolder);
|
||||||
|
|
||||||
|
for (int i = 0; i < cacheEntries.Length; ++i)
|
||||||
|
{
|
||||||
|
// We need a try-catch block because between the Directory.GetFiles call and the File.Delete calls a maintenance job, or other file operations can delete any file from the cache folder.
|
||||||
|
// So while there might be some problem with any file, we don't want to abort the whole for loop
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string filename = System.IO.Path.GetFileName(cacheEntries[i]);
|
||||||
|
UInt64 idx = 0;
|
||||||
|
bool deleteFile = false;
|
||||||
|
if (UInt64.TryParse(filename, System.Globalization.NumberStyles.AllowHexSpecifier, null, out idx))
|
||||||
|
lock (Library)
|
||||||
|
deleteFile = !UsedIndexes.ContainsKey(idx);
|
||||||
|
else
|
||||||
|
deleteFile = true;
|
||||||
|
|
||||||
|
if (deleteFile)
|
||||||
|
HTTPManager.IOService.FileDelete(cacheEntries[i]);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d29e8551599393f4193bc4daa6968607
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 65fae491919869042be9bb2f969bf050
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,226 @@
|
|||||||
|
using System;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
#if NETFX_CORE
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
//Disable CD4014: Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.
|
||||||
|
#pragma warning disable 4014
|
||||||
|
|
||||||
|
//Disable warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
|
||||||
|
#pragma warning disable 1998
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace BestHTTP
|
||||||
|
{
|
||||||
|
internal delegate void HTTPConnectionRecycledDelegate(ConnectionBase conn);
|
||||||
|
|
||||||
|
internal abstract class ConnectionBase : IDisposable
|
||||||
|
{
|
||||||
|
#region Public Properties
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The address of the server that this connection is bound to.
|
||||||
|
/// </summary>
|
||||||
|
public string ServerAddress { get; protected set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The state of this connection.
|
||||||
|
/// </summary>
|
||||||
|
public HTTPConnectionStates State { get; protected set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// It's true if this connection is available to process a HTTPRequest.
|
||||||
|
/// </summary>
|
||||||
|
public bool IsFree { get { return State == HTTPConnectionStates.Initial || State == HTTPConnectionStates.Free; } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if it's an active connection.
|
||||||
|
/// </summary>
|
||||||
|
public bool IsActive { get { return State > HTTPConnectionStates.Initial && State < HTTPConnectionStates.Free; } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If the State is HTTPConnectionStates.Processing, then it holds a HTTPRequest instance. Otherwise it's null.
|
||||||
|
/// </summary>
|
||||||
|
public HTTPRequest CurrentRequest { get; protected set; }
|
||||||
|
|
||||||
|
public virtual bool IsRemovable { get { return IsFree && (DateTime.UtcNow - LastProcessTime) > HTTPManager.MaxConnectionIdleTime; } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// When we start to process the current request. It's set after the connection is established.
|
||||||
|
/// </summary>
|
||||||
|
public DateTime StartTime { get; protected set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// When this connection timed out.
|
||||||
|
/// </summary>
|
||||||
|
public DateTime TimedOutStart { get; protected set; }
|
||||||
|
|
||||||
|
#if !BESTHTTP_DISABLE_PROXY
|
||||||
|
public bool HasProxy { get { return this.CurrentRequest != null && this.CurrentRequest.Proxy != null; } }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public Uri LastProcessedUri { get; protected set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Protected Fields
|
||||||
|
|
||||||
|
protected DateTime LastProcessTime;
|
||||||
|
protected HTTPConnectionRecycledDelegate OnConnectionRecycled = null;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Privates
|
||||||
|
|
||||||
|
private bool IsThreaded;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public ConnectionBase(string serverAddress)
|
||||||
|
:this(serverAddress, true)
|
||||||
|
{}
|
||||||
|
|
||||||
|
public ConnectionBase(string serverAddress, bool threaded)
|
||||||
|
{
|
||||||
|
this.ServerAddress = serverAddress;
|
||||||
|
this.State = HTTPConnectionStates.Initial;
|
||||||
|
this.LastProcessTime = DateTime.UtcNow;
|
||||||
|
this.IsThreaded = threaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal abstract void Abort(HTTPConnectionStates hTTPConnectionStates);
|
||||||
|
|
||||||
|
internal void Process(HTTPRequest request)
|
||||||
|
{
|
||||||
|
if (State == HTTPConnectionStates.Processing)
|
||||||
|
throw new Exception("Connection already processing a request!");
|
||||||
|
|
||||||
|
StartTime = DateTime.MaxValue;
|
||||||
|
State = HTTPConnectionStates.Processing;
|
||||||
|
|
||||||
|
CurrentRequest = request;
|
||||||
|
|
||||||
|
if (IsThreaded)
|
||||||
|
{
|
||||||
|
#if NETFX_CORE
|
||||||
|
#pragma warning disable 4014
|
||||||
|
Windows.System.Threading.ThreadPool.RunAsync(ThreadFunc);
|
||||||
|
#pragma warning restore 4014
|
||||||
|
#else
|
||||||
|
ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadFunc));
|
||||||
|
//new Thread(ThreadFunc)
|
||||||
|
// .Start();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ThreadFunc(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual
|
||||||
|
#if NETFX_CORE
|
||||||
|
async
|
||||||
|
#endif
|
||||||
|
void ThreadFunc(object param)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void HandleProgressCallback()
|
||||||
|
{
|
||||||
|
if (CurrentRequest.OnProgress != null && CurrentRequest.DownloadProgressChanged)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
CurrentRequest.OnProgress(CurrentRequest, CurrentRequest.Downloaded, CurrentRequest.DownloadLength);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
HTTPManager.Logger.Exception("ConnectionBase", "HandleProgressCallback - OnProgress", ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
CurrentRequest.DownloadProgressChanged = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CurrentRequest.OnUploadProgress != null && CurrentRequest.UploadProgressChanged)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
CurrentRequest.OnUploadProgress(CurrentRequest, CurrentRequest.Uploaded, CurrentRequest.UploadLength);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
HTTPManager.Logger.Exception("ConnectionBase", "HandleProgressCallback - OnUploadProgress", ex);
|
||||||
|
}
|
||||||
|
CurrentRequest.UploadProgressChanged = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void HandleCallback()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
HandleProgressCallback();
|
||||||
|
|
||||||
|
if (State == HTTPConnectionStates.Upgraded)
|
||||||
|
{
|
||||||
|
if (CurrentRequest != null && CurrentRequest.Response != null && CurrentRequest.Response.IsUpgraded)
|
||||||
|
CurrentRequest.UpgradeCallback();
|
||||||
|
State = HTTPConnectionStates.WaitForProtocolShutdown;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
CurrentRequest.CallCallback();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
HTTPManager.Logger.Exception("ConnectionBase", "HandleCallback", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void Recycle(HTTPConnectionRecycledDelegate onConnectionRecycled)
|
||||||
|
{
|
||||||
|
OnConnectionRecycled = onConnectionRecycled;
|
||||||
|
if (!(State > HTTPConnectionStates.Initial && State < HTTPConnectionStates.WaitForProtocolShutdown) || State == HTTPConnectionStates.Redirected)
|
||||||
|
RecycleNow();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void RecycleNow()
|
||||||
|
{
|
||||||
|
if (State == HTTPConnectionStates.TimedOut ||
|
||||||
|
State == HTTPConnectionStates.Closed)
|
||||||
|
LastProcessTime = DateTime.MinValue;
|
||||||
|
|
||||||
|
State = HTTPConnectionStates.Free;
|
||||||
|
if (CurrentRequest != null)
|
||||||
|
CurrentRequest.Dispose();
|
||||||
|
CurrentRequest = null;
|
||||||
|
|
||||||
|
if (OnConnectionRecycled != null)
|
||||||
|
{
|
||||||
|
OnConnectionRecycled(this);
|
||||||
|
OnConnectionRecycled = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Dispose Pattern
|
||||||
|
|
||||||
|
protected bool IsDisposed { get; private set; }
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose(true);
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
IsDisposed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
~ConnectionBase()
|
||||||
|
{
|
||||||
|
Dispose(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f59e4337e77f0be4d8f6649beaca8362
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,300 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
using BestHTTP.Extensions;
|
||||||
|
using BestHTTP.PlatformSupport.FileSystem;
|
||||||
|
|
||||||
|
namespace BestHTTP
|
||||||
|
{
|
||||||
|
public sealed class StreamList : System.IO.Stream
|
||||||
|
{
|
||||||
|
private System.IO.Stream[] Streams;
|
||||||
|
private int CurrentIdx;
|
||||||
|
|
||||||
|
public StreamList(params System.IO.Stream[] streams)
|
||||||
|
{
|
||||||
|
this.Streams = streams;
|
||||||
|
this.CurrentIdx = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool CanRead
|
||||||
|
{
|
||||||
|
get {
|
||||||
|
if (CurrentIdx >= Streams.Length)
|
||||||
|
return false;
|
||||||
|
return Streams[CurrentIdx].CanRead;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool CanSeek { get { return false; } }
|
||||||
|
|
||||||
|
public override bool CanWrite
|
||||||
|
{
|
||||||
|
get {
|
||||||
|
if (CurrentIdx >= Streams.Length)
|
||||||
|
return false;
|
||||||
|
return Streams[CurrentIdx].CanWrite;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Flush()
|
||||||
|
{
|
||||||
|
if (CurrentIdx >= Streams.Length)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// We have to call the flush to all previous streams, as we may advanced the CurrentIdx
|
||||||
|
for (int i = 0; i <= CurrentIdx; ++i)
|
||||||
|
Streams[i].Flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override long Length
|
||||||
|
{
|
||||||
|
get {
|
||||||
|
if (CurrentIdx >= Streams.Length)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
long length = 0;
|
||||||
|
for (int i = 0; i < Streams.Length; ++i)
|
||||||
|
length += Streams[i].Length;
|
||||||
|
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int Read(byte[] buffer, int offset, int count)
|
||||||
|
{
|
||||||
|
if (CurrentIdx >= Streams.Length)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
int readCount = Streams[CurrentIdx].Read(buffer, offset, count);
|
||||||
|
|
||||||
|
while (readCount < count && CurrentIdx++ < Streams.Length)
|
||||||
|
{
|
||||||
|
readCount += Streams[CurrentIdx].Read(buffer, offset + readCount, count - readCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
return readCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Write(byte[] buffer, int offset, int count)
|
||||||
|
{
|
||||||
|
if (CurrentIdx >= Streams.Length)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Streams[CurrentIdx].Write(buffer, offset, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Write(string str)
|
||||||
|
{
|
||||||
|
byte[] bytes = str.GetASCIIBytes();
|
||||||
|
|
||||||
|
this.Write(bytes, 0, bytes.Length);
|
||||||
|
VariableSizedBufferPool.Release(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < Streams.Length; ++i)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Streams[i].Dispose();
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
HTTPManager.Logger.Exception("StreamList", "Dispose", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override long Position
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
throw new NotImplementedException("Position get");
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
throw new NotImplementedException("Position set");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override long Seek(long offset, System.IO.SeekOrigin origin)
|
||||||
|
{
|
||||||
|
if (CurrentIdx >= Streams.Length)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return Streams[CurrentIdx].Seek(offset, origin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SetLength(long value)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException("SetLength");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*public static class AndroidFileHelper
|
||||||
|
{
|
||||||
|
// AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
|
||||||
|
// AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity");
|
||||||
|
|
||||||
|
public static Stream GetAPKFileStream(string path)
|
||||||
|
{
|
||||||
|
UnityEngine.AndroidJavaClass up = new UnityEngine.AndroidJavaClass("com.unity3d.player.UnityPlayer");
|
||||||
|
UnityEngine.AndroidJavaObject cActivity = up.GetStatic<UnityEngine.AndroidJavaObject>("currentActivity");
|
||||||
|
|
||||||
|
UnityEngine.AndroidJavaObject assetManager = cActivity.GetStatic<UnityEngine.AndroidJavaObject>("getAssets");
|
||||||
|
|
||||||
|
return new AndroidInputStream(assetManager.Call<UnityEngine.AndroidJavaObject>("open", path));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class AndroidInputStream : Stream
|
||||||
|
{
|
||||||
|
private UnityEngine.AndroidJavaObject baseStream;
|
||||||
|
|
||||||
|
public override bool CanRead
|
||||||
|
{
|
||||||
|
get { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool CanSeek
|
||||||
|
{
|
||||||
|
get { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool CanWrite
|
||||||
|
{
|
||||||
|
get { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Flush()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override long Length
|
||||||
|
{
|
||||||
|
get { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override long Position
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public AndroidInputStream(UnityEngine.AndroidJavaObject inputStream)
|
||||||
|
{
|
||||||
|
this.baseStream = inputStream;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int Read(byte[] buffer, int offset, int count)
|
||||||
|
{
|
||||||
|
return this.baseStream.Call<int>("read", buffer, offset, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override long Seek(long offset, SeekOrigin origin)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SetLength(long value)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Write(byte[] buffer, int offset, int count)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
internal sealed class FileConnection : ConnectionBase
|
||||||
|
{
|
||||||
|
public FileConnection(string serverAddress)
|
||||||
|
:base(serverAddress)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
internal override void Abort(HTTPConnectionStates newState)
|
||||||
|
{
|
||||||
|
State = newState;
|
||||||
|
|
||||||
|
switch (State)
|
||||||
|
{
|
||||||
|
case HTTPConnectionStates.TimedOut: TimedOutStart = DateTime.UtcNow; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void ThreadFunc(object param)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Step 1 : create a stream with header information
|
||||||
|
// Step 2 : create a stream from the file
|
||||||
|
// Step 3 : create a StreamList
|
||||||
|
// Step 4 : create a HTTPResponse object
|
||||||
|
// Step 5 : call the Receive function of the response object
|
||||||
|
|
||||||
|
using (System.IO.Stream fs = HTTPManager.IOService.CreateFileStream(this.CurrentRequest.CurrentUri.LocalPath, FileStreamModes.Open))
|
||||||
|
//using (Stream fs = AndroidFileHelper.GetAPKFileStream(this.CurrentRequest.CurrentUri.LocalPath))
|
||||||
|
using (StreamList stream = new StreamList(new System.IO.MemoryStream(), fs))
|
||||||
|
{
|
||||||
|
// This will write to the MemoryStream
|
||||||
|
stream.Write("HTTP/1.1 200 Ok\r\n");
|
||||||
|
stream.Write("Content-Type: application/octet-stream\r\n");
|
||||||
|
stream.Write("Content-Length: " + fs.Length.ToString() + "\r\n");
|
||||||
|
stream.Write("\r\n");
|
||||||
|
|
||||||
|
stream.Seek(0, System.IO.SeekOrigin.Begin);
|
||||||
|
|
||||||
|
base.CurrentRequest.Response = new HTTPResponse(base.CurrentRequest, stream, base.CurrentRequest.UseStreaming, false);
|
||||||
|
|
||||||
|
if (!CurrentRequest.Response.Receive())
|
||||||
|
CurrentRequest.Response = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
if (CurrentRequest != null)
|
||||||
|
{
|
||||||
|
// Something gone bad, Response must be null!
|
||||||
|
CurrentRequest.Response = null;
|
||||||
|
|
||||||
|
switch (State)
|
||||||
|
{
|
||||||
|
case HTTPConnectionStates.AbortRequested:
|
||||||
|
CurrentRequest.State = HTTPRequestStates.Aborted;
|
||||||
|
break;
|
||||||
|
case HTTPConnectionStates.TimedOut:
|
||||||
|
CurrentRequest.State = HTTPRequestStates.TimedOut;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
CurrentRequest.Exception = ex;
|
||||||
|
CurrentRequest.State = HTTPRequestStates.Error;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
State = HTTPConnectionStates.Closed;
|
||||||
|
if (CurrentRequest.State == HTTPRequestStates.Processing)
|
||||||
|
{
|
||||||
|
if (CurrentRequest.Response != null)
|
||||||
|
CurrentRequest.State = HTTPRequestStates.Finished;
|
||||||
|
else
|
||||||
|
CurrentRequest.State = HTTPRequestStates.Error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 24106f78264881a419f83ef4b760ded7
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,411 @@
|
|||||||
|
#if UNITY_WEBGL && !UNITY_EDITOR
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
using BestHTTP.Authentication;
|
||||||
|
using BestHTTP.Extensions;
|
||||||
|
|
||||||
|
namespace BestHTTP
|
||||||
|
{
|
||||||
|
delegate void OnWebGLRequestHandlerDelegate(int nativeId, int httpStatus, IntPtr pBuffer, int length, int zero);
|
||||||
|
delegate void OnWebGLBufferDelegate(int nativeId, IntPtr pBuffer, int length);
|
||||||
|
delegate void OnWebGLProgressDelegate(int nativeId, int downloaded, int total);
|
||||||
|
delegate void OnWebGLErrorDelegate(int nativeId, string error);
|
||||||
|
delegate void OnWebGLTimeoutDelegate(int nativeId);
|
||||||
|
delegate void OnWebGLAbortedDelegate(int nativeId);
|
||||||
|
|
||||||
|
internal sealed class WebGLConnection : ConnectionBase
|
||||||
|
{
|
||||||
|
static Dictionary<int, WebGLConnection> Connections = new Dictionary<int, WebGLConnection>(4);
|
||||||
|
|
||||||
|
int NativeId;
|
||||||
|
BufferPoolMemoryStream Stream;
|
||||||
|
|
||||||
|
public WebGLConnection(string serverAddress)
|
||||||
|
: base(serverAddress, false)
|
||||||
|
{
|
||||||
|
XHR_SetLoglevel((byte)HTTPManager.Logger.Level);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override void Abort(HTTPConnectionStates newState)
|
||||||
|
{
|
||||||
|
State = newState;
|
||||||
|
|
||||||
|
switch (State)
|
||||||
|
{
|
||||||
|
case HTTPConnectionStates.TimedOut: TimedOutStart = DateTime.UtcNow; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
XHR_Abort(this.NativeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void ThreadFunc(object param /*null*/)
|
||||||
|
{
|
||||||
|
// XmlHttpRequest setup
|
||||||
|
|
||||||
|
this.NativeId = XHR_Create(HTTPRequest.MethodNames[(byte)CurrentRequest.MethodType],
|
||||||
|
CurrentRequest.CurrentUri.OriginalString,
|
||||||
|
CurrentRequest.Credentials != null ? CurrentRequest.Credentials.UserName : null,
|
||||||
|
CurrentRequest.Credentials != null ? CurrentRequest.Credentials.Password : null,
|
||||||
|
CurrentRequest.WithCredentials ? 1 : 0);
|
||||||
|
Connections.Add(NativeId, this);
|
||||||
|
|
||||||
|
CurrentRequest.EnumerateHeaders((header, values) =>
|
||||||
|
{
|
||||||
|
if (header != "Content-Length")
|
||||||
|
for (int i = 0; i < values.Count; ++i)
|
||||||
|
XHR_SetRequestHeader(NativeId, header, values[i]);
|
||||||
|
}, /*callBeforeSendCallback:*/ true);
|
||||||
|
|
||||||
|
byte[] body = CurrentRequest.GetEntityBody();
|
||||||
|
|
||||||
|
XHR_SetResponseHandler(NativeId, WebGLConnection.OnResponse, WebGLConnection.OnError, WebGLConnection.OnTimeout, WebGLConnection.OnAborted);
|
||||||
|
// Setting OnUploadProgress result in an addEventListener("progress", ...) call making the request non-simple.
|
||||||
|
// https://forum.unity.com/threads/best-http-released.200006/page-49#post-3696220
|
||||||
|
XHR_SetProgressHandler(NativeId, WebGLConnection.OnDownloadProgress, CurrentRequest.OnUploadProgress == null ? (OnWebGLProgressDelegate)null : WebGLConnection.OnUploadProgress);
|
||||||
|
|
||||||
|
XHR_SetTimeout(NativeId, (uint)(CurrentRequest.ConnectTimeout.TotalMilliseconds + CurrentRequest.Timeout.TotalMilliseconds));
|
||||||
|
|
||||||
|
XHR_Send(NativeId, body, body != null ? body.Length : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Callback Implementations
|
||||||
|
|
||||||
|
void OnResponse(int httpStatus, byte[] buffer, int bufferLength)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var ms = new BufferPoolMemoryStream())
|
||||||
|
{
|
||||||
|
Stream = ms;
|
||||||
|
|
||||||
|
XHR_GetStatusLine(NativeId, OnBufferCallback);
|
||||||
|
XHR_GetResponseHeaders(NativeId, OnBufferCallback);
|
||||||
|
|
||||||
|
if (buffer != null && bufferLength > 0)
|
||||||
|
ms.Write(buffer, 0, bufferLength);
|
||||||
|
|
||||||
|
ms.Seek(0L, SeekOrigin.Begin);
|
||||||
|
|
||||||
|
var internalBuffer = ms.GetBuffer();
|
||||||
|
string tmp = System.Text.Encoding.UTF8.GetString(internalBuffer);
|
||||||
|
HTTPManager.Logger.Information(this.NativeId + " OnResponse - full response ", tmp);
|
||||||
|
|
||||||
|
SupportedProtocols protocol = CurrentRequest.ProtocolHandler == SupportedProtocols.Unknown ? HTTPProtocolFactory.GetProtocolFromUri(CurrentRequest.CurrentUri) : CurrentRequest.ProtocolHandler;
|
||||||
|
CurrentRequest.Response = HTTPProtocolFactory.Get(protocol, CurrentRequest, ms, CurrentRequest.UseStreaming, false);
|
||||||
|
|
||||||
|
CurrentRequest.Response.Receive(buffer != null && bufferLength > 0 ? (int)bufferLength : -1, true);
|
||||||
|
|
||||||
|
if (CurrentRequest.IsCookiesEnabled)
|
||||||
|
BestHTTP.Cookies.CookieJar.Set(CurrentRequest.Response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
HTTPManager.Logger.Exception(this.NativeId + " WebGLConnection", "OnResponse", e);
|
||||||
|
|
||||||
|
if (CurrentRequest != null)
|
||||||
|
{
|
||||||
|
// Something gone bad, Response must be null!
|
||||||
|
CurrentRequest.Response = null;
|
||||||
|
|
||||||
|
switch (State)
|
||||||
|
{
|
||||||
|
case HTTPConnectionStates.AbortRequested:
|
||||||
|
CurrentRequest.State = HTTPRequestStates.Aborted;
|
||||||
|
break;
|
||||||
|
case HTTPConnectionStates.TimedOut:
|
||||||
|
CurrentRequest.State = HTTPRequestStates.TimedOut;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
CurrentRequest.Exception = e;
|
||||||
|
CurrentRequest.State = HTTPRequestStates.Error;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Connections.Remove(NativeId);
|
||||||
|
|
||||||
|
Stream = null;
|
||||||
|
|
||||||
|
if (CurrentRequest != null)
|
||||||
|
lock (HTTPManager.Locker)
|
||||||
|
{
|
||||||
|
State = HTTPConnectionStates.Closed;
|
||||||
|
if (CurrentRequest.State == HTTPRequestStates.Processing)
|
||||||
|
{
|
||||||
|
if (CurrentRequest.Response != null)
|
||||||
|
CurrentRequest.State = HTTPRequestStates.Finished;
|
||||||
|
else
|
||||||
|
CurrentRequest.State = HTTPRequestStates.Error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LastProcessTime = DateTime.UtcNow;
|
||||||
|
|
||||||
|
if (OnConnectionRecycled != null)
|
||||||
|
RecycleNow();
|
||||||
|
|
||||||
|
XHR_Release(NativeId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnBuffer(byte[] buffer, int bufferLength)
|
||||||
|
{
|
||||||
|
if (Stream != null)
|
||||||
|
{
|
||||||
|
Stream.Write(buffer, 0, bufferLength);
|
||||||
|
//Stream.Write(new byte[2] { HTTPResponse.CR, HTTPResponse.LF }, 0, 2);
|
||||||
|
Stream.Write(HTTPRequest.EOL, 0, HTTPRequest.EOL.Length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnDownloadProgress(int down, int total)
|
||||||
|
{
|
||||||
|
CurrentRequest.Downloaded = down;
|
||||||
|
CurrentRequest.DownloadLength = total;
|
||||||
|
CurrentRequest.DownloadProgressChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnUploadProgress(int up, int total)
|
||||||
|
{
|
||||||
|
CurrentRequest.Uploaded = up;
|
||||||
|
CurrentRequest.UploadLength = total;
|
||||||
|
CurrentRequest.UploadProgressChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnError(string error)
|
||||||
|
{
|
||||||
|
HTTPManager.Logger.Information(this.NativeId + " WebGLConnection - OnError", error);
|
||||||
|
|
||||||
|
Connections.Remove(NativeId);
|
||||||
|
|
||||||
|
Stream = null;
|
||||||
|
|
||||||
|
if (CurrentRequest != null)
|
||||||
|
lock (HTTPManager.Locker)
|
||||||
|
{
|
||||||
|
State = HTTPConnectionStates.Closed;
|
||||||
|
CurrentRequest.State = HTTPRequestStates.Error;
|
||||||
|
CurrentRequest.Exception = new Exception(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
LastProcessTime = DateTime.UtcNow;
|
||||||
|
|
||||||
|
if (OnConnectionRecycled != null)
|
||||||
|
RecycleNow();
|
||||||
|
|
||||||
|
XHR_Release(NativeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnTimeout()
|
||||||
|
{
|
||||||
|
HTTPManager.Logger.Information(this.NativeId + " WebGLConnection - OnResponse", string.Empty);
|
||||||
|
|
||||||
|
Connections.Remove(NativeId);
|
||||||
|
|
||||||
|
Stream = null;
|
||||||
|
|
||||||
|
if (CurrentRequest != null)
|
||||||
|
lock (HTTPManager.Locker)
|
||||||
|
{
|
||||||
|
State = HTTPConnectionStates.Closed;
|
||||||
|
CurrentRequest.State = HTTPRequestStates.TimedOut;
|
||||||
|
}
|
||||||
|
|
||||||
|
LastProcessTime = DateTime.UtcNow;
|
||||||
|
|
||||||
|
if (OnConnectionRecycled != null)
|
||||||
|
RecycleNow();
|
||||||
|
|
||||||
|
XHR_Release(NativeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnAborted()
|
||||||
|
{
|
||||||
|
HTTPManager.Logger.Information(this.NativeId + " WebGLConnection - OnAborted", string.Empty);
|
||||||
|
|
||||||
|
Connections.Remove(NativeId);
|
||||||
|
|
||||||
|
Stream = null;
|
||||||
|
|
||||||
|
if (CurrentRequest != null)
|
||||||
|
lock (HTTPManager.Locker)
|
||||||
|
{
|
||||||
|
State = HTTPConnectionStates.Closed;
|
||||||
|
CurrentRequest.State = HTTPRequestStates.Aborted;
|
||||||
|
}
|
||||||
|
|
||||||
|
LastProcessTime = DateTime.UtcNow;
|
||||||
|
|
||||||
|
if (OnConnectionRecycled != null)
|
||||||
|
RecycleNow();
|
||||||
|
|
||||||
|
XHR_Release(NativeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region WebGL Static Callbacks
|
||||||
|
|
||||||
|
[AOT.MonoPInvokeCallback(typeof(OnWebGLRequestHandlerDelegate))]
|
||||||
|
static void OnResponse(int nativeId, int httpStatus, IntPtr pBuffer, int length, int err)
|
||||||
|
{
|
||||||
|
HTTPManager.Logger.Information("WebGLConnection - OnResponse", string.Format("{0} {1} {2} {3}", nativeId, httpStatus, length, err));
|
||||||
|
|
||||||
|
WebGLConnection conn = null;
|
||||||
|
if (!Connections.TryGetValue(nativeId, out conn))
|
||||||
|
{
|
||||||
|
HTTPManager.Logger.Error("WebGLConnection - OnResponse", "No WebGL connection found for nativeId: " + nativeId.ToString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] buffer = VariableSizedBufferPool.Get(length, true);
|
||||||
|
|
||||||
|
// Copy data from the 'unmanaged' memory to managed memory. Buffer will be reclaimed by the GC.
|
||||||
|
Marshal.Copy(pBuffer, buffer, 0, length);
|
||||||
|
|
||||||
|
conn.OnResponse(httpStatus, buffer, length);
|
||||||
|
|
||||||
|
VariableSizedBufferPool.Release(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
[AOT.MonoPInvokeCallback(typeof(OnWebGLBufferDelegate))]
|
||||||
|
static void OnBufferCallback(int nativeId, IntPtr pBuffer, int length)
|
||||||
|
{
|
||||||
|
WebGLConnection conn = null;
|
||||||
|
if (!Connections.TryGetValue(nativeId, out conn))
|
||||||
|
{
|
||||||
|
HTTPManager.Logger.Error("WebGLConnection - OnBufferCallback", "No WebGL connection found for nativeId: " + nativeId.ToString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] buffer = VariableSizedBufferPool.Get(length, true);
|
||||||
|
|
||||||
|
// Copy data from the 'unmanaged' memory to managed memory. Buffer will be reclaimed by the GC.
|
||||||
|
Marshal.Copy(pBuffer, buffer, 0, length);
|
||||||
|
|
||||||
|
conn.OnBuffer(buffer, length);
|
||||||
|
|
||||||
|
VariableSizedBufferPool.Release(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
[AOT.MonoPInvokeCallback(typeof(OnWebGLProgressDelegate))]
|
||||||
|
static void OnDownloadProgress(int nativeId, int downloaded, int total)
|
||||||
|
{
|
||||||
|
HTTPManager.Logger.Information(nativeId + " OnDownloadProgress", downloaded.ToString() + " / " + total.ToString());
|
||||||
|
|
||||||
|
WebGLConnection conn = null;
|
||||||
|
if (!Connections.TryGetValue(nativeId, out conn))
|
||||||
|
{
|
||||||
|
HTTPManager.Logger.Error("WebGLConnection - OnDownloadProgress", "No WebGL connection found for nativeId: " + nativeId.ToString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
conn.OnDownloadProgress(downloaded, total);
|
||||||
|
}
|
||||||
|
|
||||||
|
[AOT.MonoPInvokeCallback(typeof(OnWebGLProgressDelegate))]
|
||||||
|
static void OnUploadProgress(int nativeId, int uploaded, int total)
|
||||||
|
{
|
||||||
|
HTTPManager.Logger.Information(nativeId + " OnUploadProgress", uploaded.ToString() + " / " + total.ToString());
|
||||||
|
|
||||||
|
WebGLConnection conn = null;
|
||||||
|
if (!Connections.TryGetValue(nativeId, out conn))
|
||||||
|
{
|
||||||
|
HTTPManager.Logger.Error("WebGLConnection - OnUploadProgress", "No WebGL connection found for nativeId: " + nativeId.ToString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
conn.OnUploadProgress(uploaded, total);
|
||||||
|
}
|
||||||
|
|
||||||
|
[AOT.MonoPInvokeCallback(typeof(OnWebGLErrorDelegate))]
|
||||||
|
static void OnError(int nativeId, string error)
|
||||||
|
{
|
||||||
|
WebGLConnection conn = null;
|
||||||
|
if (!Connections.TryGetValue(nativeId, out conn))
|
||||||
|
{
|
||||||
|
HTTPManager.Logger.Error("WebGLConnection - OnError", "No WebGL connection found for nativeId: " + nativeId.ToString() + " Error: " + error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
conn.OnError(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
[AOT.MonoPInvokeCallback(typeof(OnWebGLTimeoutDelegate))]
|
||||||
|
static void OnTimeout(int nativeId)
|
||||||
|
{
|
||||||
|
WebGLConnection conn = null;
|
||||||
|
if (!Connections.TryGetValue(nativeId, out conn))
|
||||||
|
{
|
||||||
|
HTTPManager.Logger.Error("WebGLConnection - OnTimeout", "No WebGL connection found for nativeId: " + nativeId.ToString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
conn.OnTimeout();
|
||||||
|
}
|
||||||
|
|
||||||
|
[AOT.MonoPInvokeCallback(typeof(OnWebGLAbortedDelegate))]
|
||||||
|
static void OnAborted(int nativeId)
|
||||||
|
{
|
||||||
|
WebGLConnection conn = null;
|
||||||
|
if (!Connections.TryGetValue(nativeId, out conn))
|
||||||
|
{
|
||||||
|
HTTPManager.Logger.Error("WebGLConnection - OnAborted", "No WebGL connection found for nativeId: " + nativeId.ToString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
conn.OnAborted();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region WebGL Interface
|
||||||
|
|
||||||
|
[DllImport("__Internal")]
|
||||||
|
private static extern int XHR_Create(string method, string url, string userName, string passwd, int withCredentials);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Is an unsigned long representing the number of milliseconds a request can take before automatically being terminated. A value of 0 (which is the default) means there is no timeout.
|
||||||
|
/// </summary>
|
||||||
|
[DllImport("__Internal")]
|
||||||
|
private static extern void XHR_SetTimeout(int nativeId, uint timeout);
|
||||||
|
|
||||||
|
[DllImport("__Internal")]
|
||||||
|
private static extern void XHR_SetRequestHeader(int nativeId, string header, string value);
|
||||||
|
|
||||||
|
[DllImport("__Internal")]
|
||||||
|
private static extern void XHR_SetResponseHandler(int nativeId, OnWebGLRequestHandlerDelegate onresponse, OnWebGLErrorDelegate onerror, OnWebGLTimeoutDelegate ontimeout, OnWebGLAbortedDelegate onabort);
|
||||||
|
|
||||||
|
[DllImport("__Internal")]
|
||||||
|
private static extern void XHR_SetProgressHandler(int nativeId, OnWebGLProgressDelegate onDownloadProgress, OnWebGLProgressDelegate onUploadProgress);
|
||||||
|
|
||||||
|
[DllImport("__Internal")]
|
||||||
|
private static extern void XHR_Send(int nativeId, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1, SizeParamIndex = 2)] byte[] body, int length);
|
||||||
|
|
||||||
|
[DllImport("__Internal")]
|
||||||
|
private static extern void XHR_GetResponseHeaders(int nativeId, OnWebGLBufferDelegate callback);
|
||||||
|
|
||||||
|
[DllImport("__Internal")]
|
||||||
|
private static extern void XHR_GetStatusLine(int nativeId, OnWebGLBufferDelegate callback);
|
||||||
|
|
||||||
|
[DllImport("__Internal")]
|
||||||
|
private static extern void XHR_Abort(int nativeId);
|
||||||
|
|
||||||
|
[DllImport("__Internal")]
|
||||||
|
private static extern void XHR_Release(int nativeId);
|
||||||
|
|
||||||
|
[DllImport("__Internal")]
|
||||||
|
private static extern void XHR_SetLoglevel(int logLevel);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: cca5a5d266418134dbb9c0b87c68e62a
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
7
JNFrame/Assets/Plugins/BestHTTP/BestHTTP/Cookies.meta
Normal file
7
JNFrame/Assets/Plugins/BestHTTP/BestHTTP/Cookies.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e138652289c643d4ca6bff547a5bd4f0
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
359
JNFrame/Assets/Plugins/BestHTTP/BestHTTP/Cookies/Cookie.cs
Normal file
359
JNFrame/Assets/Plugins/BestHTTP/BestHTTP/Cookies/Cookie.cs
Normal file
@ -0,0 +1,359 @@
|
|||||||
|
#if !BESTHTTP_DISABLE_COOKIES
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using BestHTTP.Extensions;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace BestHTTP.Cookies
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The Cookie implementation based on RFC 6265(http://tools.ietf.org/html/rfc6265).
|
||||||
|
/// </summary>
|
||||||
|
public sealed class Cookie : IComparable<Cookie>, IEquatable<Cookie>
|
||||||
|
{
|
||||||
|
private const int Version = 1;
|
||||||
|
|
||||||
|
#region Public Properties
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The name of the cookie.
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The value of the cookie.
|
||||||
|
/// </summary>
|
||||||
|
public string Value { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The Date when the Cookie is registered.
|
||||||
|
/// </summary>
|
||||||
|
public DateTime Date { get; internal set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// When this Cookie last used in a request.
|
||||||
|
/// </summary>
|
||||||
|
public DateTime LastAccess { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The Expires attribute indicates the maximum lifetime of the cookie, represented as the date and time at which the cookie expires.
|
||||||
|
/// The user agent is not required to retain the cookie until the specified date has passed.
|
||||||
|
/// In fact, user agents often evict cookies due to memory pressure or privacy concerns.
|
||||||
|
/// </summary>
|
||||||
|
public DateTime Expires { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The Max-Age attribute indicates the maximum lifetime of the cookie, represented as the number of seconds until the cookie expires.
|
||||||
|
/// The user agent is not required to retain the cookie for the specified duration.
|
||||||
|
/// In fact, user agents often evict cookies due to memory pressure or privacy concerns.
|
||||||
|
/// </summary>
|
||||||
|
public long MaxAge { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If a cookie has neither the Max-Age nor the Expires attribute, the user agent will retain the cookie until "the current session is over".
|
||||||
|
/// </summary>
|
||||||
|
public bool IsSession { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The Domain attribute specifies those hosts to which the cookie will be sent.
|
||||||
|
/// For example, if the value of the Domain attribute is "example.com", the user agent will include the cookie
|
||||||
|
/// in the Cookie header when making HTTP requests to example.com, www.example.com, and www.corp.example.com.
|
||||||
|
/// If the server omits the Domain attribute, the user agent will return the cookie only to the origin server.
|
||||||
|
/// </summary>
|
||||||
|
public string Domain { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The scope of each cookie is limited to a set of paths, controlled by the Path attribute.
|
||||||
|
/// If the server omits the Path attribute, the user agent will use the "directory" of the request-uri's path component as the default value.
|
||||||
|
/// </summary>
|
||||||
|
public string Path { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The Secure attribute limits the scope of the cookie to "secure" channels (where "secure" is defined by the user agent).
|
||||||
|
/// When a cookie has the Secure attribute, the user agent will include the cookie in an HTTP request only if the request is
|
||||||
|
/// transmitted over a secure channel (typically HTTP over Transport Layer Security (TLS)).
|
||||||
|
/// </summary>
|
||||||
|
public bool IsSecure { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The HttpOnly attribute limits the scope of the cookie to HTTP requests.
|
||||||
|
/// In particular, the attribute instructs the user agent to omit the cookie when providing access to
|
||||||
|
/// cookies via "non-HTTP" APIs (such as a web browser API that exposes cookies to scripts).
|
||||||
|
/// </summary>
|
||||||
|
public bool IsHttpOnly { get; private set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Public Constructors
|
||||||
|
|
||||||
|
public Cookie(string name, string value)
|
||||||
|
:this(name, value, "/", string.Empty)
|
||||||
|
{}
|
||||||
|
|
||||||
|
public Cookie(string name, string value, string path)
|
||||||
|
: this(name, value, path, string.Empty)
|
||||||
|
{}
|
||||||
|
|
||||||
|
public Cookie(string name, string value, string path, string domain)
|
||||||
|
:this() // call the parameter-less constructor to set default values
|
||||||
|
{
|
||||||
|
this.Name = name;
|
||||||
|
this.Value = value;
|
||||||
|
this.Path = path;
|
||||||
|
this.Domain = domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cookie(Uri uri, string name, string value, DateTime expires, bool isSession = true)
|
||||||
|
:this(name, value, uri.AbsolutePath, uri.Host)
|
||||||
|
{
|
||||||
|
this.Expires = expires;
|
||||||
|
this.IsSession = isSession;
|
||||||
|
this.Date = DateTime.UtcNow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cookie(Uri uri, string name, string value, long maxAge = -1, bool isSession = true)
|
||||||
|
:this(name, value, uri.AbsolutePath, uri.Host)
|
||||||
|
{
|
||||||
|
this.MaxAge = maxAge;
|
||||||
|
this.IsSession = isSession;
|
||||||
|
this.Date = DateTime.UtcNow;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
internal Cookie()
|
||||||
|
{
|
||||||
|
// If a cookie has neither the Max-Age nor the Expires attribute, the user agent will retain the cookie
|
||||||
|
// until "the current session is over" (as defined by the user agent).
|
||||||
|
IsSession = true;
|
||||||
|
MaxAge = -1;
|
||||||
|
LastAccess = DateTime.UtcNow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool WillExpireInTheFuture()
|
||||||
|
{
|
||||||
|
// No Expires or Max-Age value sent from the server, we will fake the return value so we will not delete the newly came Cookie
|
||||||
|
if (IsSession)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// If a cookie has both the Max-Age and the Expires attribute, the Max-Age attribute has precedence and controls the expiration date of the cookie.
|
||||||
|
return MaxAge != -1 ?
|
||||||
|
Math.Max(0, (long)(DateTime.UtcNow - Date).TotalSeconds) < MaxAge :
|
||||||
|
Expires > DateTime.UtcNow;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Guess the storage size of the cookie.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public uint GuessSize()
|
||||||
|
{
|
||||||
|
return (uint)((Name != null ? Name.Length * sizeof(char) : 0) +
|
||||||
|
(Value != null ? Value.Length * sizeof(char) : 0) +
|
||||||
|
(Domain != null ? Domain.Length * sizeof(char) : 0) +
|
||||||
|
(Path != null ? Path.Length * sizeof(char) : 0) +
|
||||||
|
(sizeof(long) * 4) +
|
||||||
|
(sizeof(bool) * 3));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Cookie Parse(string header, Uri defaultDomain)
|
||||||
|
{
|
||||||
|
Cookie cookie = new Cookie();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var kvps = ParseCookieHeader(header);
|
||||||
|
|
||||||
|
foreach (var kvp in kvps)
|
||||||
|
{
|
||||||
|
switch (kvp.Key.ToLowerInvariant())
|
||||||
|
{
|
||||||
|
case "path":
|
||||||
|
// If the attribute-value is empty or if the first character of the attribute-value is not %x2F ("/"):
|
||||||
|
// Let cookie-path be the default-path.
|
||||||
|
cookie.Path = string.IsNullOrEmpty(kvp.Value) || !kvp.Value.StartsWith("/") ? "/" : cookie.Path = kvp.Value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "domain":
|
||||||
|
// If the attribute-value is empty, the behavior is undefined. However, the user agent SHOULD ignore the cookie-av entirely.
|
||||||
|
if (string.IsNullOrEmpty(kvp.Value))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// If the first character of the attribute-value string is %x2E ("."):
|
||||||
|
// Let cookie-domain be the attribute-value without the leading %x2E (".") character.
|
||||||
|
cookie.Domain = kvp.Value.StartsWith(".") ? kvp.Value.Substring(1) : kvp.Value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "expires":
|
||||||
|
cookie.Expires = kvp.Value.ToDateTime(DateTime.FromBinary(0));
|
||||||
|
cookie.IsSession = false;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "max-age":
|
||||||
|
cookie.MaxAge = kvp.Value.ToInt64(-1);
|
||||||
|
cookie.IsSession = false;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "secure":
|
||||||
|
cookie.IsSecure = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "httponly":
|
||||||
|
cookie.IsHttpOnly = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
cookie.Name = kvp.Key;
|
||||||
|
cookie.Value = kvp.Value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Some user agents provide users the option of preventing persistent storage of cookies across sessions.
|
||||||
|
// When configured thusly, user agents MUST treat all received cookies as if the persistent-flag were set to false.
|
||||||
|
if (HTTPManager.EnablePrivateBrowsing)
|
||||||
|
cookie.IsSession = true;
|
||||||
|
|
||||||
|
// http://tools.ietf.org/html/rfc6265#section-4.1.2.3
|
||||||
|
// WARNING: Some existing user agents treat an absent Domain attribute as if the Domain attribute were present and contained the current host name.
|
||||||
|
// For example, if example.com returns a Set-Cookie header without a Domain attribute, these user agents will erroneously send the cookie to www.example.com as well.
|
||||||
|
if (string.IsNullOrEmpty(cookie.Domain))
|
||||||
|
cookie.Domain = defaultDomain.Host;
|
||||||
|
|
||||||
|
// http://tools.ietf.org/html/rfc6265#section-5.3 section 7:
|
||||||
|
// If the cookie-attribute-list contains an attribute with an attribute-name of "Path",
|
||||||
|
// set the cookie's path to attribute-value of the last attribute in the cookie-attribute-list with an attribute-name of "Path".
|
||||||
|
// __Otherwise, set the cookie's path to the default-path of the request-uri.__
|
||||||
|
if (string.IsNullOrEmpty(cookie.Path))
|
||||||
|
cookie.Path = defaultDomain.AbsolutePath;
|
||||||
|
|
||||||
|
cookie.Date = cookie.LastAccess = DateTime.UtcNow;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
HTTPManager.Logger.Warning("Cookie", "Parse - Couldn't parse header: " + header + " exception: " + ex.ToString() + " " + ex.StackTrace);
|
||||||
|
}
|
||||||
|
return cookie;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Save & Load
|
||||||
|
|
||||||
|
internal void SaveTo(BinaryWriter stream)
|
||||||
|
{
|
||||||
|
stream.Write(Version);
|
||||||
|
stream.Write(Name ?? string.Empty);
|
||||||
|
stream.Write(Value ?? string.Empty);
|
||||||
|
stream.Write(Date.ToBinary());
|
||||||
|
stream.Write(LastAccess.ToBinary());
|
||||||
|
stream.Write(Expires.ToBinary());
|
||||||
|
stream.Write(MaxAge);
|
||||||
|
stream.Write(IsSession);
|
||||||
|
stream.Write(Domain ?? string.Empty);
|
||||||
|
stream.Write(Path ?? string.Empty);
|
||||||
|
stream.Write(IsSecure);
|
||||||
|
stream.Write(IsHttpOnly);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void LoadFrom(BinaryReader stream)
|
||||||
|
{
|
||||||
|
/*int version = */stream.ReadInt32();
|
||||||
|
this.Name = stream.ReadString();
|
||||||
|
this.Value = stream.ReadString();
|
||||||
|
this.Date = DateTime.FromBinary(stream.ReadInt64());
|
||||||
|
this.LastAccess = DateTime.FromBinary(stream.ReadInt64());
|
||||||
|
this.Expires = DateTime.FromBinary(stream.ReadInt64());
|
||||||
|
this.MaxAge = stream.ReadInt64();
|
||||||
|
this.IsSession = stream.ReadBoolean();
|
||||||
|
this.Domain = stream.ReadString();
|
||||||
|
this.Path = stream.ReadString();
|
||||||
|
this.IsSecure = stream.ReadBoolean();
|
||||||
|
this.IsHttpOnly = stream.ReadBoolean();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Overrides and new Equals function
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return string.Concat(this.Name, "=", this.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Equals(object obj)
|
||||||
|
{
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return this.Equals(obj as Cookie);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Equals(Cookie cookie)
|
||||||
|
{
|
||||||
|
if (cookie == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (Object.ReferenceEquals(this, cookie))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return this.Name.Equals(cookie.Name, StringComparison.Ordinal) &&
|
||||||
|
((this.Domain == null && cookie.Domain == null) || this.Domain.Equals(cookie.Domain, StringComparison.Ordinal)) &&
|
||||||
|
((this.Path == null && cookie.Path == null) || this.Path.Equals(cookie.Path, StringComparison.Ordinal));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return this.ToString().GetHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Private Helper Functions
|
||||||
|
|
||||||
|
private static string ReadValue(string str, ref int pos)
|
||||||
|
{
|
||||||
|
string result = string.Empty;
|
||||||
|
if (str == null)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
return str.Read(ref pos, ';');
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<HeaderValue> ParseCookieHeader(string str)
|
||||||
|
{
|
||||||
|
List<HeaderValue> result = new List<HeaderValue>();
|
||||||
|
|
||||||
|
if (str == null)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
int idx = 0;
|
||||||
|
|
||||||
|
// process the rest of the text
|
||||||
|
while (idx < str.Length)
|
||||||
|
{
|
||||||
|
// Read key
|
||||||
|
string key = str.Read(ref idx, (ch) => ch != '=' && ch != ';').Trim();
|
||||||
|
HeaderValue qp = new HeaderValue(key);
|
||||||
|
|
||||||
|
if (idx < str.Length && str[idx - 1] == '=')
|
||||||
|
qp.Value = ReadValue(str, ref idx);
|
||||||
|
|
||||||
|
result.Add(qp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region IComparable<Cookie> implementation
|
||||||
|
|
||||||
|
public int CompareTo(Cookie other)
|
||||||
|
{
|
||||||
|
return this.LastAccess.CompareTo(other.LastAccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3c89f8c2ca77c56448d03216927e0546
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
489
JNFrame/Assets/Plugins/BestHTTP/BestHTTP/Cookies/CookieJar.cs
Normal file
489
JNFrame/Assets/Plugins/BestHTTP/BestHTTP/Cookies/CookieJar.cs
Normal file
@ -0,0 +1,489 @@
|
|||||||
|
#if !BESTHTTP_DISABLE_COOKIES
|
||||||
|
|
||||||
|
using BestHTTP.PlatformSupport.FileSystem;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace BestHTTP.Cookies
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The Cookie Jar implementation based on RFC 6265(http://tools.ietf.org/html/rfc6265).
|
||||||
|
/// </summary>
|
||||||
|
public static class CookieJar
|
||||||
|
{
|
||||||
|
// Version of the cookie store. It may be used in a future version for maintaining compatibility.
|
||||||
|
private const int Version = 1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if File apis are supported.
|
||||||
|
/// </summary>
|
||||||
|
public static bool IsSavingSupported
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
#if !BESTHTTP_DISABLE_COOKIE_SAVE
|
||||||
|
if (IsSupportCheckDone)
|
||||||
|
return _isSavingSupported;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
HTTPManager.IOService.DirectoryExists(HTTPManager.GetRootCacheFolder());
|
||||||
|
_isSavingSupported = true;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
_isSavingSupported = false;
|
||||||
|
|
||||||
|
HTTPManager.Logger.Warning("CookieJar", "Cookie saving and loading disabled!");
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
IsSupportCheckDone = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _isSavingSupported;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The plugin will delete cookies that are accessed this threshold ago. Its default value is 7 days.
|
||||||
|
/// </summary>
|
||||||
|
public static TimeSpan AccessThreshold = TimeSpan.FromDays(7);
|
||||||
|
|
||||||
|
#region Privates
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List of the Cookies
|
||||||
|
/// </summary>
|
||||||
|
private static List<Cookie> Cookies = new List<Cookie>();
|
||||||
|
private static string CookieFolder { get; set; }
|
||||||
|
private static string LibraryPath { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Synchronization object for thread safety.
|
||||||
|
/// </summary>
|
||||||
|
private static object Locker = new object();
|
||||||
|
|
||||||
|
#if !BESTHTTP_DISABLE_COOKIE_SAVE
|
||||||
|
private static bool _isSavingSupported;
|
||||||
|
private static bool IsSupportCheckDone;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private static bool Loaded;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Internal Functions
|
||||||
|
|
||||||
|
internal static void SetupFolder()
|
||||||
|
{
|
||||||
|
#if !BESTHTTP_DISABLE_COOKIE_SAVE
|
||||||
|
if (!CookieJar.IsSavingSupported)
|
||||||
|
return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(CookieFolder) || string.IsNullOrEmpty(LibraryPath))
|
||||||
|
{
|
||||||
|
CookieFolder = System.IO.Path.Combine(HTTPManager.GetRootCacheFolder(), "Cookies");
|
||||||
|
LibraryPath = System.IO.Path.Combine(CookieFolder, "Library");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{ }
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Will set or update all cookies from the response object.
|
||||||
|
/// </summary>
|
||||||
|
internal static void Set(HTTPResponse response)
|
||||||
|
{
|
||||||
|
if (response == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
lock(Locker)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Maintain();
|
||||||
|
|
||||||
|
List<Cookie> newCookies = new List<Cookie>();
|
||||||
|
var setCookieHeaders = response.GetHeaderValues("set-cookie");
|
||||||
|
|
||||||
|
// No cookies. :'(
|
||||||
|
if (setCookieHeaders == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
foreach (var cookieHeader in setCookieHeaders)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Cookie cookie = Cookie.Parse(cookieHeader, response.baseRequest.CurrentUri);
|
||||||
|
|
||||||
|
if (cookie != null)
|
||||||
|
{
|
||||||
|
int idx;
|
||||||
|
var old = Find(cookie, out idx);
|
||||||
|
|
||||||
|
// if no value for the cookie or already expired then the server asked us to delete the cookie
|
||||||
|
bool expired = string.IsNullOrEmpty(cookie.Value) || !cookie.WillExpireInTheFuture();
|
||||||
|
|
||||||
|
if (!expired)
|
||||||
|
{
|
||||||
|
// no old cookie, add it straight to the list
|
||||||
|
if (old == null)
|
||||||
|
{
|
||||||
|
Cookies.Add(cookie);
|
||||||
|
|
||||||
|
newCookies.Add(cookie);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Update the creation-time of the newly created cookie to match the creation-time of the old-cookie.
|
||||||
|
cookie.Date = old.Date;
|
||||||
|
Cookies[idx] = cookie;
|
||||||
|
|
||||||
|
newCookies.Add(cookie);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (idx != -1) // delete the cookie
|
||||||
|
Cookies.RemoveAt(idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// Ignore cookie on error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
response.Cookies = newCookies;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes all expired or 'old' cookies, and will keep the sum size of cookies under the given size.
|
||||||
|
/// </summary>
|
||||||
|
internal static void Maintain()
|
||||||
|
{
|
||||||
|
// It's not the same as in the rfc:
|
||||||
|
// http://tools.ietf.org/html/rfc6265#section-5.3
|
||||||
|
|
||||||
|
lock (Locker)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
uint size = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < Cookies.Count; )
|
||||||
|
{
|
||||||
|
var cookie = Cookies[i];
|
||||||
|
|
||||||
|
// Remove expired or not used cookies
|
||||||
|
if (!cookie.WillExpireInTheFuture() || (cookie.LastAccess + AccessThreshold) < DateTime.UtcNow)
|
||||||
|
Cookies.RemoveAt(i);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!cookie.IsSession)
|
||||||
|
size += cookie.GuessSize();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (size > HTTPManager.CookieJarSize)
|
||||||
|
{
|
||||||
|
Cookies.Sort();
|
||||||
|
|
||||||
|
while (size > HTTPManager.CookieJarSize && Cookies.Count > 0)
|
||||||
|
{
|
||||||
|
var cookie = Cookies[0];
|
||||||
|
Cookies.RemoveAt(0);
|
||||||
|
|
||||||
|
size -= cookie.GuessSize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Saves the Cookie Jar to a file.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>Not implemented under Unity WebPlayer</remarks>
|
||||||
|
internal static void Persist()
|
||||||
|
{
|
||||||
|
#if !BESTHTTP_DISABLE_COOKIE_SAVE
|
||||||
|
if (!IsSavingSupported)
|
||||||
|
return;
|
||||||
|
|
||||||
|
lock (Locker)
|
||||||
|
{
|
||||||
|
if (!Loaded)
|
||||||
|
return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Delete any expired cookie
|
||||||
|
Maintain();
|
||||||
|
|
||||||
|
if (!HTTPManager.IOService.DirectoryExists(CookieFolder))
|
||||||
|
HTTPManager.IOService.DirectoryCreate(CookieFolder);
|
||||||
|
|
||||||
|
using (var fs = HTTPManager.IOService.CreateFileStream(LibraryPath, FileStreamModes.Create))
|
||||||
|
using (var bw = new System.IO.BinaryWriter(fs))
|
||||||
|
{
|
||||||
|
bw.Write(Version);
|
||||||
|
|
||||||
|
// Count how many non-session cookies we have
|
||||||
|
int count = 0;
|
||||||
|
foreach (var cookie in Cookies)
|
||||||
|
if (!cookie.IsSession)
|
||||||
|
count++;
|
||||||
|
|
||||||
|
bw.Write(count);
|
||||||
|
|
||||||
|
// Save only the persistable cookies
|
||||||
|
foreach (var cookie in Cookies)
|
||||||
|
if (!cookie.IsSession)
|
||||||
|
cookie.SaveTo(bw);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Load previously persisted cookie library from the file.
|
||||||
|
/// </summary>
|
||||||
|
internal static void Load()
|
||||||
|
{
|
||||||
|
#if !BESTHTTP_DISABLE_COOKIE_SAVE
|
||||||
|
if (!IsSavingSupported)
|
||||||
|
return;
|
||||||
|
|
||||||
|
lock (Locker)
|
||||||
|
{
|
||||||
|
if (Loaded)
|
||||||
|
return;
|
||||||
|
|
||||||
|
SetupFolder();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Cookies.Clear();
|
||||||
|
|
||||||
|
if (!HTTPManager.IOService.DirectoryExists(CookieFolder))
|
||||||
|
HTTPManager.IOService.DirectoryCreate(CookieFolder);
|
||||||
|
|
||||||
|
if (!HTTPManager.IOService.FileExists(LibraryPath))
|
||||||
|
return;
|
||||||
|
|
||||||
|
using (var fs = HTTPManager.IOService.CreateFileStream(LibraryPath, FileStreamModes.Open))
|
||||||
|
using (var br = new System.IO.BinaryReader(fs))
|
||||||
|
{
|
||||||
|
/*int version = */br.ReadInt32();
|
||||||
|
int cookieCount = br.ReadInt32();
|
||||||
|
|
||||||
|
for (int i = 0; i < cookieCount; ++i)
|
||||||
|
{
|
||||||
|
Cookie cookie = new Cookie();
|
||||||
|
cookie.LoadFrom(br);
|
||||||
|
|
||||||
|
if (cookie.WillExpireInTheFuture())
|
||||||
|
Cookies.Add(cookie);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Cookies.Clear();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Loaded = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Public Functions
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns all Cookies that corresponds to the given Uri.
|
||||||
|
/// </summary>
|
||||||
|
public static List<Cookie> Get(Uri uri)
|
||||||
|
{
|
||||||
|
lock (Locker)
|
||||||
|
{
|
||||||
|
Load();
|
||||||
|
|
||||||
|
List<Cookie> result = null;
|
||||||
|
|
||||||
|
for (int i = 0; i < Cookies.Count; ++i)
|
||||||
|
{
|
||||||
|
Cookie cookie = Cookies[i];
|
||||||
|
if (cookie.WillExpireInTheFuture() && uri.Host.IndexOf(cookie.Domain) != -1 && uri.AbsolutePath.StartsWith(cookie.Path))
|
||||||
|
{
|
||||||
|
if (result == null)
|
||||||
|
result = new List<Cookie>();
|
||||||
|
|
||||||
|
result.Add(cookie);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Will add a new, or overwrite an old cookie if already exists.
|
||||||
|
/// </summary>
|
||||||
|
public static void Set(Uri uri, Cookie cookie)
|
||||||
|
{
|
||||||
|
Set(cookie);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Will add a new, or overwrite an old cookie if already exists.
|
||||||
|
/// </summary>
|
||||||
|
public static void Set(Cookie cookie)
|
||||||
|
{
|
||||||
|
lock (Locker)
|
||||||
|
{
|
||||||
|
Load();
|
||||||
|
|
||||||
|
int idx;
|
||||||
|
Find(cookie, out idx);
|
||||||
|
|
||||||
|
if (idx >= 0)
|
||||||
|
Cookies[idx] = cookie;
|
||||||
|
else
|
||||||
|
Cookies.Add(cookie);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Cookie> GetAll()
|
||||||
|
{
|
||||||
|
lock (Locker)
|
||||||
|
{
|
||||||
|
Load();
|
||||||
|
|
||||||
|
return Cookies;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes all cookies from the Jar.
|
||||||
|
/// </summary>
|
||||||
|
public static void Clear()
|
||||||
|
{
|
||||||
|
lock (Locker)
|
||||||
|
{
|
||||||
|
Load();
|
||||||
|
|
||||||
|
Cookies.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes cookies that older than the given parameter.
|
||||||
|
/// </summary>
|
||||||
|
public static void Clear(TimeSpan olderThan)
|
||||||
|
{
|
||||||
|
lock (Locker)
|
||||||
|
{
|
||||||
|
Load();
|
||||||
|
|
||||||
|
for (int i = 0; i < Cookies.Count; )
|
||||||
|
{
|
||||||
|
var cookie = Cookies[i];
|
||||||
|
|
||||||
|
// Remove expired or not used cookies
|
||||||
|
if (!cookie.WillExpireInTheFuture() || (cookie.Date + olderThan) < DateTime.UtcNow)
|
||||||
|
Cookies.RemoveAt(i);
|
||||||
|
else
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes cookies that matches to the given domain.
|
||||||
|
/// </summary>
|
||||||
|
public static void Clear(string domain)
|
||||||
|
{
|
||||||
|
lock (Locker)
|
||||||
|
{
|
||||||
|
Load();
|
||||||
|
|
||||||
|
for (int i = 0; i < Cookies.Count; )
|
||||||
|
{
|
||||||
|
var cookie = Cookies[i];
|
||||||
|
|
||||||
|
// Remove expired or not used cookies
|
||||||
|
if (!cookie.WillExpireInTheFuture() || cookie.Domain.IndexOf(domain) != -1)
|
||||||
|
Cookies.RemoveAt(i);
|
||||||
|
else
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Remove(Uri uri, string name)
|
||||||
|
{
|
||||||
|
lock(Locker)
|
||||||
|
{
|
||||||
|
Load();
|
||||||
|
|
||||||
|
for (int i = 0; i < Cookies.Count; )
|
||||||
|
{
|
||||||
|
var cookie = Cookies[i];
|
||||||
|
|
||||||
|
if (cookie.Name.Equals(name, StringComparison.OrdinalIgnoreCase) && uri.Host.IndexOf(cookie.Domain) != -1)
|
||||||
|
Cookies.RemoveAt(i);
|
||||||
|
else
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Private Helper Functions
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Find and return a Cookie and his index in the list.
|
||||||
|
/// </summary>
|
||||||
|
private static Cookie Find(Cookie cookie, out int idx)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < Cookies.Count; ++i)
|
||||||
|
{
|
||||||
|
Cookie c = Cookies[i];
|
||||||
|
|
||||||
|
if (c.Equals(cookie))
|
||||||
|
{
|
||||||
|
idx = i;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
idx = -1;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b6b22cd983735ee46908eac3f37eb798
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4d4075eb3d5bdee4c9f373d710808d60
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
473
JNFrame/Assets/Plugins/BestHTTP/BestHTTP/Decompression/CRC32.cs
Normal file
473
JNFrame/Assets/Plugins/BestHTTP/BestHTTP/Decompression/CRC32.cs
Normal file
@ -0,0 +1,473 @@
|
|||||||
|
// CRC32.cs
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Copyright (c) 2011 Dino Chiesa.
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This code module is part of DotNetZip, a zipfile class library.
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This code is licensed under the Microsoft Public License.
|
||||||
|
// See the file License.txt for the license details.
|
||||||
|
// More info on: http://dotnetzip.codeplex.com
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Last Saved: <2011-August-02 18:25:54>
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This module defines the CRC32 class, which can do the CRC32 algorithm, using
|
||||||
|
// arbitrary starting polynomials, and bit reversal. The bit reversal is what
|
||||||
|
// distinguishes this CRC-32 used in BZip2 from the CRC-32 that is used in PKZIP
|
||||||
|
// files, or GZIP files. This class does both.
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using Interop = System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace BestHTTP.Decompression.Crc
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Computes a CRC-32. The CRC-32 algorithm is parameterized - you
|
||||||
|
/// can set the polynomial and enable or disable bit
|
||||||
|
/// reversal. This can be used for GZIP, BZip2, or ZIP.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// This type is used internally by DotNetZip; it is generally not used
|
||||||
|
/// directly by applications wishing to create, read, or manipulate zip
|
||||||
|
/// archive files.
|
||||||
|
/// </remarks>
|
||||||
|
|
||||||
|
internal class CRC32
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates the total number of bytes applied to the CRC.
|
||||||
|
/// </summary>
|
||||||
|
public Int64 TotalBytesRead
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _TotalBytesRead;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates the current CRC for all blocks slurped in.
|
||||||
|
/// </summary>
|
||||||
|
public Int32 Crc32Result
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return unchecked((Int32)(~_register));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the CRC32 for the specified stream.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input">The stream over which to calculate the CRC32</param>
|
||||||
|
/// <returns>the CRC32 calculation</returns>
|
||||||
|
public Int32 GetCrc32(System.IO.Stream input)
|
||||||
|
{
|
||||||
|
return GetCrc32AndCopy(input, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the CRC32 for the specified stream, and writes the input into the
|
||||||
|
/// output stream.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input">The stream over which to calculate the CRC32</param>
|
||||||
|
/// <param name="output">The stream into which to deflate the input</param>
|
||||||
|
/// <returns>the CRC32 calculation</returns>
|
||||||
|
public Int32 GetCrc32AndCopy(System.IO.Stream input, System.IO.Stream output)
|
||||||
|
{
|
||||||
|
if (input == null)
|
||||||
|
throw new Exception("The input stream must not be null.");
|
||||||
|
|
||||||
|
unchecked
|
||||||
|
{
|
||||||
|
byte[] buffer = new byte[BUFFER_SIZE];
|
||||||
|
int readSize = BUFFER_SIZE;
|
||||||
|
|
||||||
|
_TotalBytesRead = 0;
|
||||||
|
int count = input.Read(buffer, 0, readSize);
|
||||||
|
if (output != null) output.Write(buffer, 0, count);
|
||||||
|
_TotalBytesRead += count;
|
||||||
|
while (count > 0)
|
||||||
|
{
|
||||||
|
SlurpBlock(buffer, 0, count);
|
||||||
|
count = input.Read(buffer, 0, readSize);
|
||||||
|
if (output != null) output.Write(buffer, 0, count);
|
||||||
|
_TotalBytesRead += count;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (Int32)(~_register);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the CRC32 for the given (word,byte) combo. This is a
|
||||||
|
/// computation defined by PKzip for PKZIP 2.0 (weak) encryption.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="W">The word to start with.</param>
|
||||||
|
/// <param name="B">The byte to combine it with.</param>
|
||||||
|
/// <returns>The CRC-ized result.</returns>
|
||||||
|
public Int32 ComputeCrc32(Int32 W, byte B)
|
||||||
|
{
|
||||||
|
return _InternalComputeCrc32((UInt32)W, B);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal Int32 _InternalComputeCrc32(UInt32 W, byte B)
|
||||||
|
{
|
||||||
|
return (Int32)(crc32Table[(W ^ B) & 0xFF] ^ (W >> 8));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update the value for the running CRC32 using the given block of bytes.
|
||||||
|
/// This is useful when using the CRC32() class in a Stream.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="block">block of bytes to slurp</param>
|
||||||
|
/// <param name="offset">starting point in the block</param>
|
||||||
|
/// <param name="count">how many bytes within the block to slurp</param>
|
||||||
|
public void SlurpBlock(byte[] block, int offset, int count)
|
||||||
|
{
|
||||||
|
if (block == null)
|
||||||
|
throw new Exception("The data buffer must not be null.");
|
||||||
|
|
||||||
|
// bzip algorithm
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
int x = offset + i;
|
||||||
|
byte b = block[x];
|
||||||
|
if (this.reverseBits)
|
||||||
|
{
|
||||||
|
UInt32 temp = (_register >> 24) ^ b;
|
||||||
|
_register = (_register << 8) ^ crc32Table[temp];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UInt32 temp = (_register & 0x000000FF) ^ b;
|
||||||
|
_register = (_register >> 8) ^ crc32Table[temp];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_TotalBytesRead += count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Process one byte in the CRC.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name = "b">the byte to include into the CRC . </param>
|
||||||
|
public void UpdateCRC(byte b)
|
||||||
|
{
|
||||||
|
if (this.reverseBits)
|
||||||
|
{
|
||||||
|
UInt32 temp = (_register >> 24) ^ b;
|
||||||
|
_register = (_register << 8) ^ crc32Table[temp];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UInt32 temp = (_register & 0x000000FF) ^ b;
|
||||||
|
_register = (_register >> 8) ^ crc32Table[temp];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Process a run of N identical bytes into the CRC.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// <para>
|
||||||
|
/// This method serves as an optimization for updating the CRC when a
|
||||||
|
/// run of identical bytes is found. Rather than passing in a buffer of
|
||||||
|
/// length n, containing all identical bytes b, this method accepts the
|
||||||
|
/// byte value and the length of the (virtual) buffer - the length of
|
||||||
|
/// the run.
|
||||||
|
/// </para>
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name = "b">the byte to include into the CRC. </param>
|
||||||
|
/// <param name = "n">the number of times that byte should be repeated. </param>
|
||||||
|
public void UpdateCRC(byte b, int n)
|
||||||
|
{
|
||||||
|
while (n-- > 0)
|
||||||
|
{
|
||||||
|
if (this.reverseBits)
|
||||||
|
{
|
||||||
|
uint temp = (_register >> 24) ^ b;
|
||||||
|
_register = (_register << 8) ^ crc32Table[(temp >= 0)
|
||||||
|
? temp
|
||||||
|
: (temp + 256)];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UInt32 temp = (_register & 0x000000FF) ^ b;
|
||||||
|
_register = (_register >> 8) ^ crc32Table[(temp >= 0)
|
||||||
|
? temp
|
||||||
|
: (temp + 256)];
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private static uint ReverseBits(uint data)
|
||||||
|
{
|
||||||
|
unchecked
|
||||||
|
{
|
||||||
|
uint ret = data;
|
||||||
|
ret = (ret & 0x55555555) << 1 | (ret >> 1) & 0x55555555;
|
||||||
|
ret = (ret & 0x33333333) << 2 | (ret >> 2) & 0x33333333;
|
||||||
|
ret = (ret & 0x0F0F0F0F) << 4 | (ret >> 4) & 0x0F0F0F0F;
|
||||||
|
ret = (ret << 24) | ((ret & 0xFF00) << 8) | ((ret >> 8) & 0xFF00) | (ret >> 24);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte ReverseBits(byte data)
|
||||||
|
{
|
||||||
|
unchecked
|
||||||
|
{
|
||||||
|
uint u = (uint)data * 0x00020202;
|
||||||
|
uint m = 0x01044010;
|
||||||
|
uint s = u & m;
|
||||||
|
uint t = (u << 2) & (m << 1);
|
||||||
|
return (byte)((0x01001001 * (s + t)) >> 24);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void GenerateLookupTable()
|
||||||
|
{
|
||||||
|
crc32Table = new UInt32[256];
|
||||||
|
unchecked
|
||||||
|
{
|
||||||
|
UInt32 dwCrc;
|
||||||
|
byte i = 0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
dwCrc = i;
|
||||||
|
for (byte j = 8; j > 0; j--)
|
||||||
|
{
|
||||||
|
if ((dwCrc & 1) == 1)
|
||||||
|
{
|
||||||
|
dwCrc = (dwCrc >> 1) ^ dwPolynomial;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dwCrc >>= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (reverseBits)
|
||||||
|
{
|
||||||
|
crc32Table[ReverseBits(i)] = ReverseBits(dwCrc);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
crc32Table[i] = dwCrc;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
} while (i!=0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if VERBOSE
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("private static readonly UInt32[] crc32Table = {");
|
||||||
|
for (int i = 0; i < crc32Table.Length; i+=4)
|
||||||
|
{
|
||||||
|
Console.Write(" ");
|
||||||
|
for (int j=0; j < 4; j++)
|
||||||
|
{
|
||||||
|
Console.Write(" 0x{0:X8}U,", crc32Table[i+j]);
|
||||||
|
}
|
||||||
|
Console.WriteLine();
|
||||||
|
}
|
||||||
|
Console.WriteLine("};");
|
||||||
|
Console.WriteLine();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private uint gf2_matrix_times(uint[] matrix, uint vec)
|
||||||
|
{
|
||||||
|
uint sum = 0;
|
||||||
|
int i=0;
|
||||||
|
while (vec != 0)
|
||||||
|
{
|
||||||
|
if ((vec & 0x01)== 0x01)
|
||||||
|
sum ^= matrix[i];
|
||||||
|
vec >>= 1;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void gf2_matrix_square(uint[] square, uint[] mat)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 32; i++)
|
||||||
|
square[i] = gf2_matrix_times(mat, mat[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Combines the given CRC32 value with the current running total.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// This is useful when using a divide-and-conquer approach to
|
||||||
|
/// calculating a CRC. Multiple threads can each calculate a
|
||||||
|
/// CRC32 on a segment of the data, and then combine the
|
||||||
|
/// individual CRC32 values at the end.
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="crc">the crc value to be combined with this one</param>
|
||||||
|
/// <param name="length">the length of data the CRC value was calculated on</param>
|
||||||
|
public void Combine(int crc, int length)
|
||||||
|
{
|
||||||
|
uint[] even = new uint[32]; // even-power-of-two zeros operator
|
||||||
|
uint[] odd = new uint[32]; // odd-power-of-two zeros operator
|
||||||
|
|
||||||
|
if (length == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
uint crc1= ~_register;
|
||||||
|
uint crc2= (uint) crc;
|
||||||
|
|
||||||
|
// put operator for one zero bit in odd
|
||||||
|
odd[0] = this.dwPolynomial; // the CRC-32 polynomial
|
||||||
|
uint row = 1;
|
||||||
|
for (int i = 1; i < 32; i++)
|
||||||
|
{
|
||||||
|
odd[i] = row;
|
||||||
|
row <<= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// put operator for two zero bits in even
|
||||||
|
gf2_matrix_square(even, odd);
|
||||||
|
|
||||||
|
// put operator for four zero bits in odd
|
||||||
|
gf2_matrix_square(odd, even);
|
||||||
|
|
||||||
|
uint len2 = (uint) length;
|
||||||
|
|
||||||
|
// apply len2 zeros to crc1 (first square will put the operator for one
|
||||||
|
// zero byte, eight zero bits, in even)
|
||||||
|
do {
|
||||||
|
// apply zeros operator for this bit of len2
|
||||||
|
gf2_matrix_square(even, odd);
|
||||||
|
|
||||||
|
if ((len2 & 1)== 1)
|
||||||
|
crc1 = gf2_matrix_times(even, crc1);
|
||||||
|
len2 >>= 1;
|
||||||
|
|
||||||
|
if (len2 == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
// another iteration of the loop with odd and even swapped
|
||||||
|
gf2_matrix_square(odd, even);
|
||||||
|
if ((len2 & 1)==1)
|
||||||
|
crc1 = gf2_matrix_times(odd, crc1);
|
||||||
|
len2 >>= 1;
|
||||||
|
|
||||||
|
|
||||||
|
} while (len2 != 0);
|
||||||
|
|
||||||
|
crc1 ^= crc2;
|
||||||
|
|
||||||
|
_register= ~crc1;
|
||||||
|
|
||||||
|
//return (int) crc1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create an instance of the CRC32 class using the default settings: no
|
||||||
|
/// bit reversal, and a polynomial of 0xEDB88320.
|
||||||
|
/// </summary>
|
||||||
|
public CRC32() : this(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create an instance of the CRC32 class, specifying whether to reverse
|
||||||
|
/// data bits or not.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name='reverseBits'>
|
||||||
|
/// specify true if the instance should reverse data bits.
|
||||||
|
/// </param>
|
||||||
|
/// <remarks>
|
||||||
|
/// <para>
|
||||||
|
/// In the CRC-32 used by BZip2, the bits are reversed. Therefore if you
|
||||||
|
/// want a CRC32 with compatibility with BZip2, you should pass true
|
||||||
|
/// here. In the CRC-32 used by GZIP and PKZIP, the bits are not
|
||||||
|
/// reversed; Therefore if you want a CRC32 with compatibility with
|
||||||
|
/// those, you should pass false.
|
||||||
|
/// </para>
|
||||||
|
/// </remarks>
|
||||||
|
public CRC32(bool reverseBits) :
|
||||||
|
this( unchecked((int)0xEDB88320), reverseBits)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create an instance of the CRC32 class, specifying the polynomial and
|
||||||
|
/// whether to reverse data bits or not.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name='polynomial'>
|
||||||
|
/// The polynomial to use for the CRC, expressed in the reversed (LSB)
|
||||||
|
/// format: the highest ordered bit in the polynomial value is the
|
||||||
|
/// coefficient of the 0th power; the second-highest order bit is the
|
||||||
|
/// coefficient of the 1 power, and so on. Expressed this way, the
|
||||||
|
/// polynomial for the CRC-32C used in IEEE 802.3, is 0xEDB88320.
|
||||||
|
/// </param>
|
||||||
|
/// <param name='reverseBits'>
|
||||||
|
/// specify true if the instance should reverse data bits.
|
||||||
|
/// </param>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
/// <para>
|
||||||
|
/// In the CRC-32 used by BZip2, the bits are reversed. Therefore if you
|
||||||
|
/// want a CRC32 with compatibility with BZip2, you should pass true
|
||||||
|
/// here for the <c>reverseBits</c> parameter. In the CRC-32 used by
|
||||||
|
/// GZIP and PKZIP, the bits are not reversed; Therefore if you want a
|
||||||
|
/// CRC32 with compatibility with those, you should pass false for the
|
||||||
|
/// <c>reverseBits</c> parameter.
|
||||||
|
/// </para>
|
||||||
|
/// </remarks>
|
||||||
|
public CRC32(int polynomial, bool reverseBits)
|
||||||
|
{
|
||||||
|
this.reverseBits = reverseBits;
|
||||||
|
this.dwPolynomial = (uint) polynomial;
|
||||||
|
this.GenerateLookupTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reset the CRC-32 class - clear the CRC "remainder register."
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// <para>
|
||||||
|
/// Use this when employing a single instance of this class to compute
|
||||||
|
/// multiple, distinct CRCs on multiple, distinct data blocks.
|
||||||
|
/// </para>
|
||||||
|
/// </remarks>
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
_register = 0xFFFFFFFFU;
|
||||||
|
}
|
||||||
|
|
||||||
|
// private member vars
|
||||||
|
private UInt32 dwPolynomial;
|
||||||
|
private Int64 _TotalBytesRead;
|
||||||
|
private bool reverseBits;
|
||||||
|
private UInt32[] crc32Table;
|
||||||
|
private const int BUFFER_SIZE = 8192;
|
||||||
|
private UInt32 _register = 0xFFFFFFFFU;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 16fc99dd9503b7046bed4bfdbbfec3c0
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
1883
JNFrame/Assets/Plugins/BestHTTP/BestHTTP/Decompression/Deflate.cs
Normal file
1883
JNFrame/Assets/Plugins/BestHTTP/BestHTTP/Decompression/Deflate.cs
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ad45ad0b3a07a2f4181d9f4243b82395
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,692 @@
|
|||||||
|
// DeflateStream.cs
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Copyright (c) 2009-2010 Dino Chiesa.
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This code module is part of DotNetZip, a zipfile class library.
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This code is licensed under the Microsoft Public License.
|
||||||
|
// See the file License.txt for the license details.
|
||||||
|
// More info on: http://dotnetzip.codeplex.com
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// last saved (in emacs):
|
||||||
|
// Time-stamp: <2011-July-31 14:48:11>
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This module defines the DeflateStream class, which can be used as a replacement for
|
||||||
|
// the System.IO.Compression.DeflateStream class in the .NET BCL.
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace BestHTTP.Decompression.Zlib
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A class for compressing and decompressing streams using the Deflate algorithm.
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// The DeflateStream is a <see
|
||||||
|
/// href="http://en.wikipedia.org/wiki/Decorator_pattern">Decorator</see> on a <see
|
||||||
|
/// cref="System.IO.Stream"/>. It adds DEFLATE compression or decompression to any
|
||||||
|
/// stream.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// Using this stream, applications can compress or decompress data via stream
|
||||||
|
/// <c>Read</c> and <c>Write</c> operations. Either compresssion or decompression
|
||||||
|
/// can occur through either reading or writing. The compression format used is
|
||||||
|
/// DEFLATE, which is documented in <see
|
||||||
|
/// href="http://www.ietf.org/rfc/rfc1951.txt">IETF RFC 1951</see>, "DEFLATE
|
||||||
|
/// Compressed Data Format Specification version 1.3.".
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// </remarks>
|
||||||
|
///
|
||||||
|
/// <seealso cref="GZipStream" />
|
||||||
|
public class DeflateStream : System.IO.Stream
|
||||||
|
{
|
||||||
|
internal ZlibBaseStream _baseStream;
|
||||||
|
internal System.IO.Stream _innerStream;
|
||||||
|
bool _disposed;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a DeflateStream using the specified CompressionMode.
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
/// When mode is <c>CompressionMode.Compress</c>, the DeflateStream will use
|
||||||
|
/// the default compression level. The "captive" stream will be closed when
|
||||||
|
/// the DeflateStream is closed.
|
||||||
|
/// </remarks>
|
||||||
|
///
|
||||||
|
/// <example>
|
||||||
|
/// This example uses a DeflateStream to compress data from a file, and writes
|
||||||
|
/// the compressed data to another file.
|
||||||
|
/// <code>
|
||||||
|
/// using (System.IO.Stream input = System.IO.File.OpenRead(fileToCompress))
|
||||||
|
/// {
|
||||||
|
/// using (var raw = System.IO.File.Create(fileToCompress + ".deflated"))
|
||||||
|
/// {
|
||||||
|
/// using (Stream compressor = new DeflateStream(raw, CompressionMode.Compress))
|
||||||
|
/// {
|
||||||
|
/// byte[] buffer = new byte[WORKING_BUFFER_SIZE];
|
||||||
|
/// int n;
|
||||||
|
/// while ((n= input.Read(buffer, 0, buffer.Length)) != 0)
|
||||||
|
/// {
|
||||||
|
/// compressor.Write(buffer, 0, n);
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// </code>
|
||||||
|
///
|
||||||
|
/// <code lang="VB">
|
||||||
|
/// Using input As Stream = File.OpenRead(fileToCompress)
|
||||||
|
/// Using raw As FileStream = File.Create(fileToCompress & ".deflated")
|
||||||
|
/// Using compressor As Stream = New DeflateStream(raw, CompressionMode.Compress)
|
||||||
|
/// Dim buffer As Byte() = New Byte(4096) {}
|
||||||
|
/// Dim n As Integer = -1
|
||||||
|
/// Do While (n <> 0)
|
||||||
|
/// If (n > 0) Then
|
||||||
|
/// compressor.Write(buffer, 0, n)
|
||||||
|
/// End If
|
||||||
|
/// n = input.Read(buffer, 0, buffer.Length)
|
||||||
|
/// Loop
|
||||||
|
/// End Using
|
||||||
|
/// End Using
|
||||||
|
/// End Using
|
||||||
|
/// </code>
|
||||||
|
/// </example>
|
||||||
|
/// <param name="stream">The stream which will be read or written.</param>
|
||||||
|
/// <param name="mode">Indicates whether the DeflateStream will compress or decompress.</param>
|
||||||
|
public DeflateStream(System.IO.Stream stream, CompressionMode mode)
|
||||||
|
: this(stream, mode, CompressionLevel.Default, false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a DeflateStream using the specified CompressionMode and the specified CompressionLevel.
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// When mode is <c>CompressionMode.Decompress</c>, the level parameter is
|
||||||
|
/// ignored. The "captive" stream will be closed when the DeflateStream is
|
||||||
|
/// closed.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// </remarks>
|
||||||
|
///
|
||||||
|
/// <example>
|
||||||
|
///
|
||||||
|
/// This example uses a DeflateStream to compress data from a file, and writes
|
||||||
|
/// the compressed data to another file.
|
||||||
|
///
|
||||||
|
/// <code>
|
||||||
|
/// using (System.IO.Stream input = System.IO.File.OpenRead(fileToCompress))
|
||||||
|
/// {
|
||||||
|
/// using (var raw = System.IO.File.Create(fileToCompress + ".deflated"))
|
||||||
|
/// {
|
||||||
|
/// using (Stream compressor = new DeflateStream(raw,
|
||||||
|
/// CompressionMode.Compress,
|
||||||
|
/// CompressionLevel.BestCompression))
|
||||||
|
/// {
|
||||||
|
/// byte[] buffer = new byte[WORKING_BUFFER_SIZE];
|
||||||
|
/// int n= -1;
|
||||||
|
/// while (n != 0)
|
||||||
|
/// {
|
||||||
|
/// if (n > 0)
|
||||||
|
/// compressor.Write(buffer, 0, n);
|
||||||
|
/// n= input.Read(buffer, 0, buffer.Length);
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// </code>
|
||||||
|
///
|
||||||
|
/// <code lang="VB">
|
||||||
|
/// Using input As Stream = File.OpenRead(fileToCompress)
|
||||||
|
/// Using raw As FileStream = File.Create(fileToCompress & ".deflated")
|
||||||
|
/// Using compressor As Stream = New DeflateStream(raw, CompressionMode.Compress, CompressionLevel.BestCompression)
|
||||||
|
/// Dim buffer As Byte() = New Byte(4096) {}
|
||||||
|
/// Dim n As Integer = -1
|
||||||
|
/// Do While (n <> 0)
|
||||||
|
/// If (n > 0) Then
|
||||||
|
/// compressor.Write(buffer, 0, n)
|
||||||
|
/// End If
|
||||||
|
/// n = input.Read(buffer, 0, buffer.Length)
|
||||||
|
/// Loop
|
||||||
|
/// End Using
|
||||||
|
/// End Using
|
||||||
|
/// End Using
|
||||||
|
/// </code>
|
||||||
|
/// </example>
|
||||||
|
/// <param name="stream">The stream to be read or written while deflating or inflating.</param>
|
||||||
|
/// <param name="mode">Indicates whether the <c>DeflateStream</c> will compress or decompress.</param>
|
||||||
|
/// <param name="level">A tuning knob to trade speed for effectiveness.</param>
|
||||||
|
public DeflateStream(System.IO.Stream stream, CompressionMode mode, CompressionLevel level)
|
||||||
|
: this(stream, mode, level, false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a <c>DeflateStream</c> using the specified
|
||||||
|
/// <c>CompressionMode</c>, and explicitly specify whether the
|
||||||
|
/// stream should be left open after Deflation or Inflation.
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// This constructor allows the application to request that the captive stream
|
||||||
|
/// remain open after the deflation or inflation occurs. By default, after
|
||||||
|
/// <c>Close()</c> is called on the stream, the captive stream is also
|
||||||
|
/// closed. In some cases this is not desired, for example if the stream is a
|
||||||
|
/// memory stream that will be re-read after compression. Specify true for
|
||||||
|
/// the <paramref name="leaveOpen"/> parameter to leave the stream open.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// The <c>DeflateStream</c> will use the default compression level.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// See the other overloads of this constructor for example code.
|
||||||
|
/// </para>
|
||||||
|
/// </remarks>
|
||||||
|
///
|
||||||
|
/// <param name="stream">
|
||||||
|
/// The stream which will be read or written. This is called the
|
||||||
|
/// "captive" stream in other places in this documentation.
|
||||||
|
/// </param>
|
||||||
|
///
|
||||||
|
/// <param name="mode">
|
||||||
|
/// Indicates whether the <c>DeflateStream</c> will compress or decompress.
|
||||||
|
/// </param>
|
||||||
|
///
|
||||||
|
/// <param name="leaveOpen">true if the application would like the stream to
|
||||||
|
/// remain open after inflation/deflation.</param>
|
||||||
|
public DeflateStream(System.IO.Stream stream, CompressionMode mode, bool leaveOpen)
|
||||||
|
: this(stream, mode, CompressionLevel.Default, leaveOpen)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a <c>DeflateStream</c> using the specified <c>CompressionMode</c>
|
||||||
|
/// and the specified <c>CompressionLevel</c>, and explicitly specify whether
|
||||||
|
/// the stream should be left open after Deflation or Inflation.
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// When mode is <c>CompressionMode.Decompress</c>, the level parameter is ignored.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// This constructor allows the application to request that the captive stream
|
||||||
|
/// remain open after the deflation or inflation occurs. By default, after
|
||||||
|
/// <c>Close()</c> is called on the stream, the captive stream is also
|
||||||
|
/// closed. In some cases this is not desired, for example if the stream is a
|
||||||
|
/// <see cref="System.IO.MemoryStream"/> that will be re-read after
|
||||||
|
/// compression. Specify true for the <paramref name="leaveOpen"/> parameter
|
||||||
|
/// to leave the stream open.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// </remarks>
|
||||||
|
///
|
||||||
|
/// <example>
|
||||||
|
///
|
||||||
|
/// This example shows how to use a <c>DeflateStream</c> to compress data from
|
||||||
|
/// a file, and store the compressed data into another file.
|
||||||
|
///
|
||||||
|
/// <code>
|
||||||
|
/// using (var output = System.IO.File.Create(fileToCompress + ".deflated"))
|
||||||
|
/// {
|
||||||
|
/// using (System.IO.Stream input = System.IO.File.OpenRead(fileToCompress))
|
||||||
|
/// {
|
||||||
|
/// using (Stream compressor = new DeflateStream(output, CompressionMode.Compress, CompressionLevel.BestCompression, true))
|
||||||
|
/// {
|
||||||
|
/// byte[] buffer = new byte[WORKING_BUFFER_SIZE];
|
||||||
|
/// int n= -1;
|
||||||
|
/// while (n != 0)
|
||||||
|
/// {
|
||||||
|
/// if (n > 0)
|
||||||
|
/// compressor.Write(buffer, 0, n);
|
||||||
|
/// n= input.Read(buffer, 0, buffer.Length);
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// // can write additional data to the output stream here
|
||||||
|
/// }
|
||||||
|
/// </code>
|
||||||
|
///
|
||||||
|
/// <code lang="VB">
|
||||||
|
/// Using output As FileStream = File.Create(fileToCompress & ".deflated")
|
||||||
|
/// Using input As Stream = File.OpenRead(fileToCompress)
|
||||||
|
/// Using compressor As Stream = New DeflateStream(output, CompressionMode.Compress, CompressionLevel.BestCompression, True)
|
||||||
|
/// Dim buffer As Byte() = New Byte(4096) {}
|
||||||
|
/// Dim n As Integer = -1
|
||||||
|
/// Do While (n <> 0)
|
||||||
|
/// If (n > 0) Then
|
||||||
|
/// compressor.Write(buffer, 0, n)
|
||||||
|
/// End If
|
||||||
|
/// n = input.Read(buffer, 0, buffer.Length)
|
||||||
|
/// Loop
|
||||||
|
/// End Using
|
||||||
|
/// End Using
|
||||||
|
/// ' can write additional data to the output stream here.
|
||||||
|
/// End Using
|
||||||
|
/// </code>
|
||||||
|
/// </example>
|
||||||
|
/// <param name="stream">The stream which will be read or written.</param>
|
||||||
|
/// <param name="mode">Indicates whether the DeflateStream will compress or decompress.</param>
|
||||||
|
/// <param name="leaveOpen">true if the application would like the stream to remain open after inflation/deflation.</param>
|
||||||
|
/// <param name="level">A tuning knob to trade speed for effectiveness.</param>
|
||||||
|
public DeflateStream(System.IO.Stream stream, CompressionMode mode, CompressionLevel level, bool leaveOpen)
|
||||||
|
{
|
||||||
|
_innerStream = stream;
|
||||||
|
_baseStream = new ZlibBaseStream(stream, mode, level, ZlibStreamFlavor.DEFLATE, leaveOpen);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a <c>DeflateStream</c> using the specified <c>CompressionMode</c>
|
||||||
|
/// and the specified <c>CompressionLevel</c>, and explicitly specify whether
|
||||||
|
/// the stream should be left open after Deflation or Inflation.
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// When mode is <c>CompressionMode.Decompress</c>, the level parameter is ignored.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// This constructor allows the application to request that the captive stream
|
||||||
|
/// remain open after the deflation or inflation occurs. By default, after
|
||||||
|
/// <c>Close()</c> is called on the stream, the captive stream is also
|
||||||
|
/// closed. In some cases this is not desired, for example if the stream is a
|
||||||
|
/// <see cref="System.IO.MemoryStream"/> that will be re-read after
|
||||||
|
/// compression. Specify true for the <paramref name="leaveOpen"/> parameter
|
||||||
|
/// to leave the stream open.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// </remarks>
|
||||||
|
///
|
||||||
|
/// <example>
|
||||||
|
///
|
||||||
|
/// This example shows how to use a <c>DeflateStream</c> to compress data from
|
||||||
|
/// a file, and store the compressed data into another file.
|
||||||
|
///
|
||||||
|
/// <code>
|
||||||
|
/// using (var output = System.IO.File.Create(fileToCompress + ".deflated"))
|
||||||
|
/// {
|
||||||
|
/// using (System.IO.Stream input = System.IO.File.OpenRead(fileToCompress))
|
||||||
|
/// {
|
||||||
|
/// using (Stream compressor = new DeflateStream(output, CompressionMode.Compress, CompressionLevel.BestCompression, true))
|
||||||
|
/// {
|
||||||
|
/// byte[] buffer = new byte[WORKING_BUFFER_SIZE];
|
||||||
|
/// int n= -1;
|
||||||
|
/// while (n != 0)
|
||||||
|
/// {
|
||||||
|
/// if (n > 0)
|
||||||
|
/// compressor.Write(buffer, 0, n);
|
||||||
|
/// n= input.Read(buffer, 0, buffer.Length);
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// // can write additional data to the output stream here
|
||||||
|
/// }
|
||||||
|
/// </code>
|
||||||
|
///
|
||||||
|
/// <code lang="VB">
|
||||||
|
/// Using output As FileStream = File.Create(fileToCompress & ".deflated")
|
||||||
|
/// Using input As Stream = File.OpenRead(fileToCompress)
|
||||||
|
/// Using compressor As Stream = New DeflateStream(output, CompressionMode.Compress, CompressionLevel.BestCompression, True)
|
||||||
|
/// Dim buffer As Byte() = New Byte(4096) {}
|
||||||
|
/// Dim n As Integer = -1
|
||||||
|
/// Do While (n <> 0)
|
||||||
|
/// If (n > 0) Then
|
||||||
|
/// compressor.Write(buffer, 0, n)
|
||||||
|
/// End If
|
||||||
|
/// n = input.Read(buffer, 0, buffer.Length)
|
||||||
|
/// Loop
|
||||||
|
/// End Using
|
||||||
|
/// End Using
|
||||||
|
/// ' can write additional data to the output stream here.
|
||||||
|
/// End Using
|
||||||
|
/// </code>
|
||||||
|
/// </example>
|
||||||
|
/// <param name="stream">The stream which will be read or written.</param>
|
||||||
|
/// <param name="mode">Indicates whether the DeflateStream will compress or decompress.</param>
|
||||||
|
/// <param name="leaveOpen">true if the application would like the stream to remain open after inflation/deflation.</param>
|
||||||
|
/// <param name="level">A tuning knob to trade speed for effectiveness.</param>
|
||||||
|
/// <param name="windowBits">Desired window bits.</param>
|
||||||
|
public DeflateStream(System.IO.Stream stream, CompressionMode mode, CompressionLevel level, bool leaveOpen, int windowBits)
|
||||||
|
{
|
||||||
|
_innerStream = stream;
|
||||||
|
_baseStream = new ZlibBaseStream(stream, mode, level, ZlibStreamFlavor.DEFLATE, leaveOpen, windowBits);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Zlib properties
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This property sets the flush behavior on the stream.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks> See the ZLIB documentation for the meaning of the flush behavior.
|
||||||
|
/// </remarks>
|
||||||
|
virtual public FlushType FlushMode
|
||||||
|
{
|
||||||
|
get { return (this._baseStream._flushMode); }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_disposed) throw new ObjectDisposedException("DeflateStream");
|
||||||
|
this._baseStream._flushMode = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The size of the working buffer for the compression codec.
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
/// <para>
|
||||||
|
/// The working buffer is used for all stream operations. The default size is
|
||||||
|
/// 1024 bytes. The minimum size is 128 bytes. You may get better performance
|
||||||
|
/// with a larger buffer. Then again, you might not. You would have to test
|
||||||
|
/// it.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// Set this before the first call to <c>Read()</c> or <c>Write()</c> on the
|
||||||
|
/// stream. If you try to set it afterwards, it will throw.
|
||||||
|
/// </para>
|
||||||
|
/// </remarks>
|
||||||
|
public int BufferSize
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._baseStream._bufferSize;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_disposed) throw new ObjectDisposedException("DeflateStream");
|
||||||
|
if (this._baseStream._workingBuffer != null)
|
||||||
|
throw new ZlibException("The working buffer is already set.");
|
||||||
|
if (value < ZlibConstants.WorkingBufferSizeMin)
|
||||||
|
throw new ZlibException(String.Format("Don't be silly. {0} bytes?? Use a bigger buffer, at least {1}.", value, ZlibConstants.WorkingBufferSizeMin));
|
||||||
|
this._baseStream._bufferSize = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The ZLIB strategy to be used during compression.
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
/// By tweaking this parameter, you may be able to optimize the compression for
|
||||||
|
/// data with particular characteristics.
|
||||||
|
/// </remarks>
|
||||||
|
public CompressionStrategy Strategy
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._baseStream.Strategy;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_disposed) throw new ObjectDisposedException("DeflateStream");
|
||||||
|
this._baseStream.Strategy = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Returns the total number of bytes input so far.</summary>
|
||||||
|
virtual public long TotalIn
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._baseStream._z.TotalBytesIn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Returns the total number of bytes output so far.</summary>
|
||||||
|
virtual public long TotalOut
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._baseStream._z.TotalBytesOut;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region System.IO.Stream methods
|
||||||
|
/// <summary>
|
||||||
|
/// Dispose the stream.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// <para>
|
||||||
|
/// This may or may not result in a <c>Close()</c> call on the captive
|
||||||
|
/// stream. See the constructors that have a <c>leaveOpen</c> parameter
|
||||||
|
/// for more information.
|
||||||
|
/// </para>
|
||||||
|
/// <para>
|
||||||
|
/// Application code won't call this code directly. This method may be
|
||||||
|
/// invoked in two distinct scenarios. If disposing == true, the method
|
||||||
|
/// has been called directly or indirectly by a user's code, for example
|
||||||
|
/// via the public Dispose() method. In this case, both managed and
|
||||||
|
/// unmanaged resources can be referenced and disposed. If disposing ==
|
||||||
|
/// false, the method has been called by the runtime from inside the
|
||||||
|
/// object finalizer and this method should not reference other objects;
|
||||||
|
/// in that case only unmanaged resources must be referenced or
|
||||||
|
/// disposed.
|
||||||
|
/// </para>
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="disposing">
|
||||||
|
/// true if the Dispose method was invoked by user code.
|
||||||
|
/// </param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!_disposed)
|
||||||
|
{
|
||||||
|
if (disposing && (this._baseStream != null))
|
||||||
|
this._baseStream.Close();
|
||||||
|
_disposed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates whether the stream can be read.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The return value depends on whether the captive stream supports reading.
|
||||||
|
/// </remarks>
|
||||||
|
public override bool CanRead
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_disposed) throw new ObjectDisposedException("DeflateStream");
|
||||||
|
return _baseStream._stream.CanRead;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates whether the stream supports Seek operations.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Always returns false.
|
||||||
|
/// </remarks>
|
||||||
|
public override bool CanSeek
|
||||||
|
{
|
||||||
|
get { return false; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates whether the stream can be written.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The return value depends on whether the captive stream supports writing.
|
||||||
|
/// </remarks>
|
||||||
|
public override bool CanWrite
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_disposed) throw new ObjectDisposedException("DeflateStream");
|
||||||
|
return _baseStream._stream.CanWrite;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Flush the stream.
|
||||||
|
/// </summary>
|
||||||
|
public override void Flush()
|
||||||
|
{
|
||||||
|
if (_disposed) throw new ObjectDisposedException("DeflateStream");
|
||||||
|
_baseStream.Flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reading this property always throws a <see cref="NotImplementedException"/>.
|
||||||
|
/// </summary>
|
||||||
|
public override long Length
|
||||||
|
{
|
||||||
|
get { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The position of the stream pointer.
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
/// Setting this property always throws a <see
|
||||||
|
/// cref="NotImplementedException"/>. Reading will return the total bytes
|
||||||
|
/// written out, if used in writing, or the total bytes read in, if used in
|
||||||
|
/// reading. The count may refer to compressed bytes or uncompressed bytes,
|
||||||
|
/// depending on how you've used the stream.
|
||||||
|
/// </remarks>
|
||||||
|
public override long Position
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (this._baseStream._streamMode == BestHTTP.Decompression.Zlib.ZlibBaseStream.StreamMode.Writer)
|
||||||
|
return this._baseStream._z.TotalBytesOut;
|
||||||
|
if (this._baseStream._streamMode == BestHTTP.Decompression.Zlib.ZlibBaseStream.StreamMode.Reader)
|
||||||
|
return this._baseStream._z.TotalBytesIn;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
set { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Read data from the stream.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// If you wish to use the <c>DeflateStream</c> to compress data while
|
||||||
|
/// reading, you can create a <c>DeflateStream</c> with
|
||||||
|
/// <c>CompressionMode.Compress</c>, providing an uncompressed data stream.
|
||||||
|
/// Then call Read() on that <c>DeflateStream</c>, and the data read will be
|
||||||
|
/// compressed as you read. If you wish to use the <c>DeflateStream</c> to
|
||||||
|
/// decompress data while reading, you can create a <c>DeflateStream</c> with
|
||||||
|
/// <c>CompressionMode.Decompress</c>, providing a readable compressed data
|
||||||
|
/// stream. Then call Read() on that <c>DeflateStream</c>, and the data read
|
||||||
|
/// will be decompressed as you read.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// A <c>DeflateStream</c> can be used for <c>Read()</c> or <c>Write()</c>, but not both.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="buffer">The buffer into which the read data should be placed.</param>
|
||||||
|
/// <param name="offset">the offset within that data array to put the first byte read.</param>
|
||||||
|
/// <param name="count">the number of bytes to read.</param>
|
||||||
|
/// <returns>the number of bytes actually read</returns>
|
||||||
|
public override int Read(byte[] buffer, int offset, int count)
|
||||||
|
{
|
||||||
|
if (_disposed) throw new ObjectDisposedException("DeflateStream");
|
||||||
|
return _baseStream.Read(buffer, offset, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Calling this method always throws a <see cref="NotImplementedException"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="offset">this is irrelevant, since it will always throw!</param>
|
||||||
|
/// <param name="origin">this is irrelevant, since it will always throw!</param>
|
||||||
|
/// <returns>irrelevant!</returns>
|
||||||
|
public override long Seek(long offset, System.IO.SeekOrigin origin)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Will call the base stream's SetLength method.
|
||||||
|
/// </summary>
|
||||||
|
public override void SetLength(long value)
|
||||||
|
{
|
||||||
|
_baseStream.SetLength(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Write data to the stream.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// If you wish to use the <c>DeflateStream</c> to compress data while
|
||||||
|
/// writing, you can create a <c>DeflateStream</c> with
|
||||||
|
/// <c>CompressionMode.Compress</c>, and a writable output stream. Then call
|
||||||
|
/// <c>Write()</c> on that <c>DeflateStream</c>, providing uncompressed data
|
||||||
|
/// as input. The data sent to the output stream will be the compressed form
|
||||||
|
/// of the data written. If you wish to use the <c>DeflateStream</c> to
|
||||||
|
/// decompress data while writing, you can create a <c>DeflateStream</c> with
|
||||||
|
/// <c>CompressionMode.Decompress</c>, and a writable output stream. Then
|
||||||
|
/// call <c>Write()</c> on that stream, providing previously compressed
|
||||||
|
/// data. The data sent to the output stream will be the decompressed form of
|
||||||
|
/// the data written.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// A <c>DeflateStream</c> can be used for <c>Read()</c> or <c>Write()</c>,
|
||||||
|
/// but not both.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// </remarks>
|
||||||
|
///
|
||||||
|
/// <param name="buffer">The buffer holding data to write to the stream.</param>
|
||||||
|
/// <param name="offset">the offset within that data array to find the first byte to write.</param>
|
||||||
|
/// <param name="count">the number of bytes to write.</param>
|
||||||
|
public override void Write(byte[] buffer, int offset, int count)
|
||||||
|
{
|
||||||
|
if (_disposed) throw new ObjectDisposedException("DeflateStream");
|
||||||
|
_baseStream.Write(buffer, offset, count);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8b7a3b80f9aa82941a62c619c263ff5e
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,919 @@
|
|||||||
|
// GZipStream.cs
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Copyright (c) 2009 Dino Chiesa and Microsoft Corporation.
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This code module is part of DotNetZip, a zipfile class library.
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This code is licensed under the Microsoft Public License.
|
||||||
|
// See the file License.txt for the license details.
|
||||||
|
// More info on: http://dotnetzip.codeplex.com
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// last saved (in emacs):
|
||||||
|
// Time-stamp: <2011-July-11 21:42:34>
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This module defines the GZipStream class, which can be used as a replacement for
|
||||||
|
// the System.IO.Compression.GZipStream class in the .NET BCL. NB: The design is not
|
||||||
|
// completely OO clean: there is some intelligence in the ZlibBaseStream that reads the
|
||||||
|
// GZip header.
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace BestHTTP.Decompression.Zlib
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A class for compressing and decompressing GZIP streams.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// The <c>GZipStream</c> is a <see
|
||||||
|
/// href="http://en.wikipedia.org/wiki/Decorator_pattern">Decorator</see> on a
|
||||||
|
/// <see cref="Stream"/>. It adds GZIP compression or decompression to any
|
||||||
|
/// stream.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// Like the <c>System.IO.Compression.GZipStream</c> in the .NET Base Class Library, the
|
||||||
|
/// <c>Ionic.Zlib.GZipStream</c> can compress while writing, or decompress while
|
||||||
|
/// reading, but not vice versa. The compression method used is GZIP, which is
|
||||||
|
/// documented in <see href="http://www.ietf.org/rfc/rfc1952.txt">IETF RFC
|
||||||
|
/// 1952</see>, "GZIP file format specification version 4.3".</para>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// A <c>GZipStream</c> can be used to decompress data (through <c>Read()</c>) or
|
||||||
|
/// to compress data (through <c>Write()</c>), but not both.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// If you wish to use the <c>GZipStream</c> to compress data, you must wrap it
|
||||||
|
/// around a write-able stream. As you call <c>Write()</c> on the <c>GZipStream</c>, the
|
||||||
|
/// data will be compressed into the GZIP format. If you want to decompress data,
|
||||||
|
/// you must wrap the <c>GZipStream</c> around a readable stream that contains an
|
||||||
|
/// IETF RFC 1952-compliant stream. The data will be decompressed as you call
|
||||||
|
/// <c>Read()</c> on the <c>GZipStream</c>.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// Though the GZIP format allows data from multiple files to be concatenated
|
||||||
|
/// together, this stream handles only a single segment of GZIP format, typically
|
||||||
|
/// representing a single file.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// </remarks>
|
||||||
|
///
|
||||||
|
/// <seealso cref="DeflateStream" />
|
||||||
|
public class GZipStream : System.IO.Stream
|
||||||
|
{
|
||||||
|
// GZip format
|
||||||
|
// source: http://tools.ietf.org/html/rfc1952
|
||||||
|
//
|
||||||
|
// header id: 2 bytes 1F 8B
|
||||||
|
// compress method 1 byte 8= DEFLATE (none other supported)
|
||||||
|
// flag 1 byte bitfield (See below)
|
||||||
|
// mtime 4 bytes time_t (seconds since jan 1, 1970 UTC of the file.
|
||||||
|
// xflg 1 byte 2 = max compress used , 4 = max speed (can be ignored)
|
||||||
|
// OS 1 byte OS for originating archive. set to 0xFF in compression.
|
||||||
|
// extra field length 2 bytes optional - only if FEXTRA is set.
|
||||||
|
// extra field varies
|
||||||
|
// filename varies optional - if FNAME is set. zero terminated. ISO-8859-1.
|
||||||
|
// file comment varies optional - if FCOMMENT is set. zero terminated. ISO-8859-1.
|
||||||
|
// crc16 1 byte optional - present only if FHCRC bit is set
|
||||||
|
// compressed data varies
|
||||||
|
// CRC32 4 bytes
|
||||||
|
// isize 4 bytes data size modulo 2^32
|
||||||
|
//
|
||||||
|
// FLG (FLaGs)
|
||||||
|
// bit 0 FTEXT - indicates file is ASCII text (can be safely ignored)
|
||||||
|
// bit 1 FHCRC - there is a CRC16 for the header immediately following the header
|
||||||
|
// bit 2 FEXTRA - extra fields are present
|
||||||
|
// bit 3 FNAME - the zero-terminated filename is present. encoding; ISO-8859-1.
|
||||||
|
// bit 4 FCOMMENT - a zero-terminated file comment is present. encoding: ISO-8859-1
|
||||||
|
// bit 5 reserved
|
||||||
|
// bit 6 reserved
|
||||||
|
// bit 7 reserved
|
||||||
|
//
|
||||||
|
// On consumption:
|
||||||
|
// Extra field is a bunch of nonsense and can be safely ignored.
|
||||||
|
// Header CRC and OS, likewise.
|
||||||
|
//
|
||||||
|
// on generation:
|
||||||
|
// all optional fields get 0, except for the OS, which gets 255.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The comment on the GZIP stream.
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
/// <para>
|
||||||
|
/// The GZIP format allows for each file to optionally have an associated
|
||||||
|
/// comment stored with the file. The comment is encoded with the ISO-8859-1
|
||||||
|
/// code page. To include a comment in a GZIP stream you create, set this
|
||||||
|
/// property before calling <c>Write()</c> for the first time on the
|
||||||
|
/// <c>GZipStream</c>.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// When using <c>GZipStream</c> to decompress, you can retrieve this property
|
||||||
|
/// after the first call to <c>Read()</c>. If no comment has been set in the
|
||||||
|
/// GZIP bytestream, the Comment property will return <c>null</c>
|
||||||
|
/// (<c>Nothing</c> in VB).
|
||||||
|
/// </para>
|
||||||
|
/// </remarks>
|
||||||
|
public String Comment
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _Comment;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_disposed) throw new ObjectDisposedException("GZipStream");
|
||||||
|
_Comment = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The FileName for the GZIP stream.
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// The GZIP format optionally allows each file to have an associated
|
||||||
|
/// filename. When compressing data (through <c>Write()</c>), set this
|
||||||
|
/// FileName before calling <c>Write()</c> the first time on the <c>GZipStream</c>.
|
||||||
|
/// The actual filename is encoded into the GZIP bytestream with the
|
||||||
|
/// ISO-8859-1 code page, according to RFC 1952. It is the application's
|
||||||
|
/// responsibility to insure that the FileName can be encoded and decoded
|
||||||
|
/// correctly with this code page.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// When decompressing (through <c>Read()</c>), you can retrieve this value
|
||||||
|
/// any time after the first <c>Read()</c>. In the case where there was no filename
|
||||||
|
/// encoded into the GZIP bytestream, the property will return <c>null</c> (<c>Nothing</c>
|
||||||
|
/// in VB).
|
||||||
|
/// </para>
|
||||||
|
/// </remarks>
|
||||||
|
public String FileName
|
||||||
|
{
|
||||||
|
get { return _FileName; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_disposed) throw new ObjectDisposedException("GZipStream");
|
||||||
|
_FileName = value;
|
||||||
|
if (_FileName == null) return;
|
||||||
|
if (_FileName.IndexOf("/") != -1)
|
||||||
|
{
|
||||||
|
_FileName = _FileName.Replace("/", "\\");
|
||||||
|
}
|
||||||
|
if (_FileName.EndsWith("\\"))
|
||||||
|
throw new Exception("Illegal filename");
|
||||||
|
if (_FileName.IndexOf("\\") != -1)
|
||||||
|
{
|
||||||
|
// trim any leading path
|
||||||
|
_FileName = Path.GetFileName(_FileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The last modified time for the GZIP stream.
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
/// GZIP allows the storage of a last modified time with each GZIP entity.
|
||||||
|
/// When compressing data, you can set this before the first call to
|
||||||
|
/// <c>Write()</c>. When decompressing, you can retrieve this value any time
|
||||||
|
/// after the first call to <c>Read()</c>.
|
||||||
|
/// </remarks>
|
||||||
|
public DateTime? LastModified;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The CRC on the GZIP stream.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// This is used for internal error checking. You probably don't need to look at this property.
|
||||||
|
/// </remarks>
|
||||||
|
public int Crc32 { get { return _Crc32; } }
|
||||||
|
|
||||||
|
private int _headerByteCount;
|
||||||
|
internal ZlibBaseStream _baseStream;
|
||||||
|
bool _disposed;
|
||||||
|
bool _firstReadDone;
|
||||||
|
string _FileName;
|
||||||
|
string _Comment;
|
||||||
|
int _Crc32;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a <c>GZipStream</c> using the specified <c>CompressionMode</c>.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// When mode is <c>CompressionMode.Compress</c>, the <c>GZipStream</c> will use the
|
||||||
|
/// default compression level.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// As noted in the class documentation, the <c>CompressionMode</c> (Compress
|
||||||
|
/// or Decompress) also establishes the "direction" of the stream. A
|
||||||
|
/// <c>GZipStream</c> with <c>CompressionMode.Compress</c> works only through
|
||||||
|
/// <c>Write()</c>. A <c>GZipStream</c> with
|
||||||
|
/// <c>CompressionMode.Decompress</c> works only through <c>Read()</c>.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// </remarks>
|
||||||
|
///
|
||||||
|
/// <example>
|
||||||
|
/// This example shows how to use a GZipStream to compress data.
|
||||||
|
/// <code>
|
||||||
|
/// using (System.IO.Stream input = System.IO.File.OpenRead(fileToCompress))
|
||||||
|
/// {
|
||||||
|
/// using (var raw = System.IO.File.Create(outputFile))
|
||||||
|
/// {
|
||||||
|
/// using (Stream compressor = new GZipStream(raw, CompressionMode.Compress))
|
||||||
|
/// {
|
||||||
|
/// byte[] buffer = new byte[WORKING_BUFFER_SIZE];
|
||||||
|
/// int n;
|
||||||
|
/// while ((n= input.Read(buffer, 0, buffer.Length)) != 0)
|
||||||
|
/// {
|
||||||
|
/// compressor.Write(buffer, 0, n);
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// </code>
|
||||||
|
/// <code lang="VB">
|
||||||
|
/// Dim outputFile As String = (fileToCompress & ".compressed")
|
||||||
|
/// Using input As Stream = File.OpenRead(fileToCompress)
|
||||||
|
/// Using raw As FileStream = File.Create(outputFile)
|
||||||
|
/// Using compressor As Stream = New GZipStream(raw, CompressionMode.Compress)
|
||||||
|
/// Dim buffer As Byte() = New Byte(4096) {}
|
||||||
|
/// Dim n As Integer = -1
|
||||||
|
/// Do While (n <> 0)
|
||||||
|
/// If (n > 0) Then
|
||||||
|
/// compressor.Write(buffer, 0, n)
|
||||||
|
/// End If
|
||||||
|
/// n = input.Read(buffer, 0, buffer.Length)
|
||||||
|
/// Loop
|
||||||
|
/// End Using
|
||||||
|
/// End Using
|
||||||
|
/// End Using
|
||||||
|
/// </code>
|
||||||
|
/// </example>
|
||||||
|
///
|
||||||
|
/// <example>
|
||||||
|
/// This example shows how to use a GZipStream to uncompress a file.
|
||||||
|
/// <code>
|
||||||
|
/// private void GunZipFile(string filename)
|
||||||
|
/// {
|
||||||
|
/// if (!filename.EndsWith(".gz))
|
||||||
|
/// throw new ArgumentException("filename");
|
||||||
|
/// var DecompressedFile = filename.Substring(0,filename.Length-3);
|
||||||
|
/// byte[] working = new byte[WORKING_BUFFER_SIZE];
|
||||||
|
/// int n= 1;
|
||||||
|
/// using (System.IO.Stream input = System.IO.File.OpenRead(filename))
|
||||||
|
/// {
|
||||||
|
/// using (Stream decompressor= new Ionic.Zlib.GZipStream(input, CompressionMode.Decompress, true))
|
||||||
|
/// {
|
||||||
|
/// using (var output = System.IO.File.Create(DecompressedFile))
|
||||||
|
/// {
|
||||||
|
/// while (n !=0)
|
||||||
|
/// {
|
||||||
|
/// n= decompressor.Read(working, 0, working.Length);
|
||||||
|
/// if (n > 0)
|
||||||
|
/// {
|
||||||
|
/// output.Write(working, 0, n);
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// </code>
|
||||||
|
///
|
||||||
|
/// <code lang="VB">
|
||||||
|
/// Private Sub GunZipFile(ByVal filename as String)
|
||||||
|
/// If Not (filename.EndsWith(".gz)) Then
|
||||||
|
/// Throw New ArgumentException("filename")
|
||||||
|
/// End If
|
||||||
|
/// Dim DecompressedFile as String = filename.Substring(0,filename.Length-3)
|
||||||
|
/// Dim working(WORKING_BUFFER_SIZE) as Byte
|
||||||
|
/// Dim n As Integer = 1
|
||||||
|
/// Using input As Stream = File.OpenRead(filename)
|
||||||
|
/// Using decompressor As Stream = new Ionic.Zlib.GZipStream(input, CompressionMode.Decompress, True)
|
||||||
|
/// Using output As Stream = File.Create(UncompressedFile)
|
||||||
|
/// Do
|
||||||
|
/// n= decompressor.Read(working, 0, working.Length)
|
||||||
|
/// If n > 0 Then
|
||||||
|
/// output.Write(working, 0, n)
|
||||||
|
/// End IF
|
||||||
|
/// Loop While (n > 0)
|
||||||
|
/// End Using
|
||||||
|
/// End Using
|
||||||
|
/// End Using
|
||||||
|
/// End Sub
|
||||||
|
/// </code>
|
||||||
|
/// </example>
|
||||||
|
///
|
||||||
|
/// <param name="stream">The stream which will be read or written.</param>
|
||||||
|
/// <param name="mode">Indicates whether the GZipStream will compress or decompress.</param>
|
||||||
|
public GZipStream(Stream stream, CompressionMode mode)
|
||||||
|
: this(stream, mode, CompressionLevel.Default, false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a <c>GZipStream</c> using the specified <c>CompressionMode</c> and
|
||||||
|
/// the specified <c>CompressionLevel</c>.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// The <c>CompressionMode</c> (Compress or Decompress) also establishes the
|
||||||
|
/// "direction" of the stream. A <c>GZipStream</c> with
|
||||||
|
/// <c>CompressionMode.Compress</c> works only through <c>Write()</c>. A
|
||||||
|
/// <c>GZipStream</c> with <c>CompressionMode.Decompress</c> works only
|
||||||
|
/// through <c>Read()</c>.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// </remarks>
|
||||||
|
///
|
||||||
|
/// <example>
|
||||||
|
///
|
||||||
|
/// This example shows how to use a <c>GZipStream</c> to compress a file into a .gz file.
|
||||||
|
///
|
||||||
|
/// <code>
|
||||||
|
/// using (System.IO.Stream input = System.IO.File.OpenRead(fileToCompress))
|
||||||
|
/// {
|
||||||
|
/// using (var raw = System.IO.File.Create(fileToCompress + ".gz"))
|
||||||
|
/// {
|
||||||
|
/// using (Stream compressor = new GZipStream(raw,
|
||||||
|
/// CompressionMode.Compress,
|
||||||
|
/// CompressionLevel.BestCompression))
|
||||||
|
/// {
|
||||||
|
/// byte[] buffer = new byte[WORKING_BUFFER_SIZE];
|
||||||
|
/// int n;
|
||||||
|
/// while ((n= input.Read(buffer, 0, buffer.Length)) != 0)
|
||||||
|
/// {
|
||||||
|
/// compressor.Write(buffer, 0, n);
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// </code>
|
||||||
|
///
|
||||||
|
/// <code lang="VB">
|
||||||
|
/// Using input As Stream = File.OpenRead(fileToCompress)
|
||||||
|
/// Using raw As FileStream = File.Create(fileToCompress & ".gz")
|
||||||
|
/// Using compressor As Stream = New GZipStream(raw, CompressionMode.Compress, CompressionLevel.BestCompression)
|
||||||
|
/// Dim buffer As Byte() = New Byte(4096) {}
|
||||||
|
/// Dim n As Integer = -1
|
||||||
|
/// Do While (n <> 0)
|
||||||
|
/// If (n > 0) Then
|
||||||
|
/// compressor.Write(buffer, 0, n)
|
||||||
|
/// End If
|
||||||
|
/// n = input.Read(buffer, 0, buffer.Length)
|
||||||
|
/// Loop
|
||||||
|
/// End Using
|
||||||
|
/// End Using
|
||||||
|
/// End Using
|
||||||
|
/// </code>
|
||||||
|
/// </example>
|
||||||
|
/// <param name="stream">The stream to be read or written while deflating or inflating.</param>
|
||||||
|
/// <param name="mode">Indicates whether the <c>GZipStream</c> will compress or decompress.</param>
|
||||||
|
/// <param name="level">A tuning knob to trade speed for effectiveness.</param>
|
||||||
|
public GZipStream(Stream stream, CompressionMode mode, CompressionLevel level)
|
||||||
|
: this(stream, mode, level, false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a <c>GZipStream</c> using the specified <c>CompressionMode</c>, and
|
||||||
|
/// explicitly specify whether the stream should be left open after Deflation
|
||||||
|
/// or Inflation.
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
/// <para>
|
||||||
|
/// This constructor allows the application to request that the captive stream
|
||||||
|
/// remain open after the deflation or inflation occurs. By default, after
|
||||||
|
/// <c>Close()</c> is called on the stream, the captive stream is also
|
||||||
|
/// closed. In some cases this is not desired, for example if the stream is a
|
||||||
|
/// memory stream that will be re-read after compressed data has been written
|
||||||
|
/// to it. Specify true for the <paramref name="leaveOpen"/> parameter to leave
|
||||||
|
/// the stream open.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// The <see cref="CompressionMode"/> (Compress or Decompress) also
|
||||||
|
/// establishes the "direction" of the stream. A <c>GZipStream</c> with
|
||||||
|
/// <c>CompressionMode.Compress</c> works only through <c>Write()</c>. A <c>GZipStream</c>
|
||||||
|
/// with <c>CompressionMode.Decompress</c> works only through <c>Read()</c>.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// The <c>GZipStream</c> will use the default compression level. If you want
|
||||||
|
/// to specify the compression level, see <see cref="GZipStream(Stream,
|
||||||
|
/// CompressionMode, CompressionLevel, bool)"/>.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// See the other overloads of this constructor for example code.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// </remarks>
|
||||||
|
///
|
||||||
|
/// <param name="stream">
|
||||||
|
/// The stream which will be read or written. This is called the "captive"
|
||||||
|
/// stream in other places in this documentation.
|
||||||
|
/// </param>
|
||||||
|
///
|
||||||
|
/// <param name="mode">Indicates whether the GZipStream will compress or decompress.
|
||||||
|
/// </param>
|
||||||
|
///
|
||||||
|
/// <param name="leaveOpen">
|
||||||
|
/// true if the application would like the base stream to remain open after
|
||||||
|
/// inflation/deflation.
|
||||||
|
/// </param>
|
||||||
|
public GZipStream(Stream stream, CompressionMode mode, bool leaveOpen)
|
||||||
|
: this(stream, mode, CompressionLevel.Default, leaveOpen)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a <c>GZipStream</c> using the specified <c>CompressionMode</c> and the
|
||||||
|
/// specified <c>CompressionLevel</c>, and explicitly specify whether the
|
||||||
|
/// stream should be left open after Deflation or Inflation.
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// This constructor allows the application to request that the captive stream
|
||||||
|
/// remain open after the deflation or inflation occurs. By default, after
|
||||||
|
/// <c>Close()</c> is called on the stream, the captive stream is also
|
||||||
|
/// closed. In some cases this is not desired, for example if the stream is a
|
||||||
|
/// memory stream that will be re-read after compressed data has been written
|
||||||
|
/// to it. Specify true for the <paramref name="leaveOpen"/> parameter to
|
||||||
|
/// leave the stream open.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// As noted in the class documentation, the <c>CompressionMode</c> (Compress
|
||||||
|
/// or Decompress) also establishes the "direction" of the stream. A
|
||||||
|
/// <c>GZipStream</c> with <c>CompressionMode.Compress</c> works only through
|
||||||
|
/// <c>Write()</c>. A <c>GZipStream</c> with <c>CompressionMode.Decompress</c> works only
|
||||||
|
/// through <c>Read()</c>.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// </remarks>
|
||||||
|
///
|
||||||
|
/// <example>
|
||||||
|
/// This example shows how to use a <c>GZipStream</c> to compress data.
|
||||||
|
/// <code>
|
||||||
|
/// using (System.IO.Stream input = System.IO.File.OpenRead(fileToCompress))
|
||||||
|
/// {
|
||||||
|
/// using (var raw = System.IO.File.Create(outputFile))
|
||||||
|
/// {
|
||||||
|
/// using (Stream compressor = new GZipStream(raw, CompressionMode.Compress, CompressionLevel.BestCompression, true))
|
||||||
|
/// {
|
||||||
|
/// byte[] buffer = new byte[WORKING_BUFFER_SIZE];
|
||||||
|
/// int n;
|
||||||
|
/// while ((n= input.Read(buffer, 0, buffer.Length)) != 0)
|
||||||
|
/// {
|
||||||
|
/// compressor.Write(buffer, 0, n);
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// </code>
|
||||||
|
/// <code lang="VB">
|
||||||
|
/// Dim outputFile As String = (fileToCompress & ".compressed")
|
||||||
|
/// Using input As Stream = File.OpenRead(fileToCompress)
|
||||||
|
/// Using raw As FileStream = File.Create(outputFile)
|
||||||
|
/// Using compressor As Stream = New GZipStream(raw, CompressionMode.Compress, CompressionLevel.BestCompression, True)
|
||||||
|
/// Dim buffer As Byte() = New Byte(4096) {}
|
||||||
|
/// Dim n As Integer = -1
|
||||||
|
/// Do While (n <> 0)
|
||||||
|
/// If (n > 0) Then
|
||||||
|
/// compressor.Write(buffer, 0, n)
|
||||||
|
/// End If
|
||||||
|
/// n = input.Read(buffer, 0, buffer.Length)
|
||||||
|
/// Loop
|
||||||
|
/// End Using
|
||||||
|
/// End Using
|
||||||
|
/// End Using
|
||||||
|
/// </code>
|
||||||
|
/// </example>
|
||||||
|
/// <param name="stream">The stream which will be read or written.</param>
|
||||||
|
/// <param name="mode">Indicates whether the GZipStream will compress or decompress.</param>
|
||||||
|
/// <param name="leaveOpen">true if the application would like the stream to remain open after inflation/deflation.</param>
|
||||||
|
/// <param name="level">A tuning knob to trade speed for effectiveness.</param>
|
||||||
|
public GZipStream(Stream stream, CompressionMode mode, CompressionLevel level, bool leaveOpen)
|
||||||
|
{
|
||||||
|
_baseStream = new ZlibBaseStream(stream, mode, level, ZlibStreamFlavor.GZIP, leaveOpen);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Zlib properties
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This property sets the flush behavior on the stream.
|
||||||
|
/// </summary>
|
||||||
|
virtual public FlushType FlushMode
|
||||||
|
{
|
||||||
|
get { return (this._baseStream._flushMode); }
|
||||||
|
set {
|
||||||
|
if (_disposed) throw new ObjectDisposedException("GZipStream");
|
||||||
|
this._baseStream._flushMode = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The size of the working buffer for the compression codec.
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
/// <para>
|
||||||
|
/// The working buffer is used for all stream operations. The default size is
|
||||||
|
/// 1024 bytes. The minimum size is 128 bytes. You may get better performance
|
||||||
|
/// with a larger buffer. Then again, you might not. You would have to test
|
||||||
|
/// it.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// Set this before the first call to <c>Read()</c> or <c>Write()</c> on the
|
||||||
|
/// stream. If you try to set it afterwards, it will throw.
|
||||||
|
/// </para>
|
||||||
|
/// </remarks>
|
||||||
|
public int BufferSize
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._baseStream._bufferSize;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_disposed) throw new ObjectDisposedException("GZipStream");
|
||||||
|
if (this._baseStream._workingBuffer != null)
|
||||||
|
throw new ZlibException("The working buffer is already set.");
|
||||||
|
if (value < ZlibConstants.WorkingBufferSizeMin)
|
||||||
|
throw new ZlibException(String.Format("Don't be silly. {0} bytes?? Use a bigger buffer, at least {1}.", value, ZlibConstants.WorkingBufferSizeMin));
|
||||||
|
this._baseStream._bufferSize = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary> Returns the total number of bytes input so far.</summary>
|
||||||
|
virtual public long TotalIn
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._baseStream._z.TotalBytesIn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> Returns the total number of bytes output so far.</summary>
|
||||||
|
virtual public long TotalOut
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._baseStream._z.TotalBytesOut;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Stream methods
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Dispose the stream.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// <para>
|
||||||
|
/// This may or may not result in a <c>Close()</c> call on the captive
|
||||||
|
/// stream. See the constructors that have a <c>leaveOpen</c> parameter
|
||||||
|
/// for more information.
|
||||||
|
/// </para>
|
||||||
|
/// <para>
|
||||||
|
/// This method may be invoked in two distinct scenarios. If disposing
|
||||||
|
/// == true, the method has been called directly or indirectly by a
|
||||||
|
/// user's code, for example via the public Dispose() method. In this
|
||||||
|
/// case, both managed and unmanaged resources can be referenced and
|
||||||
|
/// disposed. If disposing == false, the method has been called by the
|
||||||
|
/// runtime from inside the object finalizer and this method should not
|
||||||
|
/// reference other objects; in that case only unmanaged resources must
|
||||||
|
/// be referenced or disposed.
|
||||||
|
/// </para>
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="disposing">
|
||||||
|
/// indicates whether the Dispose method was invoked by user code.
|
||||||
|
/// </param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!_disposed)
|
||||||
|
{
|
||||||
|
if (disposing && (this._baseStream != null))
|
||||||
|
{
|
||||||
|
this._baseStream.Close();
|
||||||
|
this._Crc32 = _baseStream.Crc32;
|
||||||
|
}
|
||||||
|
_disposed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates whether the stream can be read.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The return value depends on whether the captive stream supports reading.
|
||||||
|
/// </remarks>
|
||||||
|
public override bool CanRead
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_disposed) throw new ObjectDisposedException("GZipStream");
|
||||||
|
return _baseStream._stream.CanRead;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates whether the stream supports Seek operations.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Always returns false.
|
||||||
|
/// </remarks>
|
||||||
|
public override bool CanSeek
|
||||||
|
{
|
||||||
|
get { return false; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates whether the stream can be written.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The return value depends on whether the captive stream supports writing.
|
||||||
|
/// </remarks>
|
||||||
|
public override bool CanWrite
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_disposed) throw new ObjectDisposedException("GZipStream");
|
||||||
|
return _baseStream._stream.CanWrite;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Flush the stream.
|
||||||
|
/// </summary>
|
||||||
|
public override void Flush()
|
||||||
|
{
|
||||||
|
if (_disposed) throw new ObjectDisposedException("GZipStream");
|
||||||
|
_baseStream.Flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reading this property always throws a <see cref="NotImplementedException"/>.
|
||||||
|
/// </summary>
|
||||||
|
public override long Length
|
||||||
|
{
|
||||||
|
get { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The position of the stream pointer.
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
/// Setting this property always throws a <see
|
||||||
|
/// cref="NotImplementedException"/>. Reading will return the total bytes
|
||||||
|
/// written out, if used in writing, or the total bytes read in, if used in
|
||||||
|
/// reading. The count may refer to compressed bytes or uncompressed bytes,
|
||||||
|
/// depending on how you've used the stream.
|
||||||
|
/// </remarks>
|
||||||
|
public override long Position
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (this._baseStream._streamMode == BestHTTP.Decompression.Zlib.ZlibBaseStream.StreamMode.Writer)
|
||||||
|
return this._baseStream._z.TotalBytesOut + _headerByteCount;
|
||||||
|
if (this._baseStream._streamMode == BestHTTP.Decompression.Zlib.ZlibBaseStream.StreamMode.Reader)
|
||||||
|
return this._baseStream._z.TotalBytesIn + this._baseStream._gzipHeaderByteCount;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
set { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Read and decompress data from the source stream.
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
/// With a <c>GZipStream</c>, decompression is done through reading.
|
||||||
|
/// </remarks>
|
||||||
|
///
|
||||||
|
/// <example>
|
||||||
|
/// <code>
|
||||||
|
/// byte[] working = new byte[WORKING_BUFFER_SIZE];
|
||||||
|
/// using (System.IO.Stream input = System.IO.File.OpenRead(_CompressedFile))
|
||||||
|
/// {
|
||||||
|
/// using (Stream decompressor= new Ionic.Zlib.GZipStream(input, CompressionMode.Decompress, true))
|
||||||
|
/// {
|
||||||
|
/// using (var output = System.IO.File.Create(_DecompressedFile))
|
||||||
|
/// {
|
||||||
|
/// int n;
|
||||||
|
/// while ((n= decompressor.Read(working, 0, working.Length)) !=0)
|
||||||
|
/// {
|
||||||
|
/// output.Write(working, 0, n);
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// </code>
|
||||||
|
/// </example>
|
||||||
|
/// <param name="buffer">The buffer into which the decompressed data should be placed.</param>
|
||||||
|
/// <param name="offset">the offset within that data array to put the first byte read.</param>
|
||||||
|
/// <param name="count">the number of bytes to read.</param>
|
||||||
|
/// <returns>the number of bytes actually read</returns>
|
||||||
|
public override int Read(byte[] buffer, int offset, int count)
|
||||||
|
{
|
||||||
|
if (_disposed) throw new ObjectDisposedException("GZipStream");
|
||||||
|
int n = _baseStream.Read(buffer, offset, count);
|
||||||
|
|
||||||
|
// Console.WriteLine("GZipStream::Read(buffer, off({0}), c({1}) = {2}", offset, count, n);
|
||||||
|
// Console.WriteLine( Util.FormatByteArray(buffer, offset, n) );
|
||||||
|
|
||||||
|
if (!_firstReadDone)
|
||||||
|
{
|
||||||
|
_firstReadDone = true;
|
||||||
|
FileName = _baseStream._GzipFileName;
|
||||||
|
Comment = _baseStream._GzipComment;
|
||||||
|
}
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Calling this method always throws a <see cref="NotImplementedException"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="offset">irrelevant; it will always throw!</param>
|
||||||
|
/// <param name="origin">irrelevant; it will always throw!</param>
|
||||||
|
/// <returns>irrelevant!</returns>
|
||||||
|
public override long Seek(long offset, SeekOrigin origin)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Calling this method always throws a <see cref="NotImplementedException"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">irrelevant; this method will always throw!</param>
|
||||||
|
public override void SetLength(long value)
|
||||||
|
{
|
||||||
|
//throw new NotImplementedException();
|
||||||
|
_baseStream.SetLength(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Write data to the stream.
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
/// <para>
|
||||||
|
/// If you wish to use the <c>GZipStream</c> to compress data while writing,
|
||||||
|
/// you can create a <c>GZipStream</c> with <c>CompressionMode.Compress</c>, and a
|
||||||
|
/// writable output stream. Then call <c>Write()</c> on that <c>GZipStream</c>,
|
||||||
|
/// providing uncompressed data as input. The data sent to the output stream
|
||||||
|
/// will be the compressed form of the data written.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// A <c>GZipStream</c> can be used for <c>Read()</c> or <c>Write()</c>, but not
|
||||||
|
/// both. Writing implies compression. Reading implies decompression.
|
||||||
|
/// </para>
|
||||||
|
///
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="buffer">The buffer holding data to write to the stream.</param>
|
||||||
|
/// <param name="offset">the offset within that data array to find the first byte to write.</param>
|
||||||
|
/// <param name="count">the number of bytes to write.</param>
|
||||||
|
public override void Write(byte[] buffer, int offset, int count)
|
||||||
|
{
|
||||||
|
if (_disposed) throw new ObjectDisposedException("GZipStream");
|
||||||
|
if (_baseStream._streamMode == BestHTTP.Decompression.Zlib.ZlibBaseStream.StreamMode.Undefined)
|
||||||
|
{
|
||||||
|
//Console.WriteLine("GZipStream: First write");
|
||||||
|
if (_baseStream._wantCompress)
|
||||||
|
{
|
||||||
|
// first write in compression, therefore, emit the GZIP header
|
||||||
|
_headerByteCount = EmitHeader();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_baseStream.Write(buffer, offset, count);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
internal static readonly System.DateTime _unixEpoch = new System.DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||||
|
internal static readonly System.Text.Encoding iso8859dash1 = System.Text.Encoding.GetEncoding("iso-8859-1");
|
||||||
|
|
||||||
|
|
||||||
|
private int EmitHeader()
|
||||||
|
{
|
||||||
|
byte[] commentBytes = (Comment == null) ? null : iso8859dash1.GetBytes(Comment);
|
||||||
|
byte[] filenameBytes = (FileName == null) ? null : iso8859dash1.GetBytes(FileName);
|
||||||
|
|
||||||
|
int cbLength = (Comment == null) ? 0 : commentBytes.Length + 1;
|
||||||
|
int fnLength = (FileName == null) ? 0 : filenameBytes.Length + 1;
|
||||||
|
|
||||||
|
int bufferLength = 10 + cbLength + fnLength;
|
||||||
|
byte[] header = Extensions.VariableSizedBufferPool.Get(bufferLength, false);
|
||||||
|
int i = 0;
|
||||||
|
// ID
|
||||||
|
header[i++] = 0x1F;
|
||||||
|
header[i++] = 0x8B;
|
||||||
|
|
||||||
|
// compression method
|
||||||
|
header[i++] = 8;
|
||||||
|
byte flag = 0;
|
||||||
|
if (Comment != null)
|
||||||
|
flag ^= 0x10;
|
||||||
|
if (FileName != null)
|
||||||
|
flag ^= 0x8;
|
||||||
|
|
||||||
|
// flag
|
||||||
|
header[i++] = flag;
|
||||||
|
|
||||||
|
// mtime
|
||||||
|
if (!LastModified.HasValue) LastModified = DateTime.Now;
|
||||||
|
System.TimeSpan delta = LastModified.Value - _unixEpoch;
|
||||||
|
Int32 timet = (Int32)delta.TotalSeconds;
|
||||||
|
Array.Copy(BitConverter.GetBytes(timet), 0, header, i, 4);
|
||||||
|
i += 4;
|
||||||
|
|
||||||
|
// xflg
|
||||||
|
header[i++] = 0; // this field is totally useless
|
||||||
|
// OS
|
||||||
|
header[i++] = 0xFF; // 0xFF == unspecified
|
||||||
|
|
||||||
|
// extra field length - only if FEXTRA is set, which it is not.
|
||||||
|
//header[i++]= 0;
|
||||||
|
//header[i++]= 0;
|
||||||
|
|
||||||
|
// filename
|
||||||
|
if (fnLength != 0)
|
||||||
|
{
|
||||||
|
Array.Copy(filenameBytes, 0, header, i, fnLength - 1);
|
||||||
|
i += fnLength - 1;
|
||||||
|
header[i++] = 0; // terminate
|
||||||
|
}
|
||||||
|
|
||||||
|
// comment
|
||||||
|
if (cbLength != 0)
|
||||||
|
{
|
||||||
|
Array.Copy(commentBytes, 0, header, i, cbLength - 1);
|
||||||
|
i += cbLength - 1;
|
||||||
|
header[i++] = 0; // terminate
|
||||||
|
}
|
||||||
|
|
||||||
|
_baseStream._stream.Write(header, 0, header.Length);
|
||||||
|
int headerLength = header.Length;
|
||||||
|
|
||||||
|
Extensions.VariableSizedBufferPool.Release(header);
|
||||||
|
|
||||||
|
return headerLength; // bytes written
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: be79ee53ca164d04cbbb654f7de657f5
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,436 @@
|
|||||||
|
// Inftree.cs
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Copyright (c) 2009 Dino Chiesa and Microsoft Corporation.
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This code module is part of DotNetZip, a zipfile class library.
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This code is licensed under the Microsoft Public License.
|
||||||
|
// See the file License.txt for the license details.
|
||||||
|
// More info on: http://dotnetzip.codeplex.com
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// last saved (in emacs):
|
||||||
|
// Time-stamp: <2009-October-28 12:43:54>
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This module defines classes used in decompression. This code is derived
|
||||||
|
// from the jzlib implementation of zlib. In keeping with the license for jzlib,
|
||||||
|
// the copyright to that code is below.
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer in
|
||||||
|
// the documentation and/or other materials provided with the distribution.
|
||||||
|
//
|
||||||
|
// 3. The names of the authors may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||||
|
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
||||||
|
// INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||||
|
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||||
|
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This program is based on zlib-1.1.3; credit to authors
|
||||||
|
// Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
|
||||||
|
// and contributors of zlib.
|
||||||
|
//
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
namespace BestHTTP.Decompression.Zlib
|
||||||
|
{
|
||||||
|
|
||||||
|
sealed class InfTree
|
||||||
|
{
|
||||||
|
|
||||||
|
private const int MANY = 1440;
|
||||||
|
|
||||||
|
private const int Z_OK = 0;
|
||||||
|
private const int Z_STREAM_END = 1;
|
||||||
|
private const int Z_NEED_DICT = 2;
|
||||||
|
private const int Z_ERRNO = - 1;
|
||||||
|
private const int Z_STREAM_ERROR = - 2;
|
||||||
|
private const int Z_DATA_ERROR = - 3;
|
||||||
|
private const int Z_MEM_ERROR = - 4;
|
||||||
|
private const int Z_BUF_ERROR = - 5;
|
||||||
|
private const int Z_VERSION_ERROR = - 6;
|
||||||
|
|
||||||
|
internal const int fixed_bl = 9;
|
||||||
|
internal const int fixed_bd = 5;
|
||||||
|
|
||||||
|
//UPGRADE_NOTE: Final was removed from the declaration of 'fixed_tl'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
|
||||||
|
internal static readonly int[] fixed_tl = new int[]{96, 7, 256, 0, 8, 80, 0, 8, 16, 84, 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, 9, 192, 80, 7, 10, 0, 8, 96, 0, 8, 32, 0, 9, 160, 0, 8, 0, 0, 8, 128, 0, 8, 64, 0, 9, 224, 80, 7, 6, 0, 8, 88, 0, 8, 24, 0, 9, 144, 83, 7, 59, 0, 8, 120, 0, 8, 56, 0, 9, 208, 81, 7, 17, 0, 8, 104, 0, 8, 40, 0, 9, 176, 0, 8, 8, 0, 8, 136, 0, 8, 72, 0, 9, 240, 80, 7, 4, 0, 8, 84, 0, 8, 20, 85, 8, 227, 83, 7, 43, 0, 8, 116, 0, 8, 52, 0, 9, 200, 81, 7, 13, 0, 8, 100, 0, 8, 36, 0, 9, 168, 0, 8, 4, 0, 8, 132, 0, 8, 68, 0, 9, 232, 80, 7, 8, 0, 8, 92, 0, 8, 28, 0, 9, 152, 84, 7, 83, 0, 8, 124, 0, 8, 60, 0, 9, 216, 82, 7, 23, 0, 8, 108, 0, 8, 44, 0, 9, 184, 0, 8, 12, 0, 8, 140, 0, 8, 76, 0, 9, 248, 80, 7, 3, 0, 8, 82, 0, 8, 18, 85, 8, 163, 83, 7, 35, 0, 8, 114, 0, 8, 50, 0, 9, 196, 81, 7, 11, 0, 8, 98, 0, 8, 34, 0, 9, 164, 0, 8, 2, 0, 8, 130, 0, 8, 66, 0, 9, 228, 80, 7, 7, 0, 8, 90, 0, 8, 26, 0, 9, 148, 84, 7, 67, 0, 8, 122, 0, 8, 58, 0, 9, 212, 82, 7, 19, 0, 8, 106, 0, 8, 42, 0, 9, 180, 0, 8, 10, 0, 8, 138, 0, 8, 74, 0, 9, 244, 80, 7, 5, 0, 8, 86, 0, 8, 22, 192, 8, 0, 83, 7, 51, 0, 8, 118, 0, 8, 54, 0, 9, 204, 81, 7, 15, 0, 8, 102, 0, 8, 38, 0, 9, 172, 0, 8, 6, 0, 8, 134, 0, 8, 70, 0, 9, 236, 80, 7, 9, 0, 8, 94, 0, 8, 30, 0, 9, 156, 84, 7, 99, 0, 8, 126, 0, 8, 62, 0, 9, 220, 82, 7, 27, 0, 8, 110, 0, 8, 46, 0, 9, 188, 0, 8, 14, 0, 8, 142, 0, 8, 78, 0, 9, 252, 96, 7, 256, 0, 8, 81, 0, 8, 17, 85, 8, 131, 82, 7, 31, 0, 8, 113, 0, 8, 49, 0, 9, 194, 80, 7, 10, 0, 8, 97, 0, 8, 33, 0, 9, 162, 0, 8, 1, 0, 8, 129, 0, 8, 65, 0, 9, 226, 80, 7, 6, 0, 8, 89, 0, 8, 25, 0, 9, 146, 83, 7, 59, 0, 8, 121, 0, 8, 57, 0, 9, 210, 81, 7, 17, 0, 8, 105, 0, 8, 41, 0, 9, 178, 0, 8, 9, 0, 8, 137, 0, 8, 73, 0, 9, 242, 80, 7, 4, 0, 8, 85, 0, 8, 21, 80, 8, 258, 83, 7, 43, 0, 8, 117, 0, 8, 53, 0, 9, 202, 81, 7, 13, 0, 8, 101, 0, 8, 37, 0, 9, 170, 0, 8, 5, 0, 8, 133, 0, 8, 69, 0, 9, 234, 80, 7, 8, 0, 8, 93, 0, 8, 29, 0, 9, 154, 84, 7, 83, 0, 8, 125, 0, 8, 61, 0, 9, 218, 82, 7, 23, 0, 8, 109, 0, 8, 45, 0, 9, 186,
|
||||||
|
0, 8, 13, 0, 8, 141, 0, 8, 77, 0, 9, 250, 80, 7, 3, 0, 8, 83, 0, 8, 19, 85, 8, 195, 83, 7, 35, 0, 8, 115, 0, 8, 51, 0, 9, 198, 81, 7, 11, 0, 8, 99, 0, 8, 35, 0, 9, 166, 0, 8, 3, 0, 8, 131, 0, 8, 67, 0, 9, 230, 80, 7, 7, 0, 8, 91, 0, 8, 27, 0, 9, 150, 84, 7, 67, 0, 8, 123, 0, 8, 59, 0, 9, 214, 82, 7, 19, 0, 8, 107, 0, 8, 43, 0, 9, 182, 0, 8, 11, 0, 8, 139, 0, 8, 75, 0, 9, 246, 80, 7, 5, 0, 8, 87, 0, 8, 23, 192, 8, 0, 83, 7, 51, 0, 8, 119, 0, 8, 55, 0, 9, 206, 81, 7, 15, 0, 8, 103, 0, 8, 39, 0, 9, 174, 0, 8, 7, 0, 8, 135, 0, 8, 71, 0, 9, 238, 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, 9, 158, 84, 7, 99, 0, 8, 127, 0, 8, 63, 0, 9, 222, 82, 7, 27, 0, 8, 111, 0, 8, 47, 0, 9, 190, 0, 8, 15, 0, 8, 143, 0, 8, 79, 0, 9, 254, 96, 7, 256, 0, 8, 80, 0, 8, 16, 84, 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, 9, 193, 80, 7, 10, 0, 8, 96, 0, 8, 32, 0, 9, 161, 0, 8, 0, 0, 8, 128, 0, 8, 64, 0, 9, 225, 80, 7, 6, 0, 8, 88, 0, 8, 24, 0, 9, 145, 83, 7, 59, 0, 8, 120, 0, 8, 56, 0, 9, 209, 81, 7, 17, 0, 8, 104, 0, 8, 40, 0, 9, 177, 0, 8, 8, 0, 8, 136, 0, 8, 72, 0, 9, 241, 80, 7, 4, 0, 8, 84, 0, 8, 20, 85, 8, 227, 83, 7, 43, 0, 8, 116, 0, 8, 52, 0, 9, 201, 81, 7, 13, 0, 8, 100, 0, 8, 36, 0, 9, 169, 0, 8, 4, 0, 8, 132, 0, 8, 68, 0, 9, 233, 80, 7, 8, 0, 8, 92, 0, 8, 28, 0, 9, 153, 84, 7, 83, 0, 8, 124, 0, 8, 60, 0, 9, 217, 82, 7, 23, 0, 8, 108, 0, 8, 44, 0, 9, 185, 0, 8, 12, 0, 8, 140, 0, 8, 76, 0, 9, 249, 80, 7, 3, 0, 8, 82, 0, 8, 18, 85, 8, 163, 83, 7, 35, 0, 8, 114, 0, 8, 50, 0, 9, 197, 81, 7, 11, 0, 8, 98, 0, 8, 34, 0, 9, 165, 0, 8, 2, 0, 8, 130, 0, 8, 66, 0, 9, 229, 80, 7, 7, 0, 8, 90, 0, 8, 26, 0, 9, 149, 84, 7, 67, 0, 8, 122, 0, 8, 58, 0, 9, 213, 82, 7, 19, 0, 8, 106, 0, 8, 42, 0, 9, 181, 0, 8, 10, 0, 8, 138, 0, 8, 74, 0, 9, 245, 80, 7, 5, 0, 8, 86, 0, 8, 22, 192, 8, 0, 83, 7, 51, 0, 8, 118, 0, 8, 54, 0, 9, 205, 81, 7, 15, 0, 8, 102, 0, 8, 38, 0, 9, 173, 0, 8, 6, 0, 8, 134, 0, 8, 70, 0, 9, 237, 80, 7, 9, 0, 8, 94, 0, 8, 30, 0, 9, 157, 84, 7, 99, 0, 8, 126, 0, 8, 62, 0, 9, 221, 82, 7, 27, 0, 8, 110, 0, 8, 46, 0, 9, 189, 0, 8,
|
||||||
|
14, 0, 8, 142, 0, 8, 78, 0, 9, 253, 96, 7, 256, 0, 8, 81, 0, 8, 17, 85, 8, 131, 82, 7, 31, 0, 8, 113, 0, 8, 49, 0, 9, 195, 80, 7, 10, 0, 8, 97, 0, 8, 33, 0, 9, 163, 0, 8, 1, 0, 8, 129, 0, 8, 65, 0, 9, 227, 80, 7, 6, 0, 8, 89, 0, 8, 25, 0, 9, 147, 83, 7, 59, 0, 8, 121, 0, 8, 57, 0, 9, 211, 81, 7, 17, 0, 8, 105, 0, 8, 41, 0, 9, 179, 0, 8, 9, 0, 8, 137, 0, 8, 73, 0, 9, 243, 80, 7, 4, 0, 8, 85, 0, 8, 21, 80, 8, 258, 83, 7, 43, 0, 8, 117, 0, 8, 53, 0, 9, 203, 81, 7, 13, 0, 8, 101, 0, 8, 37, 0, 9, 171, 0, 8, 5, 0, 8, 133, 0, 8, 69, 0, 9, 235, 80, 7, 8, 0, 8, 93, 0, 8, 29, 0, 9, 155, 84, 7, 83, 0, 8, 125, 0, 8, 61, 0, 9, 219, 82, 7, 23, 0, 8, 109, 0, 8, 45, 0, 9, 187, 0, 8, 13, 0, 8, 141, 0, 8, 77, 0, 9, 251, 80, 7, 3, 0, 8, 83, 0, 8, 19, 85, 8, 195, 83, 7, 35, 0, 8, 115, 0, 8, 51, 0, 9, 199, 81, 7, 11, 0, 8, 99, 0, 8, 35, 0, 9, 167, 0, 8, 3, 0, 8, 131, 0, 8, 67, 0, 9, 231, 80, 7, 7, 0, 8, 91, 0, 8, 27, 0, 9, 151, 84, 7, 67, 0, 8, 123, 0, 8, 59, 0, 9, 215, 82, 7, 19, 0, 8, 107, 0, 8, 43, 0, 9, 183, 0, 8, 11, 0, 8, 139, 0, 8, 75, 0, 9, 247, 80, 7, 5, 0, 8, 87, 0, 8, 23, 192, 8, 0, 83, 7, 51, 0, 8, 119, 0, 8, 55, 0, 9, 207, 81, 7, 15, 0, 8, 103, 0, 8, 39, 0, 9, 175, 0, 8, 7, 0, 8, 135, 0, 8, 71, 0, 9, 239, 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, 9, 159, 84, 7, 99, 0, 8, 127, 0, 8, 63, 0, 9, 223, 82, 7, 27, 0, 8, 111, 0, 8, 47, 0, 9, 191, 0, 8, 15, 0, 8, 143, 0, 8, 79, 0, 9, 255};
|
||||||
|
//UPGRADE_NOTE: Final was removed from the declaration of 'fixed_td'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
|
||||||
|
internal static readonly int[] fixed_td = new int[]{80, 5, 1, 87, 5, 257, 83, 5, 17, 91, 5, 4097, 81, 5, 5, 89, 5, 1025, 85, 5, 65, 93, 5, 16385, 80, 5, 3, 88, 5, 513, 84, 5, 33, 92, 5, 8193, 82, 5, 9, 90, 5, 2049, 86, 5, 129, 192, 5, 24577, 80, 5, 2, 87, 5, 385, 83, 5, 25, 91, 5, 6145, 81, 5, 7, 89, 5, 1537, 85, 5, 97, 93, 5, 24577, 80, 5, 4, 88, 5, 769, 84, 5, 49, 92, 5, 12289, 82, 5, 13, 90, 5, 3073, 86, 5, 193, 192, 5, 24577};
|
||||||
|
|
||||||
|
// Tables for deflate from PKZIP's appnote.txt.
|
||||||
|
//UPGRADE_NOTE: Final was removed from the declaration of 'cplens'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
|
||||||
|
internal static readonly int[] cplens = new int[]{3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
|
||||||
|
|
||||||
|
// see note #13 above about 258
|
||||||
|
//UPGRADE_NOTE: Final was removed from the declaration of 'cplext'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
|
||||||
|
internal static readonly int[] cplext = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112};
|
||||||
|
|
||||||
|
//UPGRADE_NOTE: Final was removed from the declaration of 'cpdist'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
|
||||||
|
internal static readonly int[] cpdist = new int[]{1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577};
|
||||||
|
|
||||||
|
//UPGRADE_NOTE: Final was removed from the declaration of 'cpdext'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
|
||||||
|
internal static readonly int[] cpdext = new int[]{0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13};
|
||||||
|
|
||||||
|
// If BMAX needs to be larger than 16, then h and x[] should be uLong.
|
||||||
|
internal const int BMAX = 15; // maximum bit length of any code
|
||||||
|
|
||||||
|
internal int[] hn = null; // hufts used in space
|
||||||
|
internal int[] v = null; // work area for huft_build
|
||||||
|
internal int[] c = null; // bit length count table
|
||||||
|
internal int[] r = null; // table entity for structure assignment
|
||||||
|
internal int[] u = null; // table stack
|
||||||
|
internal int[] x = null; // bit offsets, then code stack
|
||||||
|
|
||||||
|
private int huft_build(int[] b, int bindex, int n, int s, int[] d, int[] e, int[] t, int[] m, int[] hp, int[] hn, int[] v)
|
||||||
|
{
|
||||||
|
// Given a list of code lengths and a maximum table size, make a set of
|
||||||
|
// tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR
|
||||||
|
// if the given code set is incomplete (the tables are still built in this
|
||||||
|
// case), Z_DATA_ERROR if the input is invalid (an over-subscribed set of
|
||||||
|
// lengths), or Z_MEM_ERROR if not enough memory.
|
||||||
|
|
||||||
|
int a; // counter for codes of length k
|
||||||
|
int f; // i repeats in table every f entries
|
||||||
|
int g; // maximum code length
|
||||||
|
int h; // table level
|
||||||
|
int i; // counter, current code
|
||||||
|
int j; // counter
|
||||||
|
int k; // number of bits in current code
|
||||||
|
int l; // bits per table (returned in m)
|
||||||
|
int mask; // (1 << w) - 1, to avoid cc -O bug on HP
|
||||||
|
int p; // pointer into c[], b[], or v[]
|
||||||
|
int q; // points to current table
|
||||||
|
int w; // bits before this table == (l * h)
|
||||||
|
int xp; // pointer into x
|
||||||
|
int y; // number of dummy codes added
|
||||||
|
int z; // number of entries in current table
|
||||||
|
|
||||||
|
// Generate counts for each bit length
|
||||||
|
|
||||||
|
p = 0; i = n;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
c[b[bindex + p]]++; p++; i--; // assume all entries <= BMAX
|
||||||
|
}
|
||||||
|
while (i != 0);
|
||||||
|
|
||||||
|
if (c[0] == n)
|
||||||
|
{
|
||||||
|
// null input--all zero length codes
|
||||||
|
t[0] = - 1;
|
||||||
|
m[0] = 0;
|
||||||
|
return Z_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find minimum and maximum length, bound *m by those
|
||||||
|
l = m[0];
|
||||||
|
for (j = 1; j <= BMAX; j++)
|
||||||
|
if (c[j] != 0)
|
||||||
|
break;
|
||||||
|
k = j; // minimum code length
|
||||||
|
if (l < j)
|
||||||
|
{
|
||||||
|
l = j;
|
||||||
|
}
|
||||||
|
for (i = BMAX; i != 0; i--)
|
||||||
|
{
|
||||||
|
if (c[i] != 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
g = i; // maximum code length
|
||||||
|
if (l > i)
|
||||||
|
{
|
||||||
|
l = i;
|
||||||
|
}
|
||||||
|
m[0] = l;
|
||||||
|
|
||||||
|
// Adjust last length count to fill out codes, if needed
|
||||||
|
for (y = 1 << j; j < i; j++, y <<= 1)
|
||||||
|
{
|
||||||
|
if ((y -= c[j]) < 0)
|
||||||
|
{
|
||||||
|
return Z_DATA_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((y -= c[i]) < 0)
|
||||||
|
{
|
||||||
|
return Z_DATA_ERROR;
|
||||||
|
}
|
||||||
|
c[i] += y;
|
||||||
|
|
||||||
|
// Generate starting offsets into the value table for each length
|
||||||
|
x[1] = j = 0;
|
||||||
|
p = 1; xp = 2;
|
||||||
|
while (--i != 0)
|
||||||
|
{
|
||||||
|
// note that i == g from above
|
||||||
|
x[xp] = (j += c[p]);
|
||||||
|
xp++;
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make a table of values in order of bit lengths
|
||||||
|
i = 0; p = 0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if ((j = b[bindex + p]) != 0)
|
||||||
|
{
|
||||||
|
v[x[j]++] = i;
|
||||||
|
}
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
while (++i < n);
|
||||||
|
n = x[g]; // set n to length of v
|
||||||
|
|
||||||
|
// Generate the Huffman codes and for each, make the table entries
|
||||||
|
x[0] = i = 0; // first Huffman code is zero
|
||||||
|
p = 0; // grab values in bit order
|
||||||
|
h = - 1; // no tables yet--level -1
|
||||||
|
w = - l; // bits decoded == (l * h)
|
||||||
|
u[0] = 0; // just to keep compilers happy
|
||||||
|
q = 0; // ditto
|
||||||
|
z = 0; // ditto
|
||||||
|
|
||||||
|
// go through the bit lengths (k already is bits in shortest code)
|
||||||
|
for (; k <= g; k++)
|
||||||
|
{
|
||||||
|
a = c[k];
|
||||||
|
while (a-- != 0)
|
||||||
|
{
|
||||||
|
// here i is the Huffman code of length k bits for value *p
|
||||||
|
// make tables up to required level
|
||||||
|
while (k > w + l)
|
||||||
|
{
|
||||||
|
h++;
|
||||||
|
w += l; // previous table always l bits
|
||||||
|
// compute minimum size table less than or equal to l bits
|
||||||
|
z = g - w;
|
||||||
|
z = (z > l)?l:z; // table size upper limit
|
||||||
|
if ((f = 1 << (j = k - w)) > a + 1)
|
||||||
|
{
|
||||||
|
// try a k-w bit table
|
||||||
|
// too few codes for k-w bit table
|
||||||
|
f -= (a + 1); // deduct codes from patterns left
|
||||||
|
xp = k;
|
||||||
|
if (j < z)
|
||||||
|
{
|
||||||
|
while (++j < z)
|
||||||
|
{
|
||||||
|
// try smaller tables up to z bits
|
||||||
|
if ((f <<= 1) <= c[++xp])
|
||||||
|
break; // enough codes to use up j bits
|
||||||
|
f -= c[xp]; // else deduct codes from patterns
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
z = 1 << j; // table entries for j-bit table
|
||||||
|
|
||||||
|
// allocate new table
|
||||||
|
if (hn[0] + z > MANY)
|
||||||
|
{
|
||||||
|
// (note: doesn't matter for fixed)
|
||||||
|
return Z_DATA_ERROR; // overflow of MANY
|
||||||
|
}
|
||||||
|
u[h] = q = hn[0]; // DEBUG
|
||||||
|
hn[0] += z;
|
||||||
|
|
||||||
|
// connect to last table, if there is one
|
||||||
|
if (h != 0)
|
||||||
|
{
|
||||||
|
x[h] = i; // save pattern for backing up
|
||||||
|
r[0] = (sbyte) j; // bits in this table
|
||||||
|
r[1] = (sbyte) l; // bits to dump before this table
|
||||||
|
j = SharedUtils.URShift(i, (w - l));
|
||||||
|
r[2] = (int) (q - u[h - 1] - j); // offset to this table
|
||||||
|
Array.Copy(r, 0, hp, (u[h - 1] + j) * 3, 3); // connect to last table
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
t[0] = q; // first table is returned result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// set up table entity in r
|
||||||
|
r[1] = (sbyte) (k - w);
|
||||||
|
if (p >= n)
|
||||||
|
{
|
||||||
|
r[0] = 128 + 64; // out of values--invalid code
|
||||||
|
}
|
||||||
|
else if (v[p] < s)
|
||||||
|
{
|
||||||
|
r[0] = (sbyte) (v[p] < 256?0:32 + 64); // 256 is end-of-block
|
||||||
|
r[2] = v[p++]; // simple code is just the value
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
r[0] = (sbyte) (e[v[p] - s] + 16 + 64); // non-simple--look up in lists
|
||||||
|
r[2] = d[v[p++] - s];
|
||||||
|
}
|
||||||
|
|
||||||
|
// fill code-like entries with r
|
||||||
|
f = 1 << (k - w);
|
||||||
|
for (j = SharedUtils.URShift(i, w); j < z; j += f)
|
||||||
|
{
|
||||||
|
Array.Copy(r, 0, hp, (q + j) * 3, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
// backwards increment the k-bit code i
|
||||||
|
for (j = 1 << (k - 1); (i & j) != 0; j = SharedUtils.URShift(j, 1))
|
||||||
|
{
|
||||||
|
i ^= j;
|
||||||
|
}
|
||||||
|
i ^= j;
|
||||||
|
|
||||||
|
// backup over finished tables
|
||||||
|
mask = (1 << w) - 1; // needed on HP, cc -O bug
|
||||||
|
while ((i & mask) != x[h])
|
||||||
|
{
|
||||||
|
h--; // don't need to update q
|
||||||
|
w -= l;
|
||||||
|
mask = (1 << w) - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Return Z_BUF_ERROR if we were given an incomplete table
|
||||||
|
return y != 0 && g != 1?Z_BUF_ERROR:Z_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal int inflate_trees_bits(int[] c, int[] bb, int[] tb, int[] hp, ZlibCodec z)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
initWorkArea(19);
|
||||||
|
hn[0] = 0;
|
||||||
|
result = huft_build(c, 0, 19, 19, null, null, tb, bb, hp, hn, v);
|
||||||
|
|
||||||
|
if (result == Z_DATA_ERROR)
|
||||||
|
{
|
||||||
|
z.Message = "oversubscribed dynamic bit lengths tree";
|
||||||
|
}
|
||||||
|
else if (result == Z_BUF_ERROR || bb[0] == 0)
|
||||||
|
{
|
||||||
|
z.Message = "incomplete dynamic bit lengths tree";
|
||||||
|
result = Z_DATA_ERROR;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal int inflate_trees_dynamic(int nl, int nd, int[] c, int[] bl, int[] bd, int[] tl, int[] td, int[] hp, ZlibCodec z)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
|
||||||
|
// build literal/length tree
|
||||||
|
initWorkArea(288);
|
||||||
|
hn[0] = 0;
|
||||||
|
result = huft_build(c, 0, nl, 257, cplens, cplext, tl, bl, hp, hn, v);
|
||||||
|
if (result != Z_OK || bl[0] == 0)
|
||||||
|
{
|
||||||
|
if (result == Z_DATA_ERROR)
|
||||||
|
{
|
||||||
|
z.Message = "oversubscribed literal/length tree";
|
||||||
|
}
|
||||||
|
else if (result != Z_MEM_ERROR)
|
||||||
|
{
|
||||||
|
z.Message = "incomplete literal/length tree";
|
||||||
|
result = Z_DATA_ERROR;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// build distance tree
|
||||||
|
initWorkArea(288);
|
||||||
|
result = huft_build(c, nl, nd, 0, cpdist, cpdext, td, bd, hp, hn, v);
|
||||||
|
|
||||||
|
if (result != Z_OK || (bd[0] == 0 && nl > 257))
|
||||||
|
{
|
||||||
|
if (result == Z_DATA_ERROR)
|
||||||
|
{
|
||||||
|
z.Message = "oversubscribed distance tree";
|
||||||
|
}
|
||||||
|
else if (result == Z_BUF_ERROR)
|
||||||
|
{
|
||||||
|
z.Message = "incomplete distance tree";
|
||||||
|
result = Z_DATA_ERROR;
|
||||||
|
}
|
||||||
|
else if (result != Z_MEM_ERROR)
|
||||||
|
{
|
||||||
|
z.Message = "empty distance tree with lengths";
|
||||||
|
result = Z_DATA_ERROR;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Z_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static int inflate_trees_fixed(int[] bl, int[] bd, int[][] tl, int[][] td, ZlibCodec z)
|
||||||
|
{
|
||||||
|
bl[0] = fixed_bl;
|
||||||
|
bd[0] = fixed_bd;
|
||||||
|
tl[0] = fixed_tl;
|
||||||
|
td[0] = fixed_td;
|
||||||
|
return Z_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initWorkArea(int vsize)
|
||||||
|
{
|
||||||
|
if (hn == null)
|
||||||
|
{
|
||||||
|
hn = new int[1];
|
||||||
|
v = new int[vsize];
|
||||||
|
c = new int[BMAX + 1];
|
||||||
|
r = new int[3];
|
||||||
|
u = new int[BMAX];
|
||||||
|
x = new int[BMAX + 1];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (v.Length < vsize)
|
||||||
|
{
|
||||||
|
v = new int[vsize];
|
||||||
|
}
|
||||||
|
Array.Clear(v,0,vsize);
|
||||||
|
Array.Clear(c,0,BMAX+1);
|
||||||
|
r[0]=0; r[1]=0; r[2]=0;
|
||||||
|
// for(int i=0; i<BMAX; i++){u[i]=0;}
|
||||||
|
//Array.Copy(c, 0, u, 0, BMAX);
|
||||||
|
Array.Clear(u,0,BMAX);
|
||||||
|
// for(int i=0; i<BMAX+1; i++){x[i]=0;}
|
||||||
|
//Array.Copy(c, 0, x, 0, BMAX + 1);
|
||||||
|
Array.Clear(x,0,BMAX+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f2541c75abb466b4fb55a2335fe858c2
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
1797
JNFrame/Assets/Plugins/BestHTTP/BestHTTP/Decompression/Inflate.cs
Normal file
1797
JNFrame/Assets/Plugins/BestHTTP/BestHTTP/Decompression/Inflate.cs
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 01ece23e3663e424ba8672d6d3d50f19
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
423
JNFrame/Assets/Plugins/BestHTTP/BestHTTP/Decompression/ZTree.cs
Normal file
423
JNFrame/Assets/Plugins/BestHTTP/BestHTTP/Decompression/ZTree.cs
Normal file
@ -0,0 +1,423 @@
|
|||||||
|
// Tree.cs
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Copyright (c) 2009 Dino Chiesa and Microsoft Corporation.
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This code module is part of DotNetZip, a zipfile class library.
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This code is licensed under the Microsoft Public License.
|
||||||
|
// See the file License.txt for the license details.
|
||||||
|
// More info on: http://dotnetzip.codeplex.com
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// last saved (in emacs):
|
||||||
|
// Time-stamp: <2009-October-28 13:29:50>
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This module defines classes for zlib compression and
|
||||||
|
// decompression. This code is derived from the jzlib implementation of
|
||||||
|
// zlib. In keeping with the license for jzlib, the copyright to that
|
||||||
|
// code is below.
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer in
|
||||||
|
// the documentation and/or other materials provided with the distribution.
|
||||||
|
//
|
||||||
|
// 3. The names of the authors may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||||
|
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
||||||
|
// INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||||
|
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||||
|
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This program is based on zlib-1.1.3; credit to authors
|
||||||
|
// Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
|
||||||
|
// and contributors of zlib.
|
||||||
|
//
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace BestHTTP.Decompression.Zlib
|
||||||
|
{
|
||||||
|
sealed class ZTree
|
||||||
|
{
|
||||||
|
private static readonly int HEAP_SIZE = (2 * InternalConstants.L_CODES + 1);
|
||||||
|
|
||||||
|
// extra bits for each length code
|
||||||
|
internal static readonly int[] ExtraLengthBits = new int[]
|
||||||
|
{
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
|
||||||
|
3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0
|
||||||
|
};
|
||||||
|
|
||||||
|
// extra bits for each distance code
|
||||||
|
internal static readonly int[] ExtraDistanceBits = new int[]
|
||||||
|
{
|
||||||
|
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
|
||||||
|
7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13
|
||||||
|
};
|
||||||
|
|
||||||
|
// extra bits for each bit length code
|
||||||
|
internal static readonly int[] extra_blbits = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7};
|
||||||
|
|
||||||
|
internal static readonly sbyte[] bl_order = new sbyte[]{16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
|
||||||
|
|
||||||
|
|
||||||
|
// The lengths of the bit length codes are sent in order of decreasing
|
||||||
|
// probability, to avoid transmitting the lengths for unused bit
|
||||||
|
// length codes.
|
||||||
|
|
||||||
|
internal const int Buf_size = 8 * 2;
|
||||||
|
|
||||||
|
// see definition of array dist_code below
|
||||||
|
//internal const int DIST_CODE_LEN = 512;
|
||||||
|
|
||||||
|
private static readonly sbyte[] _dist_code = new sbyte[]
|
||||||
|
{
|
||||||
|
0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7,
|
||||||
|
8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9,
|
||||||
|
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||||
|
11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
|
||||||
|
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
|
||||||
|
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
|
||||||
|
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
|
||||||
|
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
|
||||||
|
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
|
||||||
|
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
|
||||||
|
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
|
||||||
|
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
|
||||||
|
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
|
||||||
|
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
|
||||||
|
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
|
||||||
|
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
|
||||||
|
0, 0, 16, 17, 18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21,
|
||||||
|
22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
|
||||||
|
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||||
|
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||||
|
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
|
||||||
|
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
|
||||||
|
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
|
||||||
|
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
|
||||||
|
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
|
||||||
|
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
|
||||||
|
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
|
||||||
|
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
|
||||||
|
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
|
||||||
|
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
|
||||||
|
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
|
||||||
|
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
|
||||||
|
};
|
||||||
|
|
||||||
|
internal static readonly sbyte[] LengthCode = new sbyte[]
|
||||||
|
{
|
||||||
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11,
|
||||||
|
12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15,
|
||||||
|
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17,
|
||||||
|
18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19,
|
||||||
|
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||||
|
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
|
||||||
|
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
|
||||||
|
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
|
||||||
|
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||||
|
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||||
|
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||||
|
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||||
|
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
|
||||||
|
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
|
||||||
|
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
|
||||||
|
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
internal static readonly int[] LengthBase = new int[]
|
||||||
|
{
|
||||||
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28,
|
||||||
|
32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 0
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
internal static readonly int[] DistanceBase = new int[]
|
||||||
|
{
|
||||||
|
0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192,
|
||||||
|
256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Map from a distance to a distance code.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// No side effects. _dist_code[256] and _dist_code[257] are never used.
|
||||||
|
/// </remarks>
|
||||||
|
internal static int DistanceCode(int dist)
|
||||||
|
{
|
||||||
|
return (dist < 256)
|
||||||
|
? _dist_code[dist]
|
||||||
|
: _dist_code[256 + SharedUtils.URShift(dist, 7)];
|
||||||
|
}
|
||||||
|
|
||||||
|
internal short[] dyn_tree; // the dynamic tree
|
||||||
|
internal int max_code; // largest code with non zero frequency
|
||||||
|
internal StaticTree staticTree; // the corresponding static tree
|
||||||
|
|
||||||
|
// Compute the optimal bit lengths for a tree and update the total bit length
|
||||||
|
// for the current block.
|
||||||
|
// IN assertion: the fields freq and dad are set, heap[heap_max] and
|
||||||
|
// above are the tree nodes sorted by increasing frequency.
|
||||||
|
// OUT assertions: the field len is set to the optimal bit length, the
|
||||||
|
// array bl_count contains the frequencies for each bit length.
|
||||||
|
// The length opt_len is updated; static_len is also updated if stree is
|
||||||
|
// not null.
|
||||||
|
internal void gen_bitlen(DeflateManager s)
|
||||||
|
{
|
||||||
|
short[] tree = dyn_tree;
|
||||||
|
short[] stree = staticTree.treeCodes;
|
||||||
|
int[] extra = staticTree.extraBits;
|
||||||
|
int base_Renamed = staticTree.extraBase;
|
||||||
|
int max_length = staticTree.maxLength;
|
||||||
|
int h; // heap index
|
||||||
|
int n, m; // iterate over the tree elements
|
||||||
|
int bits; // bit length
|
||||||
|
int xbits; // extra bits
|
||||||
|
short f; // frequency
|
||||||
|
int overflow = 0; // number of elements with bit length too large
|
||||||
|
|
||||||
|
for (bits = 0; bits <= InternalConstants.MAX_BITS; bits++)
|
||||||
|
s.bl_count[bits] = 0;
|
||||||
|
|
||||||
|
// In a first pass, compute the optimal bit lengths (which may
|
||||||
|
// overflow in the case of the bit length tree).
|
||||||
|
tree[s.heap[s.heap_max] * 2 + 1] = 0; // root of the heap
|
||||||
|
|
||||||
|
for (h = s.heap_max + 1; h < HEAP_SIZE; h++)
|
||||||
|
{
|
||||||
|
n = s.heap[h];
|
||||||
|
bits = tree[tree[n * 2 + 1] * 2 + 1] + 1;
|
||||||
|
if (bits > max_length)
|
||||||
|
{
|
||||||
|
bits = max_length; overflow++;
|
||||||
|
}
|
||||||
|
tree[n * 2 + 1] = (short) bits;
|
||||||
|
// We overwrite tree[n*2+1] which is no longer needed
|
||||||
|
|
||||||
|
if (n > max_code)
|
||||||
|
continue; // not a leaf node
|
||||||
|
|
||||||
|
s.bl_count[bits]++;
|
||||||
|
xbits = 0;
|
||||||
|
if (n >= base_Renamed)
|
||||||
|
xbits = extra[n - base_Renamed];
|
||||||
|
f = tree[n * 2];
|
||||||
|
s.opt_len += f * (bits + xbits);
|
||||||
|
if (stree != null)
|
||||||
|
s.static_len += f * (stree[n * 2 + 1] + xbits);
|
||||||
|
}
|
||||||
|
if (overflow == 0)
|
||||||
|
return ;
|
||||||
|
|
||||||
|
// This happens for example on obj2 and pic of the Calgary corpus
|
||||||
|
// Find the first bit length which could increase:
|
||||||
|
do
|
||||||
|
{
|
||||||
|
bits = max_length - 1;
|
||||||
|
while (s.bl_count[bits] == 0)
|
||||||
|
bits--;
|
||||||
|
s.bl_count[bits]--; // move one leaf down the tree
|
||||||
|
s.bl_count[bits + 1] = (short) (s.bl_count[bits + 1] + 2); // move one overflow item as its brother
|
||||||
|
s.bl_count[max_length]--;
|
||||||
|
// The brother of the overflow item also moves one step up,
|
||||||
|
// but this does not affect bl_count[max_length]
|
||||||
|
overflow -= 2;
|
||||||
|
}
|
||||||
|
while (overflow > 0);
|
||||||
|
|
||||||
|
for (bits = max_length; bits != 0; bits--)
|
||||||
|
{
|
||||||
|
n = s.bl_count[bits];
|
||||||
|
while (n != 0)
|
||||||
|
{
|
||||||
|
m = s.heap[--h];
|
||||||
|
if (m > max_code)
|
||||||
|
continue;
|
||||||
|
if (tree[m * 2 + 1] != bits)
|
||||||
|
{
|
||||||
|
s.opt_len = (int) (s.opt_len + ((long) bits - (long) tree[m * 2 + 1]) * (long) tree[m * 2]);
|
||||||
|
tree[m * 2 + 1] = (short) bits;
|
||||||
|
}
|
||||||
|
n--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Construct one Huffman tree and assigns the code bit strings and lengths.
|
||||||
|
// Update the total bit length for the current block.
|
||||||
|
// IN assertion: the field freq is set for all tree elements.
|
||||||
|
// OUT assertions: the fields len and code are set to the optimal bit length
|
||||||
|
// and corresponding code. The length opt_len is updated; static_len is
|
||||||
|
// also updated if stree is not null. The field max_code is set.
|
||||||
|
internal void build_tree(DeflateManager s)
|
||||||
|
{
|
||||||
|
short[] tree = dyn_tree;
|
||||||
|
short[] stree = staticTree.treeCodes;
|
||||||
|
int elems = staticTree.elems;
|
||||||
|
int n, m; // iterate over heap elements
|
||||||
|
int max_code = -1; // largest code with non zero frequency
|
||||||
|
int node; // new node being created
|
||||||
|
|
||||||
|
// Construct the initial heap, with least frequent element in
|
||||||
|
// heap[1]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
|
||||||
|
// heap[0] is not used.
|
||||||
|
s.heap_len = 0;
|
||||||
|
s.heap_max = HEAP_SIZE;
|
||||||
|
|
||||||
|
for (n = 0; n < elems; n++)
|
||||||
|
{
|
||||||
|
if (tree[n * 2] != 0)
|
||||||
|
{
|
||||||
|
s.heap[++s.heap_len] = max_code = n;
|
||||||
|
s.depth[n] = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tree[n * 2 + 1] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The pkzip format requires that at least one distance code exists,
|
||||||
|
// and that at least one bit should be sent even if there is only one
|
||||||
|
// possible code. So to avoid special checks later on we force at least
|
||||||
|
// two codes of non zero frequency.
|
||||||
|
while (s.heap_len < 2)
|
||||||
|
{
|
||||||
|
node = s.heap[++s.heap_len] = (max_code < 2?++max_code:0);
|
||||||
|
tree[node * 2] = 1;
|
||||||
|
s.depth[node] = 0;
|
||||||
|
s.opt_len--;
|
||||||
|
if (stree != null)
|
||||||
|
s.static_len -= stree[node * 2 + 1];
|
||||||
|
// node is 0 or 1 so it does not have extra bits
|
||||||
|
}
|
||||||
|
this.max_code = max_code;
|
||||||
|
|
||||||
|
// The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
|
||||||
|
// establish sub-heaps of increasing lengths:
|
||||||
|
|
||||||
|
for (n = s.heap_len / 2; n >= 1; n--)
|
||||||
|
s.pqdownheap(tree, n);
|
||||||
|
|
||||||
|
// Construct the Huffman tree by repeatedly combining the least two
|
||||||
|
// frequent nodes.
|
||||||
|
|
||||||
|
node = elems; // next internal node of the tree
|
||||||
|
do
|
||||||
|
{
|
||||||
|
// n = node of least frequency
|
||||||
|
n = s.heap[1];
|
||||||
|
s.heap[1] = s.heap[s.heap_len--];
|
||||||
|
s.pqdownheap(tree, 1);
|
||||||
|
m = s.heap[1]; // m = node of next least frequency
|
||||||
|
|
||||||
|
s.heap[--s.heap_max] = n; // keep the nodes sorted by frequency
|
||||||
|
s.heap[--s.heap_max] = m;
|
||||||
|
|
||||||
|
// Create a new node father of n and m
|
||||||
|
tree[node * 2] = unchecked((short) (tree[n * 2] + tree[m * 2]));
|
||||||
|
s.depth[node] = (sbyte) (System.Math.Max((byte) s.depth[n], (byte) s.depth[m]) + 1);
|
||||||
|
tree[n * 2 + 1] = tree[m * 2 + 1] = (short) node;
|
||||||
|
|
||||||
|
// and insert the new node in the heap
|
||||||
|
s.heap[1] = node++;
|
||||||
|
s.pqdownheap(tree, 1);
|
||||||
|
}
|
||||||
|
while (s.heap_len >= 2);
|
||||||
|
|
||||||
|
s.heap[--s.heap_max] = s.heap[1];
|
||||||
|
|
||||||
|
// At this point, the fields freq and dad are set. We can now
|
||||||
|
// generate the bit lengths.
|
||||||
|
|
||||||
|
gen_bitlen(s);
|
||||||
|
|
||||||
|
// The field len is now set, we can generate the bit codes
|
||||||
|
gen_codes(tree, max_code, s.bl_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate the codes for a given tree and bit counts (which need not be
|
||||||
|
// optimal).
|
||||||
|
// IN assertion: the array bl_count contains the bit length statistics for
|
||||||
|
// the given tree and the field len is set for all tree elements.
|
||||||
|
// OUT assertion: the field code is set for all tree elements of non
|
||||||
|
// zero code length.
|
||||||
|
internal static void gen_codes(short[] tree, int max_code, short[] bl_count)
|
||||||
|
{
|
||||||
|
short[] next_code = new short[InternalConstants.MAX_BITS + 1]; // next code value for each bit length
|
||||||
|
short code = 0; // running code value
|
||||||
|
int bits; // bit index
|
||||||
|
int n; // code index
|
||||||
|
|
||||||
|
// The distribution counts are first used to generate the code values
|
||||||
|
// without bit reversal.
|
||||||
|
for (bits = 1; bits <= InternalConstants.MAX_BITS; bits++)
|
||||||
|
unchecked {
|
||||||
|
next_code[bits] = code = (short) ((code + bl_count[bits - 1]) << 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that the bit counts in bl_count are consistent. The last code
|
||||||
|
// must be all ones.
|
||||||
|
//Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,
|
||||||
|
// "inconsistent bit counts");
|
||||||
|
//Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
|
||||||
|
|
||||||
|
for (n = 0; n <= max_code; n++)
|
||||||
|
{
|
||||||
|
int len = tree[n * 2 + 1];
|
||||||
|
if (len == 0)
|
||||||
|
continue;
|
||||||
|
// Now reverse the bits
|
||||||
|
tree[n * 2] = unchecked((short) (bi_reverse(next_code[len]++, len)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reverse the first len bits of a code, using straightforward code (a faster
|
||||||
|
// method would use a table)
|
||||||
|
// IN assertion: 1 <= len <= 15
|
||||||
|
internal static int bi_reverse(int code, int len)
|
||||||
|
{
|
||||||
|
int res = 0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
res |= code & 1;
|
||||||
|
code >>= 1; //SharedUtils.URShift(code, 1);
|
||||||
|
res <<= 1;
|
||||||
|
}
|
||||||
|
while (--len > 0);
|
||||||
|
return res >> 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 567080ac494bf3b47acca3e05bf46e84
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
546
JNFrame/Assets/Plugins/BestHTTP/BestHTTP/Decompression/Zlib.cs
Normal file
546
JNFrame/Assets/Plugins/BestHTTP/BestHTTP/Decompression/Zlib.cs
Normal file
@ -0,0 +1,546 @@
|
|||||||
|
// Zlib.cs
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Copyright (c) 2009-2011 Dino Chiesa and Microsoft Corporation.
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This code module is part of DotNetZip, a zipfile class library.
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This code is licensed under the Microsoft Public License.
|
||||||
|
// See the file License.txt for the license details.
|
||||||
|
// More info on: http://dotnetzip.codeplex.com
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Last Saved: <2011-August-03 19:52:28>
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This module defines classes for ZLIB compression and
|
||||||
|
// decompression. This code is derived from the jzlib implementation of
|
||||||
|
// zlib, but significantly modified. The object model is not the same,
|
||||||
|
// and many of the behaviors are new or different. Nonetheless, in
|
||||||
|
// keeping with the license for jzlib, the copyright to that code is
|
||||||
|
// included below.
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// The following notice applies to jzlib:
|
||||||
|
//
|
||||||
|
// Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer in
|
||||||
|
// the documentation and/or other materials provided with the distribution.
|
||||||
|
//
|
||||||
|
// 3. The names of the authors may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||||
|
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
||||||
|
// INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||||
|
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||||
|
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// jzlib is based on zlib-1.1.3.
|
||||||
|
//
|
||||||
|
// The following notice applies to zlib:
|
||||||
|
//
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Copyright (C) 1995-2004 Jean-loup Gailly and Mark Adler
|
||||||
|
//
|
||||||
|
// The ZLIB software is provided 'as-is', without any express or implied
|
||||||
|
// warranty. In no event will the authors be held liable for any damages
|
||||||
|
// arising from the use of this software.
|
||||||
|
//
|
||||||
|
// Permission is granted to anyone to use this software for any purpose,
|
||||||
|
// including commercial applications, and to alter it and redistribute it
|
||||||
|
// freely, subject to the following restrictions:
|
||||||
|
//
|
||||||
|
// 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
// claim that you wrote the original software. If you use this software
|
||||||
|
// in a product, an acknowledgment in the product documentation would be
|
||||||
|
// appreciated but is not required.
|
||||||
|
// 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
// misrepresented as being the original software.
|
||||||
|
// 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
//
|
||||||
|
// Jean-loup Gailly jloup@gzip.org
|
||||||
|
// Mark Adler madler@alumni.caltech.edu
|
||||||
|
//
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using Interop=System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace BestHTTP.Decompression.Zlib
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Describes how to flush the current deflate operation.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The different FlushType values are useful when using a Deflate in a streaming application.
|
||||||
|
/// </remarks>
|
||||||
|
public enum FlushType
|
||||||
|
{
|
||||||
|
/// <summary>No flush at all.</summary>
|
||||||
|
None = 0,
|
||||||
|
|
||||||
|
/// <summary>Closes the current block, but doesn't flush it to
|
||||||
|
/// the output. Used internally only in hypothetical
|
||||||
|
/// scenarios. This was supposed to be removed by Zlib, but it is
|
||||||
|
/// still in use in some edge cases.
|
||||||
|
/// </summary>
|
||||||
|
Partial,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Use this during compression to specify that all pending output should be
|
||||||
|
/// flushed to the output buffer and the output should be aligned on a byte
|
||||||
|
/// boundary. You might use this in a streaming communication scenario, so that
|
||||||
|
/// the decompressor can get all input data available so far. When using this
|
||||||
|
/// with a ZlibCodec, <c>AvailableBytesIn</c> will be zero after the call if
|
||||||
|
/// enough output space has been provided before the call. Flushing will
|
||||||
|
/// degrade compression and so it should be used only when necessary.
|
||||||
|
/// </summary>
|
||||||
|
Sync,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Use this during compression to specify that all output should be flushed, as
|
||||||
|
/// with <c>FlushType.Sync</c>, but also, the compression state should be reset
|
||||||
|
/// so that decompression can restart from this point if previous compressed
|
||||||
|
/// data has been damaged or if random access is desired. Using
|
||||||
|
/// <c>FlushType.Full</c> too often can significantly degrade the compression.
|
||||||
|
/// </summary>
|
||||||
|
Full,
|
||||||
|
|
||||||
|
/// <summary>Signals the end of the compression/decompression stream.</summary>
|
||||||
|
Finish,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The compression level to be used when using a DeflateStream or ZlibStream with CompressionMode.Compress.
|
||||||
|
/// </summary>
|
||||||
|
public enum CompressionLevel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// None means that the data will be simply stored, with no change at all.
|
||||||
|
/// If you are producing ZIPs for use on Mac OSX, be aware that archives produced with CompressionLevel.None
|
||||||
|
/// cannot be opened with the default zip reader. Use a different CompressionLevel.
|
||||||
|
/// </summary>
|
||||||
|
None= 0,
|
||||||
|
/// <summary>
|
||||||
|
/// Same as None.
|
||||||
|
/// </summary>
|
||||||
|
Level0 = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The fastest but least effective compression.
|
||||||
|
/// </summary>
|
||||||
|
BestSpeed = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A synonym for BestSpeed.
|
||||||
|
/// </summary>
|
||||||
|
Level1 = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A little slower, but better, than level 1.
|
||||||
|
/// </summary>
|
||||||
|
Level2 = 2,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A little slower, but better, than level 2.
|
||||||
|
/// </summary>
|
||||||
|
Level3 = 3,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A little slower, but better, than level 3.
|
||||||
|
/// </summary>
|
||||||
|
Level4 = 4,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A little slower than level 4, but with better compression.
|
||||||
|
/// </summary>
|
||||||
|
Level5 = 5,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The default compression level, with a good balance of speed and compression efficiency.
|
||||||
|
/// </summary>
|
||||||
|
Default = 6,
|
||||||
|
/// <summary>
|
||||||
|
/// A synonym for Default.
|
||||||
|
/// </summary>
|
||||||
|
Level6 = 6,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Pretty good compression!
|
||||||
|
/// </summary>
|
||||||
|
Level7 = 7,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Better compression than Level7!
|
||||||
|
/// </summary>
|
||||||
|
Level8 = 8,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The "best" compression, where best means greatest reduction in size of the input data stream.
|
||||||
|
/// This is also the slowest compression.
|
||||||
|
/// </summary>
|
||||||
|
BestCompression = 9,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A synonym for BestCompression.
|
||||||
|
/// </summary>
|
||||||
|
Level9 = 9,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Describes options for how the compression algorithm is executed. Different strategies
|
||||||
|
/// work better on different sorts of data. The strategy parameter can affect the compression
|
||||||
|
/// ratio and the speed of compression but not the correctness of the compresssion.
|
||||||
|
/// </summary>
|
||||||
|
public enum CompressionStrategy
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The default strategy is probably the best for normal data.
|
||||||
|
/// </summary>
|
||||||
|
Default = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The <c>Filtered</c> strategy is intended to be used most effectively with data produced by a
|
||||||
|
/// filter or predictor. By this definition, filtered data consists mostly of small
|
||||||
|
/// values with a somewhat random distribution. In this case, the compression algorithm
|
||||||
|
/// is tuned to compress them better. The effect of <c>Filtered</c> is to force more Huffman
|
||||||
|
/// coding and less string matching; it is a half-step between <c>Default</c> and <c>HuffmanOnly</c>.
|
||||||
|
/// </summary>
|
||||||
|
Filtered = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Using <c>HuffmanOnly</c> will force the compressor to do Huffman encoding only, with no
|
||||||
|
/// string matching.
|
||||||
|
/// </summary>
|
||||||
|
HuffmanOnly = 2,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// An enum to specify the direction of transcoding - whether to compress or decompress.
|
||||||
|
/// </summary>
|
||||||
|
public enum CompressionMode
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Used to specify that the stream should compress the data.
|
||||||
|
/// </summary>
|
||||||
|
Compress= 0,
|
||||||
|
/// <summary>
|
||||||
|
/// Used to specify that the stream should decompress the data.
|
||||||
|
/// </summary>
|
||||||
|
Decompress = 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A general purpose exception class for exceptions in the Zlib library.
|
||||||
|
/// </summary>
|
||||||
|
[Interop.GuidAttribute("ebc25cf6-9120-4283-b972-0e5520d0000E")]
|
||||||
|
internal class ZlibException : System.Exception
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The ZlibException class captures exception information generated
|
||||||
|
/// by the Zlib library.
|
||||||
|
/// </summary>
|
||||||
|
public ZlibException()
|
||||||
|
: base()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This ctor collects a message attached to the exception.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="s">the message for the exception.</param>
|
||||||
|
public ZlibException(System.String s)
|
||||||
|
: base(s)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
internal class SharedUtils
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Performs an unsigned bitwise right shift with the specified number
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="number">Number to operate on</param>
|
||||||
|
/// <param name="bits">Ammount of bits to shift</param>
|
||||||
|
/// <returns>The resulting number from the shift operation</returns>
|
||||||
|
public static int URShift(int number, int bits)
|
||||||
|
{
|
||||||
|
return (int)((uint)number >> bits);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if NOT
|
||||||
|
/// <summary>
|
||||||
|
/// Performs an unsigned bitwise right shift with the specified number
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="number">Number to operate on</param>
|
||||||
|
/// <param name="bits">Ammount of bits to shift</param>
|
||||||
|
/// <returns>The resulting number from the shift operation</returns>
|
||||||
|
public static long URShift(long number, int bits)
|
||||||
|
{
|
||||||
|
return (long) ((UInt64)number >> bits);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reads a number of characters from the current source TextReader and writes
|
||||||
|
/// the data to the target array at the specified index.
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <param name="sourceTextReader">The source TextReader to read from</param>
|
||||||
|
/// <param name="target">Contains the array of characteres read from the source TextReader.</param>
|
||||||
|
/// <param name="start">The starting index of the target array.</param>
|
||||||
|
/// <param name="count">The maximum number of characters to read from the source TextReader.</param>
|
||||||
|
///
|
||||||
|
/// <returns>
|
||||||
|
/// The number of characters read. The number will be less than or equal to
|
||||||
|
/// count depending on the data available in the source TextReader. Returns -1
|
||||||
|
/// if the end of the stream is reached.
|
||||||
|
/// </returns>
|
||||||
|
public static System.Int32 ReadInput(System.IO.TextReader sourceTextReader, byte[] target, int start, int count)
|
||||||
|
{
|
||||||
|
// Returns 0 bytes if not enough space in target
|
||||||
|
if (target.Length == 0) return 0;
|
||||||
|
|
||||||
|
char[] charArray = new char[target.Length];
|
||||||
|
int bytesRead = sourceTextReader.Read(charArray, start, count);
|
||||||
|
|
||||||
|
// Returns -1 if EOF
|
||||||
|
if (bytesRead == 0) return -1;
|
||||||
|
|
||||||
|
for (int index = start; index < start + bytesRead; index++)
|
||||||
|
target[index] = (byte)charArray[index];
|
||||||
|
|
||||||
|
return bytesRead;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
internal static byte[] ToByteArray(System.String sourceString)
|
||||||
|
{
|
||||||
|
return System.Text.UTF8Encoding.UTF8.GetBytes(sourceString);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
internal static char[] ToCharArray(byte[] byteArray)
|
||||||
|
{
|
||||||
|
return System.Text.UTF8Encoding.UTF8.GetChars(byteArray);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static class InternalConstants
|
||||||
|
{
|
||||||
|
internal static readonly int MAX_BITS = 15;
|
||||||
|
internal static readonly int BL_CODES = 19;
|
||||||
|
internal static readonly int D_CODES = 30;
|
||||||
|
internal static readonly int LITERALS = 256;
|
||||||
|
internal static readonly int LENGTH_CODES = 29;
|
||||||
|
internal static readonly int L_CODES = (LITERALS + 1 + LENGTH_CODES);
|
||||||
|
|
||||||
|
// Bit length codes must not exceed MAX_BL_BITS bits
|
||||||
|
internal static readonly int MAX_BL_BITS = 7;
|
||||||
|
|
||||||
|
// repeat previous bit length 3-6 times (2 bits of repeat count)
|
||||||
|
internal static readonly int REP_3_6 = 16;
|
||||||
|
|
||||||
|
// repeat a zero length 3-10 times (3 bits of repeat count)
|
||||||
|
internal static readonly int REPZ_3_10 = 17;
|
||||||
|
|
||||||
|
// repeat a zero length 11-138 times (7 bits of repeat count)
|
||||||
|
internal static readonly int REPZ_11_138 = 18;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed class StaticTree
|
||||||
|
{
|
||||||
|
internal static readonly short[] lengthAndLiteralsTreeCodes = new short[] {
|
||||||
|
12, 8, 140, 8, 76, 8, 204, 8, 44, 8, 172, 8, 108, 8, 236, 8,
|
||||||
|
28, 8, 156, 8, 92, 8, 220, 8, 60, 8, 188, 8, 124, 8, 252, 8,
|
||||||
|
2, 8, 130, 8, 66, 8, 194, 8, 34, 8, 162, 8, 98, 8, 226, 8,
|
||||||
|
18, 8, 146, 8, 82, 8, 210, 8, 50, 8, 178, 8, 114, 8, 242, 8,
|
||||||
|
10, 8, 138, 8, 74, 8, 202, 8, 42, 8, 170, 8, 106, 8, 234, 8,
|
||||||
|
26, 8, 154, 8, 90, 8, 218, 8, 58, 8, 186, 8, 122, 8, 250, 8,
|
||||||
|
6, 8, 134, 8, 70, 8, 198, 8, 38, 8, 166, 8, 102, 8, 230, 8,
|
||||||
|
22, 8, 150, 8, 86, 8, 214, 8, 54, 8, 182, 8, 118, 8, 246, 8,
|
||||||
|
14, 8, 142, 8, 78, 8, 206, 8, 46, 8, 174, 8, 110, 8, 238, 8,
|
||||||
|
30, 8, 158, 8, 94, 8, 222, 8, 62, 8, 190, 8, 126, 8, 254, 8,
|
||||||
|
1, 8, 129, 8, 65, 8, 193, 8, 33, 8, 161, 8, 97, 8, 225, 8,
|
||||||
|
17, 8, 145, 8, 81, 8, 209, 8, 49, 8, 177, 8, 113, 8, 241, 8,
|
||||||
|
9, 8, 137, 8, 73, 8, 201, 8, 41, 8, 169, 8, 105, 8, 233, 8,
|
||||||
|
25, 8, 153, 8, 89, 8, 217, 8, 57, 8, 185, 8, 121, 8, 249, 8,
|
||||||
|
5, 8, 133, 8, 69, 8, 197, 8, 37, 8, 165, 8, 101, 8, 229, 8,
|
||||||
|
21, 8, 149, 8, 85, 8, 213, 8, 53, 8, 181, 8, 117, 8, 245, 8,
|
||||||
|
13, 8, 141, 8, 77, 8, 205, 8, 45, 8, 173, 8, 109, 8, 237, 8,
|
||||||
|
29, 8, 157, 8, 93, 8, 221, 8, 61, 8, 189, 8, 125, 8, 253, 8,
|
||||||
|
19, 9, 275, 9, 147, 9, 403, 9, 83, 9, 339, 9, 211, 9, 467, 9,
|
||||||
|
51, 9, 307, 9, 179, 9, 435, 9, 115, 9, 371, 9, 243, 9, 499, 9,
|
||||||
|
11, 9, 267, 9, 139, 9, 395, 9, 75, 9, 331, 9, 203, 9, 459, 9,
|
||||||
|
43, 9, 299, 9, 171, 9, 427, 9, 107, 9, 363, 9, 235, 9, 491, 9,
|
||||||
|
27, 9, 283, 9, 155, 9, 411, 9, 91, 9, 347, 9, 219, 9, 475, 9,
|
||||||
|
59, 9, 315, 9, 187, 9, 443, 9, 123, 9, 379, 9, 251, 9, 507, 9,
|
||||||
|
7, 9, 263, 9, 135, 9, 391, 9, 71, 9, 327, 9, 199, 9, 455, 9,
|
||||||
|
39, 9, 295, 9, 167, 9, 423, 9, 103, 9, 359, 9, 231, 9, 487, 9,
|
||||||
|
23, 9, 279, 9, 151, 9, 407, 9, 87, 9, 343, 9, 215, 9, 471, 9,
|
||||||
|
55, 9, 311, 9, 183, 9, 439, 9, 119, 9, 375, 9, 247, 9, 503, 9,
|
||||||
|
15, 9, 271, 9, 143, 9, 399, 9, 79, 9, 335, 9, 207, 9, 463, 9,
|
||||||
|
47, 9, 303, 9, 175, 9, 431, 9, 111, 9, 367, 9, 239, 9, 495, 9,
|
||||||
|
31, 9, 287, 9, 159, 9, 415, 9, 95, 9, 351, 9, 223, 9, 479, 9,
|
||||||
|
63, 9, 319, 9, 191, 9, 447, 9, 127, 9, 383, 9, 255, 9, 511, 9,
|
||||||
|
0, 7, 64, 7, 32, 7, 96, 7, 16, 7, 80, 7, 48, 7, 112, 7,
|
||||||
|
8, 7, 72, 7, 40, 7, 104, 7, 24, 7, 88, 7, 56, 7, 120, 7,
|
||||||
|
4, 7, 68, 7, 36, 7, 100, 7, 20, 7, 84, 7, 52, 7, 116, 7,
|
||||||
|
3, 8, 131, 8, 67, 8, 195, 8, 35, 8, 163, 8, 99, 8, 227, 8
|
||||||
|
};
|
||||||
|
|
||||||
|
internal static readonly short[] distTreeCodes = new short[] {
|
||||||
|
0, 5, 16, 5, 8, 5, 24, 5, 4, 5, 20, 5, 12, 5, 28, 5,
|
||||||
|
2, 5, 18, 5, 10, 5, 26, 5, 6, 5, 22, 5, 14, 5, 30, 5,
|
||||||
|
1, 5, 17, 5, 9, 5, 25, 5, 5, 5, 21, 5, 13, 5, 29, 5,
|
||||||
|
3, 5, 19, 5, 11, 5, 27, 5, 7, 5, 23, 5 };
|
||||||
|
|
||||||
|
internal static readonly StaticTree Literals;
|
||||||
|
internal static readonly StaticTree Distances;
|
||||||
|
internal static readonly StaticTree BitLengths;
|
||||||
|
|
||||||
|
internal short[] treeCodes; // static tree or null
|
||||||
|
internal int[] extraBits; // extra bits for each code or null
|
||||||
|
internal int extraBase; // base index for extra_bits
|
||||||
|
internal int elems; // max number of elements in the tree
|
||||||
|
internal int maxLength; // max bit length for the codes
|
||||||
|
|
||||||
|
private StaticTree(short[] treeCodes, int[] extraBits, int extraBase, int elems, int maxLength)
|
||||||
|
{
|
||||||
|
this.treeCodes = treeCodes;
|
||||||
|
this.extraBits = extraBits;
|
||||||
|
this.extraBase = extraBase;
|
||||||
|
this.elems = elems;
|
||||||
|
this.maxLength = maxLength;
|
||||||
|
}
|
||||||
|
static StaticTree()
|
||||||
|
{
|
||||||
|
Literals = new StaticTree(lengthAndLiteralsTreeCodes, ZTree.ExtraLengthBits, InternalConstants.LITERALS + 1, InternalConstants.L_CODES, InternalConstants.MAX_BITS);
|
||||||
|
Distances = new StaticTree(distTreeCodes, ZTree.ExtraDistanceBits, 0, InternalConstants.D_CODES, InternalConstants.MAX_BITS);
|
||||||
|
BitLengths = new StaticTree(null, ZTree.extra_blbits, 0, InternalConstants.BL_CODES, InternalConstants.MAX_BL_BITS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Computes an Adler-32 checksum.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The Adler checksum is similar to a CRC checksum, but faster to compute, though less
|
||||||
|
/// reliable. It is used in producing RFC1950 compressed streams. The Adler checksum
|
||||||
|
/// is a required part of the "ZLIB" standard. Applications will almost never need to
|
||||||
|
/// use this class directly.
|
||||||
|
/// </remarks>
|
||||||
|
///
|
||||||
|
/// <exclude/>
|
||||||
|
public sealed class Adler
|
||||||
|
{
|
||||||
|
// largest prime smaller than 65536
|
||||||
|
private static readonly uint BASE = 65521;
|
||||||
|
// NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1
|
||||||
|
private static readonly int NMAX = 5552;
|
||||||
|
|
||||||
|
|
||||||
|
#pragma warning disable 3001
|
||||||
|
#pragma warning disable 3002
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Calculates the Adler32 checksum.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// <para>
|
||||||
|
/// This is used within ZLIB. You probably don't need to use this directly.
|
||||||
|
/// </para>
|
||||||
|
/// </remarks>
|
||||||
|
/// <example>
|
||||||
|
/// To compute an Adler32 checksum on a byte array:
|
||||||
|
/// <code>
|
||||||
|
/// var adler = Adler.Adler32(0, null, 0, 0);
|
||||||
|
/// adler = Adler.Adler32(adler, buffer, index, length);
|
||||||
|
/// </code>
|
||||||
|
/// </example>
|
||||||
|
public static uint Adler32(uint adler, byte[] buf, int index, int len)
|
||||||
|
{
|
||||||
|
if (buf == null)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
uint s1 = (uint) (adler & 0xffff);
|
||||||
|
uint s2 = (uint) ((adler >> 16) & 0xffff);
|
||||||
|
|
||||||
|
while (len > 0)
|
||||||
|
{
|
||||||
|
int k = len < NMAX ? len : NMAX;
|
||||||
|
len -= k;
|
||||||
|
while (k >= 16)
|
||||||
|
{
|
||||||
|
//s1 += (buf[index++] & 0xff); s2 += s1;
|
||||||
|
s1 += buf[index++]; s2 += s1;
|
||||||
|
s1 += buf[index++]; s2 += s1;
|
||||||
|
s1 += buf[index++]; s2 += s1;
|
||||||
|
s1 += buf[index++]; s2 += s1;
|
||||||
|
s1 += buf[index++]; s2 += s1;
|
||||||
|
s1 += buf[index++]; s2 += s1;
|
||||||
|
s1 += buf[index++]; s2 += s1;
|
||||||
|
s1 += buf[index++]; s2 += s1;
|
||||||
|
s1 += buf[index++]; s2 += s1;
|
||||||
|
s1 += buf[index++]; s2 += s1;
|
||||||
|
s1 += buf[index++]; s2 += s1;
|
||||||
|
s1 += buf[index++]; s2 += s1;
|
||||||
|
s1 += buf[index++]; s2 += s1;
|
||||||
|
s1 += buf[index++]; s2 += s1;
|
||||||
|
s1 += buf[index++]; s2 += s1;
|
||||||
|
s1 += buf[index++]; s2 += s1;
|
||||||
|
k -= 16;
|
||||||
|
}
|
||||||
|
if (k != 0)
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
s1 += buf[index++];
|
||||||
|
s2 += s1;
|
||||||
|
}
|
||||||
|
while (--k != 0);
|
||||||
|
}
|
||||||
|
s1 %= BASE;
|
||||||
|
s2 %= BASE;
|
||||||
|
}
|
||||||
|
return (uint)((s2 << 16) | s1);
|
||||||
|
}
|
||||||
|
#pragma warning restore 3001
|
||||||
|
#pragma warning restore 3002
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7d946fbf5f38d4049a7b50fe52bd8b0e
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,606 @@
|
|||||||
|
// ZlibBaseStream.cs
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Copyright (c) 2009 Dino Chiesa and Microsoft Corporation.
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This code module is part of DotNetZip, a zipfile class library.
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This code is licensed under the Microsoft Public License.
|
||||||
|
// See the file License.txt for the license details.
|
||||||
|
// More info on: http://dotnetzip.codeplex.com
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// last saved (in emacs):
|
||||||
|
// Time-stamp: <2011-August-06 21:22:38>
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This module defines the ZlibBaseStream class, which is an intnernal
|
||||||
|
// base class for DeflateStream, ZlibStream and GZipStream.
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace BestHTTP.Decompression.Zlib
|
||||||
|
{
|
||||||
|
|
||||||
|
internal enum ZlibStreamFlavor { ZLIB = 1950, DEFLATE = 1951, GZIP = 1952 }
|
||||||
|
|
||||||
|
internal class ZlibBaseStream : System.IO.Stream
|
||||||
|
{
|
||||||
|
protected internal ZlibCodec _z = null; // deferred init... new ZlibCodec();
|
||||||
|
|
||||||
|
protected internal StreamMode _streamMode = StreamMode.Undefined;
|
||||||
|
protected internal FlushType _flushMode;
|
||||||
|
protected internal ZlibStreamFlavor _flavor;
|
||||||
|
protected internal CompressionMode _compressionMode;
|
||||||
|
protected internal CompressionLevel _level;
|
||||||
|
protected internal bool _leaveOpen;
|
||||||
|
protected internal byte[] _workingBuffer;
|
||||||
|
protected internal int _bufferSize = ZlibConstants.WorkingBufferSizeDefault;
|
||||||
|
protected internal int windowBitsMax;
|
||||||
|
protected internal byte[] _buf1 = new byte[1];
|
||||||
|
|
||||||
|
protected internal System.IO.Stream _stream;
|
||||||
|
protected internal CompressionStrategy Strategy = CompressionStrategy.Default;
|
||||||
|
|
||||||
|
// workitem 7159
|
||||||
|
BestHTTP.Decompression.Crc.CRC32 crc;
|
||||||
|
protected internal string _GzipFileName;
|
||||||
|
protected internal string _GzipComment;
|
||||||
|
protected internal DateTime _GzipMtime;
|
||||||
|
protected internal int _gzipHeaderByteCount;
|
||||||
|
|
||||||
|
internal int Crc32 { get { if (crc == null) return 0; return crc.Crc32Result; } }
|
||||||
|
|
||||||
|
public ZlibBaseStream(System.IO.Stream stream,
|
||||||
|
CompressionMode compressionMode,
|
||||||
|
CompressionLevel level,
|
||||||
|
ZlibStreamFlavor flavor,
|
||||||
|
bool leaveOpen)
|
||||||
|
:this(stream, compressionMode, level, flavor,leaveOpen, ZlibConstants.WindowBitsDefault)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
public ZlibBaseStream(System.IO.Stream stream,
|
||||||
|
CompressionMode compressionMode,
|
||||||
|
CompressionLevel level,
|
||||||
|
ZlibStreamFlavor flavor,
|
||||||
|
bool leaveOpen,
|
||||||
|
int windowBits)
|
||||||
|
: base()
|
||||||
|
{
|
||||||
|
this._flushMode = FlushType.None;
|
||||||
|
//this._workingBuffer = new byte[WORKING_BUFFER_SIZE_DEFAULT];
|
||||||
|
this._stream = stream;
|
||||||
|
this._leaveOpen = leaveOpen;
|
||||||
|
this._compressionMode = compressionMode;
|
||||||
|
this._flavor = flavor;
|
||||||
|
this._level = level;
|
||||||
|
this.windowBitsMax = windowBits;
|
||||||
|
// workitem 7159
|
||||||
|
if (flavor == ZlibStreamFlavor.GZIP)
|
||||||
|
{
|
||||||
|
this.crc = new BestHTTP.Decompression.Crc.CRC32();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected internal bool _wantCompress
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (this._compressionMode == CompressionMode.Compress);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ZlibCodec z
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_z == null)
|
||||||
|
{
|
||||||
|
bool wantRfc1950Header = (this._flavor == ZlibStreamFlavor.ZLIB);
|
||||||
|
_z = new ZlibCodec();
|
||||||
|
if (this._compressionMode == CompressionMode.Decompress)
|
||||||
|
{
|
||||||
|
_z.InitializeInflate(this.windowBitsMax, wantRfc1950Header);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_z.Strategy = Strategy;
|
||||||
|
_z.InitializeDeflate(this._level, this.windowBitsMax, wantRfc1950Header);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private byte[] workingBuffer
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_workingBuffer == null)
|
||||||
|
_workingBuffer = Extensions.VariableSizedBufferPool.Get(_bufferSize, true);
|
||||||
|
return _workingBuffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public override void Write(System.Byte[] buffer, int offset, int count)
|
||||||
|
{
|
||||||
|
// workitem 7159
|
||||||
|
// calculate the CRC on the unccompressed data (before writing)
|
||||||
|
if (crc != null)
|
||||||
|
crc.SlurpBlock(buffer, offset, count);
|
||||||
|
|
||||||
|
if (_streamMode == StreamMode.Undefined)
|
||||||
|
_streamMode = StreamMode.Writer;
|
||||||
|
else if (_streamMode != StreamMode.Writer)
|
||||||
|
throw new ZlibException("Cannot Write after Reading.");
|
||||||
|
|
||||||
|
if (count == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// first reference of z property will initialize the private var _z
|
||||||
|
z.InputBuffer = buffer;
|
||||||
|
_z.NextIn = offset;
|
||||||
|
_z.AvailableBytesIn = count;
|
||||||
|
bool done = false;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
_z.OutputBuffer = workingBuffer;
|
||||||
|
_z.NextOut = 0;
|
||||||
|
_z.AvailableBytesOut = _workingBuffer.Length;
|
||||||
|
int rc = (_wantCompress)
|
||||||
|
? _z.Deflate(_flushMode)
|
||||||
|
: _z.Inflate(_flushMode);
|
||||||
|
if (rc != ZlibConstants.Z_OK && rc != ZlibConstants.Z_STREAM_END)
|
||||||
|
throw new ZlibException((_wantCompress ? "de" : "in") + "flating: " + _z.Message);
|
||||||
|
|
||||||
|
//if (_workingBuffer.Length - _z.AvailableBytesOut > 0)
|
||||||
|
_stream.Write(_workingBuffer, 0, _workingBuffer.Length - _z.AvailableBytesOut);
|
||||||
|
|
||||||
|
done = _z.AvailableBytesIn == 0 && _z.AvailableBytesOut != 0;
|
||||||
|
|
||||||
|
// If GZIP and de-compress, we're done when 8 bytes remain.
|
||||||
|
if (_flavor == ZlibStreamFlavor.GZIP && !_wantCompress)
|
||||||
|
done = (_z.AvailableBytesIn == 8 && _z.AvailableBytesOut != 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
while (!done);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void finish()
|
||||||
|
{
|
||||||
|
if (_z == null) return;
|
||||||
|
|
||||||
|
if (_streamMode == StreamMode.Writer)
|
||||||
|
{
|
||||||
|
bool done = false;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
_z.OutputBuffer = workingBuffer;
|
||||||
|
_z.NextOut = 0;
|
||||||
|
_z.AvailableBytesOut = _workingBuffer.Length;
|
||||||
|
int rc = (_wantCompress)
|
||||||
|
? _z.Deflate(FlushType.Finish)
|
||||||
|
: _z.Inflate(FlushType.Finish);
|
||||||
|
|
||||||
|
if (rc != ZlibConstants.Z_STREAM_END && rc != ZlibConstants.Z_OK)
|
||||||
|
{
|
||||||
|
string verb = (_wantCompress ? "de" : "in") + "flating";
|
||||||
|
if (_z.Message == null)
|
||||||
|
throw new ZlibException(String.Format("{0}: (rc = {1})", verb, rc));
|
||||||
|
else
|
||||||
|
throw new ZlibException(verb + ": " + _z.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_workingBuffer.Length - _z.AvailableBytesOut > 0)
|
||||||
|
{
|
||||||
|
_stream.Write(_workingBuffer, 0, _workingBuffer.Length - _z.AvailableBytesOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
done = _z.AvailableBytesIn == 0 && _z.AvailableBytesOut != 0;
|
||||||
|
// If GZIP and de-compress, we're done when 8 bytes remain.
|
||||||
|
if (_flavor == ZlibStreamFlavor.GZIP && !_wantCompress)
|
||||||
|
done = (_z.AvailableBytesIn == 8 && _z.AvailableBytesOut != 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
while (!done);
|
||||||
|
|
||||||
|
Flush();
|
||||||
|
|
||||||
|
// workitem 7159
|
||||||
|
if (_flavor == ZlibStreamFlavor.GZIP)
|
||||||
|
{
|
||||||
|
if (_wantCompress)
|
||||||
|
{
|
||||||
|
// Emit the GZIP trailer: CRC32 and size mod 2^32
|
||||||
|
int c1 = crc.Crc32Result;
|
||||||
|
_stream.Write(BitConverter.GetBytes(c1), 0, 4);
|
||||||
|
int c2 = (Int32)(crc.TotalBytesRead & 0x00000000FFFFFFFF);
|
||||||
|
_stream.Write(BitConverter.GetBytes(c2), 0, 4);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new ZlibException("Writing with decompression is not supported.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// workitem 7159
|
||||||
|
else if (_streamMode == StreamMode.Reader)
|
||||||
|
{
|
||||||
|
if (_flavor == ZlibStreamFlavor.GZIP)
|
||||||
|
{
|
||||||
|
if (!_wantCompress)
|
||||||
|
{
|
||||||
|
// workitem 8501: handle edge case (decompress empty stream)
|
||||||
|
if (_z.TotalBytesOut == 0L)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Read and potentially verify the GZIP trailer:
|
||||||
|
// CRC32 and size mod 2^32
|
||||||
|
byte[] trailer = Extensions.VariableSizedBufferPool.Get(8, true);
|
||||||
|
|
||||||
|
// workitems 8679 & 12554
|
||||||
|
if (_z.AvailableBytesIn < 8)
|
||||||
|
{
|
||||||
|
// Make sure we have read to the end of the stream
|
||||||
|
Array.Copy(_z.InputBuffer, _z.NextIn, trailer, 0, _z.AvailableBytesIn);
|
||||||
|
int bytesNeeded = 8 - _z.AvailableBytesIn;
|
||||||
|
int bytesRead = _stream.Read(trailer,
|
||||||
|
_z.AvailableBytesIn,
|
||||||
|
bytesNeeded);
|
||||||
|
if (bytesNeeded != bytesRead)
|
||||||
|
{
|
||||||
|
Extensions.VariableSizedBufferPool.Release(trailer);
|
||||||
|
throw new ZlibException(String.Format("Missing or incomplete GZIP trailer. Expected 8 bytes, got {0}.",
|
||||||
|
_z.AvailableBytesIn + bytesRead));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Array.Copy(_z.InputBuffer, _z.NextIn, trailer, 0, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
Int32 crc32_expected = BitConverter.ToInt32(trailer, 0);
|
||||||
|
Int32 crc32_actual = crc.Crc32Result;
|
||||||
|
Int32 isize_expected = BitConverter.ToInt32(trailer, 4);
|
||||||
|
Int32 isize_actual = (Int32)(_z.TotalBytesOut & 0x00000000FFFFFFFF);
|
||||||
|
|
||||||
|
if (crc32_actual != crc32_expected)
|
||||||
|
{
|
||||||
|
Extensions.VariableSizedBufferPool.Release(trailer);
|
||||||
|
throw new ZlibException(String.Format("Bad CRC32 in GZIP trailer. (actual({0:X8})!=expected({1:X8}))", crc32_actual, crc32_expected));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isize_actual != isize_expected)
|
||||||
|
{
|
||||||
|
Extensions.VariableSizedBufferPool.Release(trailer);
|
||||||
|
throw new ZlibException(String.Format("Bad size in GZIP trailer. (actual({0})!=expected({1}))", isize_actual, isize_expected));
|
||||||
|
}
|
||||||
|
Extensions.VariableSizedBufferPool.Release(trailer);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new ZlibException("Reading with compression is not supported.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void end()
|
||||||
|
{
|
||||||
|
if (z == null)
|
||||||
|
return;
|
||||||
|
if (_wantCompress)
|
||||||
|
{
|
||||||
|
_z.EndDeflate();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_z.EndInflate();
|
||||||
|
}
|
||||||
|
_z = null;
|
||||||
|
Extensions.VariableSizedBufferPool.Release(_workingBuffer);
|
||||||
|
_workingBuffer = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public
|
||||||
|
#if !NETFX_CORE
|
||||||
|
override
|
||||||
|
#endif
|
||||||
|
void Close()
|
||||||
|
{
|
||||||
|
if (_stream == null) return;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
end();
|
||||||
|
if (!_leaveOpen) _stream.Dispose();
|
||||||
|
_stream = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Flush()
|
||||||
|
{
|
||||||
|
_stream.Flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override System.Int64 Seek(System.Int64 offset, System.IO.SeekOrigin origin)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
//_outStream.Seek(offset, origin);
|
||||||
|
}
|
||||||
|
public override void SetLength(System.Int64 value)
|
||||||
|
{
|
||||||
|
_stream.SetLength(value);
|
||||||
|
nomoreinput = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if NOT
|
||||||
|
public int Read()
|
||||||
|
{
|
||||||
|
if (Read(_buf1, 0, 1) == 0)
|
||||||
|
return 0;
|
||||||
|
// calculate CRC after reading
|
||||||
|
if (crc!=null)
|
||||||
|
crc.SlurpBlock(_buf1,0,1);
|
||||||
|
return (_buf1[0] & 0xFF);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private bool nomoreinput = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private string ReadZeroTerminatedString()
|
||||||
|
{
|
||||||
|
var list = new System.Collections.Generic.List<byte>();
|
||||||
|
bool done = false;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
// workitem 7740
|
||||||
|
int n = _stream.Read(_buf1, 0, 1);
|
||||||
|
if (n != 1)
|
||||||
|
throw new ZlibException("Unexpected EOF reading GZIP header.");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_buf1[0] == 0)
|
||||||
|
done = true;
|
||||||
|
else
|
||||||
|
list.Add(_buf1[0]);
|
||||||
|
}
|
||||||
|
} while (!done);
|
||||||
|
byte[] a = list.ToArray();
|
||||||
|
return GZipStream.iso8859dash1.GetString(a, 0, a.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private int _ReadAndValidateGzipHeader()
|
||||||
|
{
|
||||||
|
int totalBytesRead = 0;
|
||||||
|
// read the header on the first read
|
||||||
|
byte[] header = Extensions.VariableSizedBufferPool.Get(10, true);
|
||||||
|
int n = _stream.Read(header, 0, 10);
|
||||||
|
|
||||||
|
// workitem 8501: handle edge case (decompress empty stream)
|
||||||
|
if (n == 0)
|
||||||
|
{
|
||||||
|
Extensions.VariableSizedBufferPool.Release(header);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (n != 10)
|
||||||
|
{
|
||||||
|
Extensions.VariableSizedBufferPool.Release(header);
|
||||||
|
throw new ZlibException("Not a valid GZIP stream.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (header[0] != 0x1F || header[1] != 0x8B || header[2] != 8)
|
||||||
|
{
|
||||||
|
Extensions.VariableSizedBufferPool.Release(header);
|
||||||
|
throw new ZlibException("Bad GZIP header.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Int32 timet = BitConverter.ToInt32(header, 4);
|
||||||
|
_GzipMtime = GZipStream._unixEpoch.AddSeconds(timet);
|
||||||
|
totalBytesRead += n;
|
||||||
|
if ((header[3] & 0x04) == 0x04)
|
||||||
|
{
|
||||||
|
// read and discard extra field
|
||||||
|
n = _stream.Read(header, 0, 2); // 2-byte length field
|
||||||
|
totalBytesRead += n;
|
||||||
|
|
||||||
|
Int16 extraLength = (Int16)(header[0] + header[1] * 256);
|
||||||
|
byte[] extra = Extensions.VariableSizedBufferPool.Get(extraLength, true);
|
||||||
|
n = _stream.Read(extra, 0, extraLength);
|
||||||
|
if (n != extraLength)
|
||||||
|
{
|
||||||
|
Extensions.VariableSizedBufferPool.Release(extra);
|
||||||
|
Extensions.VariableSizedBufferPool.Release(header);
|
||||||
|
throw new ZlibException("Unexpected end-of-file reading GZIP header.");
|
||||||
|
}
|
||||||
|
totalBytesRead += n;
|
||||||
|
}
|
||||||
|
if ((header[3] & 0x08) == 0x08)
|
||||||
|
_GzipFileName = ReadZeroTerminatedString();
|
||||||
|
if ((header[3] & 0x10) == 0x010)
|
||||||
|
_GzipComment = ReadZeroTerminatedString();
|
||||||
|
if ((header[3] & 0x02) == 0x02)
|
||||||
|
Read(_buf1, 0, 1); // CRC16, ignore
|
||||||
|
|
||||||
|
Extensions.VariableSizedBufferPool.Release(header);
|
||||||
|
return totalBytesRead;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public override System.Int32 Read(System.Byte[] buffer, System.Int32 offset, System.Int32 count)
|
||||||
|
{
|
||||||
|
// According to MS documentation, any implementation of the IO.Stream.Read function must:
|
||||||
|
// (a) throw an exception if offset & count reference an invalid part of the buffer,
|
||||||
|
// or if count < 0, or if buffer is null
|
||||||
|
// (b) return 0 only upon EOF, or if count = 0
|
||||||
|
// (c) if not EOF, then return at least 1 byte, up to <count> bytes
|
||||||
|
|
||||||
|
if (_streamMode == StreamMode.Undefined)
|
||||||
|
{
|
||||||
|
if (!this._stream.CanRead) throw new ZlibException("The stream is not readable.");
|
||||||
|
// for the first read, set up some controls.
|
||||||
|
_streamMode = StreamMode.Reader;
|
||||||
|
// (The first reference to _z goes through the private accessor which
|
||||||
|
// may initialize it.)
|
||||||
|
z.AvailableBytesIn = 0;
|
||||||
|
if (_flavor == ZlibStreamFlavor.GZIP)
|
||||||
|
{
|
||||||
|
_gzipHeaderByteCount = _ReadAndValidateGzipHeader();
|
||||||
|
// workitem 8501: handle edge case (decompress empty stream)
|
||||||
|
if (_gzipHeaderByteCount == 0)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_streamMode != StreamMode.Reader)
|
||||||
|
throw new ZlibException("Cannot Read after Writing.");
|
||||||
|
|
||||||
|
if (count == 0) return 0;
|
||||||
|
if (nomoreinput && _wantCompress) return 0; // workitem 8557
|
||||||
|
if (buffer == null) throw new ArgumentNullException("buffer");
|
||||||
|
if (count < 0) throw new ArgumentOutOfRangeException("count");
|
||||||
|
if (offset < buffer.GetLowerBound(0)) throw new ArgumentOutOfRangeException("offset");
|
||||||
|
if ((offset + count) > buffer.GetLength(0)) throw new ArgumentOutOfRangeException("count");
|
||||||
|
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
|
// set up the output of the deflate/inflate codec:
|
||||||
|
_z.OutputBuffer = buffer;
|
||||||
|
_z.NextOut = offset;
|
||||||
|
_z.AvailableBytesOut = count;
|
||||||
|
|
||||||
|
// This is necessary in case _workingBuffer has been resized. (new byte[])
|
||||||
|
// (The first reference to _workingBuffer goes through the private accessor which
|
||||||
|
// may initialize it.)
|
||||||
|
_z.InputBuffer = workingBuffer;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
// need data in _workingBuffer in order to deflate/inflate. Here, we check if we have any.
|
||||||
|
if ((_z.AvailableBytesIn == 0) && (!nomoreinput))
|
||||||
|
{
|
||||||
|
// No data available, so try to Read data from the captive stream.
|
||||||
|
_z.NextIn = 0;
|
||||||
|
_z.AvailableBytesIn = _stream.Read(_workingBuffer, 0, _workingBuffer.Length);
|
||||||
|
if (_z.AvailableBytesIn == 0)
|
||||||
|
nomoreinput = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
// we have data in InputBuffer; now compress or decompress as appropriate
|
||||||
|
rc = (_wantCompress)
|
||||||
|
? _z.Deflate(_flushMode)
|
||||||
|
: _z.Inflate(_flushMode);
|
||||||
|
|
||||||
|
if (nomoreinput && (rc == ZlibConstants.Z_BUF_ERROR))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (rc != ZlibConstants.Z_OK && rc != ZlibConstants.Z_STREAM_END)
|
||||||
|
throw new ZlibException(String.Format("{0}flating: rc={1} msg={2}", (_wantCompress ? "de" : "in"), rc, _z.Message));
|
||||||
|
|
||||||
|
if ((nomoreinput || rc == ZlibConstants.Z_STREAM_END) && (_z.AvailableBytesOut == count))
|
||||||
|
break; // nothing more to read
|
||||||
|
}
|
||||||
|
//while (_z.AvailableBytesOut == count && rc == ZlibConstants.Z_OK);
|
||||||
|
while (_z.AvailableBytesOut > 0 && !nomoreinput && rc == ZlibConstants.Z_OK);
|
||||||
|
|
||||||
|
|
||||||
|
// workitem 8557
|
||||||
|
// is there more room in output?
|
||||||
|
if (_z.AvailableBytesOut > 0)
|
||||||
|
{
|
||||||
|
if (rc == ZlibConstants.Z_OK && _z.AvailableBytesIn == 0)
|
||||||
|
{
|
||||||
|
// deferred
|
||||||
|
}
|
||||||
|
|
||||||
|
// are we completely done reading?
|
||||||
|
if (nomoreinput)
|
||||||
|
{
|
||||||
|
// and in compression?
|
||||||
|
if (_wantCompress)
|
||||||
|
{
|
||||||
|
// no more input data available; therefore we flush to
|
||||||
|
// try to complete the read
|
||||||
|
rc = _z.Deflate(FlushType.Finish);
|
||||||
|
|
||||||
|
if (rc != ZlibConstants.Z_OK && rc != ZlibConstants.Z_STREAM_END)
|
||||||
|
throw new ZlibException(String.Format("Deflating: rc={0} msg={1}", rc, _z.Message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
rc = (count - _z.AvailableBytesOut);
|
||||||
|
|
||||||
|
// calculate CRC after reading
|
||||||
|
if (crc != null)
|
||||||
|
crc.SlurpBlock(buffer, offset, rc);
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public override System.Boolean CanRead
|
||||||
|
{
|
||||||
|
get { return this._stream.CanRead; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override System.Boolean CanSeek
|
||||||
|
{
|
||||||
|
get { return this._stream.CanSeek; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override System.Boolean CanWrite
|
||||||
|
{
|
||||||
|
get { return this._stream.CanWrite; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override System.Int64 Length
|
||||||
|
{
|
||||||
|
get { return _stream.Length; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override long Position
|
||||||
|
{
|
||||||
|
get { throw new NotImplementedException(); }
|
||||||
|
set { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal enum StreamMode
|
||||||
|
{
|
||||||
|
Writer,
|
||||||
|
Reader,
|
||||||
|
Undefined,
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b34dd239e486b474aad68fb4080797c8
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,712 @@
|
|||||||
|
// ZlibCodec.cs
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Copyright (c) 2009 Dino Chiesa and Microsoft Corporation.
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This code module is part of DotNetZip, a zipfile class library.
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This code is licensed under the Microsoft Public License.
|
||||||
|
// See the file License.txt for the license details.
|
||||||
|
// More info on: http://dotnetzip.codeplex.com
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// last saved (in emacs):
|
||||||
|
// Time-stamp: <2009-November-03 15:40:51>
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This module defines a Codec for ZLIB compression and
|
||||||
|
// decompression. This code extends code that was based the jzlib
|
||||||
|
// implementation of zlib, but this code is completely novel. The codec
|
||||||
|
// class is new, and encapsulates some behaviors that are new, and some
|
||||||
|
// that were present in other classes in the jzlib code base. In
|
||||||
|
// keeping with the license for jzlib, the copyright to the jzlib code
|
||||||
|
// is included below.
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer in
|
||||||
|
// the documentation and/or other materials provided with the distribution.
|
||||||
|
//
|
||||||
|
// 3. The names of the authors may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||||
|
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
||||||
|
// INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||||
|
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||||
|
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This program is based on zlib-1.1.3; credit to authors
|
||||||
|
// Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
|
||||||
|
// and contributors of zlib.
|
||||||
|
//
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using Interop=System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace BestHTTP.Decompression.Zlib
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Encoder and Decoder for ZLIB and DEFLATE (IETF RFC1950 and RFC1951).
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
/// This class compresses and decompresses data according to the Deflate algorithm
|
||||||
|
/// and optionally, the ZLIB format, as documented in <see
|
||||||
|
/// href="http://www.ietf.org/rfc/rfc1950.txt">RFC 1950 - ZLIB</see> and <see
|
||||||
|
/// href="http://www.ietf.org/rfc/rfc1951.txt">RFC 1951 - DEFLATE</see>.
|
||||||
|
/// </remarks>
|
||||||
|
sealed internal class ZlibCodec
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The buffer from which data is taken.
|
||||||
|
/// </summary>
|
||||||
|
public byte[] InputBuffer;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// An index into the InputBuffer array, indicating where to start reading.
|
||||||
|
/// </summary>
|
||||||
|
public int NextIn;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The number of bytes available in the InputBuffer, starting at NextIn.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Generally you should set this to InputBuffer.Length before the first Inflate() or Deflate() call.
|
||||||
|
/// The class will update this number as calls to Inflate/Deflate are made.
|
||||||
|
/// </remarks>
|
||||||
|
public int AvailableBytesIn;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Total number of bytes read so far, through all calls to Inflate()/Deflate().
|
||||||
|
/// </summary>
|
||||||
|
public long TotalBytesIn;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Buffer to store output data.
|
||||||
|
/// </summary>
|
||||||
|
public byte[] OutputBuffer;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// An index into the OutputBuffer array, indicating where to start writing.
|
||||||
|
/// </summary>
|
||||||
|
public int NextOut;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The number of bytes available in the OutputBuffer, starting at NextOut.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Generally you should set this to OutputBuffer.Length before the first Inflate() or Deflate() call.
|
||||||
|
/// The class will update this number as calls to Inflate/Deflate are made.
|
||||||
|
/// </remarks>
|
||||||
|
public int AvailableBytesOut;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Total number of bytes written to the output so far, through all calls to Inflate()/Deflate().
|
||||||
|
/// </summary>
|
||||||
|
public long TotalBytesOut;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// used for diagnostics, when something goes wrong!
|
||||||
|
/// </summary>
|
||||||
|
public System.String Message;
|
||||||
|
|
||||||
|
internal DeflateManager dstate;
|
||||||
|
internal InflateManager istate;
|
||||||
|
|
||||||
|
internal uint _Adler32;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The compression level to use in this codec. Useful only in compression mode.
|
||||||
|
/// </summary>
|
||||||
|
public CompressionLevel CompressLevel = CompressionLevel.Default;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The number of Window Bits to use.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// This gauges the size of the sliding window, and hence the
|
||||||
|
/// compression effectiveness as well as memory consumption. It's best to just leave this
|
||||||
|
/// setting alone if you don't know what it is. The maximum value is 15 bits, which implies
|
||||||
|
/// a 32k window.
|
||||||
|
/// </remarks>
|
||||||
|
public int WindowBits = ZlibConstants.WindowBitsDefault;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The compression strategy to use.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// This is only effective in compression. The theory offered by ZLIB is that different
|
||||||
|
/// strategies could potentially produce significant differences in compression behavior
|
||||||
|
/// for different data sets. Unfortunately I don't have any good recommendations for how
|
||||||
|
/// to set it differently. When I tested changing the strategy I got minimally different
|
||||||
|
/// compression performance. It's best to leave this property alone if you don't have a
|
||||||
|
/// good feel for it. Or, you may want to produce a test harness that runs through the
|
||||||
|
/// different strategy options and evaluates them on different file types. If you do that,
|
||||||
|
/// let me know your results.
|
||||||
|
/// </remarks>
|
||||||
|
public CompressionStrategy Strategy = CompressionStrategy.Default;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The Adler32 checksum on the data transferred through the codec so far. You probably don't need to look at this.
|
||||||
|
/// </summary>
|
||||||
|
public int Adler32 { get { return (int)_Adler32; } }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a ZlibCodec.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// If you use this default constructor, you will later have to explicitly call
|
||||||
|
/// InitializeInflate() or InitializeDeflate() before using the ZlibCodec to compress
|
||||||
|
/// or decompress.
|
||||||
|
/// </remarks>
|
||||||
|
public ZlibCodec() { }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a ZlibCodec that either compresses or decompresses.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mode">
|
||||||
|
/// Indicates whether the codec should compress (deflate) or decompress (inflate).
|
||||||
|
/// </param>
|
||||||
|
public ZlibCodec(CompressionMode mode)
|
||||||
|
{
|
||||||
|
if (mode == CompressionMode.Compress)
|
||||||
|
{
|
||||||
|
int rc = InitializeDeflate();
|
||||||
|
if (rc != ZlibConstants.Z_OK) throw new ZlibException("Cannot initialize for deflate.");
|
||||||
|
}
|
||||||
|
else if (mode == CompressionMode.Decompress)
|
||||||
|
{
|
||||||
|
int rc = InitializeInflate();
|
||||||
|
if (rc != ZlibConstants.Z_OK) throw new ZlibException("Cannot initialize for inflate.");
|
||||||
|
}
|
||||||
|
else throw new ZlibException("Invalid ZlibStreamFlavor.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialize the inflation state.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// It is not necessary to call this before using the ZlibCodec to inflate data;
|
||||||
|
/// It is implicitly called when you call the constructor.
|
||||||
|
/// </remarks>
|
||||||
|
/// <returns>Z_OK if everything goes well.</returns>
|
||||||
|
public int InitializeInflate()
|
||||||
|
{
|
||||||
|
return InitializeInflate(this.WindowBits);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialize the inflation state with an explicit flag to
|
||||||
|
/// govern the handling of RFC1950 header bytes.
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
/// By default, the ZLIB header defined in <see
|
||||||
|
/// href="http://www.ietf.org/rfc/rfc1950.txt">RFC 1950</see> is expected. If
|
||||||
|
/// you want to read a zlib stream you should specify true for
|
||||||
|
/// expectRfc1950Header. If you have a deflate stream, you will want to specify
|
||||||
|
/// false. It is only necessary to invoke this initializer explicitly if you
|
||||||
|
/// want to specify false.
|
||||||
|
/// </remarks>
|
||||||
|
///
|
||||||
|
/// <param name="expectRfc1950Header">whether to expect an RFC1950 header byte
|
||||||
|
/// pair when reading the stream of data to be inflated.</param>
|
||||||
|
///
|
||||||
|
/// <returns>Z_OK if everything goes well.</returns>
|
||||||
|
public int InitializeInflate(bool expectRfc1950Header)
|
||||||
|
{
|
||||||
|
return InitializeInflate(this.WindowBits, expectRfc1950Header);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialize the ZlibCodec for inflation, with the specified number of window bits.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="windowBits">The number of window bits to use. If you need to ask what that is,
|
||||||
|
/// then you shouldn't be calling this initializer.</param>
|
||||||
|
/// <returns>Z_OK if all goes well.</returns>
|
||||||
|
public int InitializeInflate(int windowBits)
|
||||||
|
{
|
||||||
|
this.WindowBits = windowBits;
|
||||||
|
return InitializeInflate(windowBits, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialize the inflation state with an explicit flag to govern the handling of
|
||||||
|
/// RFC1950 header bytes.
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <remarks>
|
||||||
|
/// If you want to read a zlib stream you should specify true for
|
||||||
|
/// expectRfc1950Header. In this case, the library will expect to find a ZLIB
|
||||||
|
/// header, as defined in <see href="http://www.ietf.org/rfc/rfc1950.txt">RFC
|
||||||
|
/// 1950</see>, in the compressed stream. If you will be reading a DEFLATE or
|
||||||
|
/// GZIP stream, which does not have such a header, you will want to specify
|
||||||
|
/// false.
|
||||||
|
/// </remarks>
|
||||||
|
///
|
||||||
|
/// <param name="expectRfc1950Header">whether to expect an RFC1950 header byte pair when reading
|
||||||
|
/// the stream of data to be inflated.</param>
|
||||||
|
/// <param name="windowBits">The number of window bits to use. If you need to ask what that is,
|
||||||
|
/// then you shouldn't be calling this initializer.</param>
|
||||||
|
/// <returns>Z_OK if everything goes well.</returns>
|
||||||
|
public int InitializeInflate(int windowBits, bool expectRfc1950Header)
|
||||||
|
{
|
||||||
|
this.WindowBits = windowBits;
|
||||||
|
if (dstate != null) throw new ZlibException("You may not call InitializeInflate() after calling InitializeDeflate().");
|
||||||
|
istate = new InflateManager(expectRfc1950Header);
|
||||||
|
return istate.Initialize(this, windowBits);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Inflate the data in the InputBuffer, placing the result in the OutputBuffer.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// You must have set InputBuffer and OutputBuffer, NextIn and NextOut, and AvailableBytesIn and
|
||||||
|
/// AvailableBytesOut before calling this method.
|
||||||
|
/// </remarks>
|
||||||
|
/// <example>
|
||||||
|
/// <code>
|
||||||
|
/// private void InflateBuffer()
|
||||||
|
/// {
|
||||||
|
/// int bufferSize = 1024;
|
||||||
|
/// byte[] buffer = new byte[bufferSize];
|
||||||
|
/// ZlibCodec decompressor = new ZlibCodec();
|
||||||
|
///
|
||||||
|
/// Console.WriteLine("\n============================================");
|
||||||
|
/// Console.WriteLine("Size of Buffer to Inflate: {0} bytes.", CompressedBytes.Length);
|
||||||
|
/// MemoryStream ms = new MemoryStream(DecompressedBytes);
|
||||||
|
///
|
||||||
|
/// int rc = decompressor.InitializeInflate();
|
||||||
|
///
|
||||||
|
/// decompressor.InputBuffer = CompressedBytes;
|
||||||
|
/// decompressor.NextIn = 0;
|
||||||
|
/// decompressor.AvailableBytesIn = CompressedBytes.Length;
|
||||||
|
///
|
||||||
|
/// decompressor.OutputBuffer = buffer;
|
||||||
|
///
|
||||||
|
/// // pass 1: inflate
|
||||||
|
/// do
|
||||||
|
/// {
|
||||||
|
/// decompressor.NextOut = 0;
|
||||||
|
/// decompressor.AvailableBytesOut = buffer.Length;
|
||||||
|
/// rc = decompressor.Inflate(FlushType.None);
|
||||||
|
///
|
||||||
|
/// if (rc != ZlibConstants.Z_OK && rc != ZlibConstants.Z_STREAM_END)
|
||||||
|
/// throw new Exception("inflating: " + decompressor.Message);
|
||||||
|
///
|
||||||
|
/// ms.Write(decompressor.OutputBuffer, 0, buffer.Length - decompressor.AvailableBytesOut);
|
||||||
|
/// }
|
||||||
|
/// while (decompressor.AvailableBytesIn > 0 || decompressor.AvailableBytesOut == 0);
|
||||||
|
///
|
||||||
|
/// // pass 2: finish and flush
|
||||||
|
/// do
|
||||||
|
/// {
|
||||||
|
/// decompressor.NextOut = 0;
|
||||||
|
/// decompressor.AvailableBytesOut = buffer.Length;
|
||||||
|
/// rc = decompressor.Inflate(FlushType.Finish);
|
||||||
|
///
|
||||||
|
/// if (rc != ZlibConstants.Z_STREAM_END && rc != ZlibConstants.Z_OK)
|
||||||
|
/// throw new Exception("inflating: " + decompressor.Message);
|
||||||
|
///
|
||||||
|
/// if (buffer.Length - decompressor.AvailableBytesOut > 0)
|
||||||
|
/// ms.Write(buffer, 0, buffer.Length - decompressor.AvailableBytesOut);
|
||||||
|
/// }
|
||||||
|
/// while (decompressor.AvailableBytesIn > 0 || decompressor.AvailableBytesOut == 0);
|
||||||
|
///
|
||||||
|
/// decompressor.EndInflate();
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// </code>
|
||||||
|
/// </example>
|
||||||
|
/// <param name="flush">The flush to use when inflating.</param>
|
||||||
|
/// <returns>Z_OK if everything goes well.</returns>
|
||||||
|
public int Inflate(FlushType flush)
|
||||||
|
{
|
||||||
|
if (istate == null)
|
||||||
|
throw new ZlibException("No Inflate State!");
|
||||||
|
return istate.Inflate(flush);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ends an inflation session.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Call this after successively calling Inflate(). This will cause all buffers to be flushed.
|
||||||
|
/// After calling this you cannot call Inflate() without a intervening call to one of the
|
||||||
|
/// InitializeInflate() overloads.
|
||||||
|
/// </remarks>
|
||||||
|
/// <returns>Z_OK if everything goes well.</returns>
|
||||||
|
public int EndInflate()
|
||||||
|
{
|
||||||
|
if (istate == null)
|
||||||
|
throw new ZlibException("No Inflate State!");
|
||||||
|
int ret = istate.End();
|
||||||
|
istate = null;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// I don't know what this does!
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Z_OK if everything goes well.</returns>
|
||||||
|
public int SyncInflate()
|
||||||
|
{
|
||||||
|
if (istate == null)
|
||||||
|
throw new ZlibException("No Inflate State!");
|
||||||
|
return istate.Sync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialize the ZlibCodec for deflation operation.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The codec will use the MAX window bits and the default level of compression.
|
||||||
|
/// </remarks>
|
||||||
|
/// <example>
|
||||||
|
/// <code>
|
||||||
|
/// int bufferSize = 40000;
|
||||||
|
/// byte[] CompressedBytes = new byte[bufferSize];
|
||||||
|
/// byte[] DecompressedBytes = new byte[bufferSize];
|
||||||
|
///
|
||||||
|
/// ZlibCodec compressor = new ZlibCodec();
|
||||||
|
///
|
||||||
|
/// compressor.InitializeDeflate(CompressionLevel.Default);
|
||||||
|
///
|
||||||
|
/// compressor.InputBuffer = System.Text.ASCIIEncoding.ASCII.GetBytes(TextToCompress);
|
||||||
|
/// compressor.NextIn = 0;
|
||||||
|
/// compressor.AvailableBytesIn = compressor.InputBuffer.Length;
|
||||||
|
///
|
||||||
|
/// compressor.OutputBuffer = CompressedBytes;
|
||||||
|
/// compressor.NextOut = 0;
|
||||||
|
/// compressor.AvailableBytesOut = CompressedBytes.Length;
|
||||||
|
///
|
||||||
|
/// while (compressor.TotalBytesIn != TextToCompress.Length && compressor.TotalBytesOut < bufferSize)
|
||||||
|
/// {
|
||||||
|
/// compressor.Deflate(FlushType.None);
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// while (true)
|
||||||
|
/// {
|
||||||
|
/// int rc= compressor.Deflate(FlushType.Finish);
|
||||||
|
/// if (rc == ZlibConstants.Z_STREAM_END) break;
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// compressor.EndDeflate();
|
||||||
|
///
|
||||||
|
/// </code>
|
||||||
|
/// </example>
|
||||||
|
/// <returns>Z_OK if all goes well. You generally don't need to check the return code.</returns>
|
||||||
|
public int InitializeDeflate()
|
||||||
|
{
|
||||||
|
return _InternalInitializeDeflate(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialize the ZlibCodec for deflation operation, using the specified CompressionLevel.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The codec will use the maximum window bits (15) and the specified
|
||||||
|
/// CompressionLevel. It will emit a ZLIB stream as it compresses.
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="level">The compression level for the codec.</param>
|
||||||
|
/// <returns>Z_OK if all goes well.</returns>
|
||||||
|
public int InitializeDeflate(CompressionLevel level)
|
||||||
|
{
|
||||||
|
this.CompressLevel = level;
|
||||||
|
return _InternalInitializeDeflate(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialize the ZlibCodec for deflation operation, using the specified CompressionLevel,
|
||||||
|
/// and the explicit flag governing whether to emit an RFC1950 header byte pair.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The codec will use the maximum window bits (15) and the specified CompressionLevel.
|
||||||
|
/// If you want to generate a zlib stream, you should specify true for
|
||||||
|
/// wantRfc1950Header. In this case, the library will emit a ZLIB
|
||||||
|
/// header, as defined in <see href="http://www.ietf.org/rfc/rfc1950.txt">RFC
|
||||||
|
/// 1950</see>, in the compressed stream.
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="level">The compression level for the codec.</param>
|
||||||
|
/// <param name="wantRfc1950Header">whether to emit an initial RFC1950 byte pair in the compressed stream.</param>
|
||||||
|
/// <returns>Z_OK if all goes well.</returns>
|
||||||
|
public int InitializeDeflate(CompressionLevel level, bool wantRfc1950Header)
|
||||||
|
{
|
||||||
|
this.CompressLevel = level;
|
||||||
|
return _InternalInitializeDeflate(wantRfc1950Header);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialize the ZlibCodec for deflation operation, using the specified CompressionLevel,
|
||||||
|
/// and the specified number of window bits.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The codec will use the specified number of window bits and the specified CompressionLevel.
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="level">The compression level for the codec.</param>
|
||||||
|
/// <param name="bits">the number of window bits to use. If you don't know what this means, don't use this method.</param>
|
||||||
|
/// <returns>Z_OK if all goes well.</returns>
|
||||||
|
public int InitializeDeflate(CompressionLevel level, int bits)
|
||||||
|
{
|
||||||
|
this.CompressLevel = level;
|
||||||
|
this.WindowBits = bits;
|
||||||
|
return _InternalInitializeDeflate(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initialize the ZlibCodec for deflation operation, using the specified
|
||||||
|
/// CompressionLevel, the specified number of window bits, and the explicit flag
|
||||||
|
/// governing whether to emit an RFC1950 header byte pair.
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
/// <param name="level">The compression level for the codec.</param>
|
||||||
|
/// <param name="wantRfc1950Header">whether to emit an initial RFC1950 byte pair in the compressed stream.</param>
|
||||||
|
/// <param name="bits">the number of window bits to use. If you don't know what this means, don't use this method.</param>
|
||||||
|
/// <returns>Z_OK if all goes well.</returns>
|
||||||
|
public int InitializeDeflate(CompressionLevel level, int bits, bool wantRfc1950Header)
|
||||||
|
{
|
||||||
|
this.CompressLevel = level;
|
||||||
|
this.WindowBits = bits;
|
||||||
|
return _InternalInitializeDeflate(wantRfc1950Header);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int _InternalInitializeDeflate(bool wantRfc1950Header)
|
||||||
|
{
|
||||||
|
if (istate != null) throw new ZlibException("You may not call InitializeDeflate() after calling InitializeInflate().");
|
||||||
|
dstate = new DeflateManager();
|
||||||
|
dstate.WantRfc1950HeaderBytes = wantRfc1950Header;
|
||||||
|
|
||||||
|
return dstate.Initialize(this, this.CompressLevel, this.WindowBits, this.Strategy);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deflate one batch of data.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// You must have set InputBuffer and OutputBuffer before calling this method.
|
||||||
|
/// </remarks>
|
||||||
|
/// <example>
|
||||||
|
/// <code>
|
||||||
|
/// private void DeflateBuffer(CompressionLevel level)
|
||||||
|
/// {
|
||||||
|
/// int bufferSize = 1024;
|
||||||
|
/// byte[] buffer = new byte[bufferSize];
|
||||||
|
/// ZlibCodec compressor = new ZlibCodec();
|
||||||
|
///
|
||||||
|
/// Console.WriteLine("\n============================================");
|
||||||
|
/// Console.WriteLine("Size of Buffer to Deflate: {0} bytes.", UncompressedBytes.Length);
|
||||||
|
/// MemoryStream ms = new MemoryStream();
|
||||||
|
///
|
||||||
|
/// int rc = compressor.InitializeDeflate(level);
|
||||||
|
///
|
||||||
|
/// compressor.InputBuffer = UncompressedBytes;
|
||||||
|
/// compressor.NextIn = 0;
|
||||||
|
/// compressor.AvailableBytesIn = UncompressedBytes.Length;
|
||||||
|
///
|
||||||
|
/// compressor.OutputBuffer = buffer;
|
||||||
|
///
|
||||||
|
/// // pass 1: deflate
|
||||||
|
/// do
|
||||||
|
/// {
|
||||||
|
/// compressor.NextOut = 0;
|
||||||
|
/// compressor.AvailableBytesOut = buffer.Length;
|
||||||
|
/// rc = compressor.Deflate(FlushType.None);
|
||||||
|
///
|
||||||
|
/// if (rc != ZlibConstants.Z_OK && rc != ZlibConstants.Z_STREAM_END)
|
||||||
|
/// throw new Exception("deflating: " + compressor.Message);
|
||||||
|
///
|
||||||
|
/// ms.Write(compressor.OutputBuffer, 0, buffer.Length - compressor.AvailableBytesOut);
|
||||||
|
/// }
|
||||||
|
/// while (compressor.AvailableBytesIn > 0 || compressor.AvailableBytesOut == 0);
|
||||||
|
///
|
||||||
|
/// // pass 2: finish and flush
|
||||||
|
/// do
|
||||||
|
/// {
|
||||||
|
/// compressor.NextOut = 0;
|
||||||
|
/// compressor.AvailableBytesOut = buffer.Length;
|
||||||
|
/// rc = compressor.Deflate(FlushType.Finish);
|
||||||
|
///
|
||||||
|
/// if (rc != ZlibConstants.Z_STREAM_END && rc != ZlibConstants.Z_OK)
|
||||||
|
/// throw new Exception("deflating: " + compressor.Message);
|
||||||
|
///
|
||||||
|
/// if (buffer.Length - compressor.AvailableBytesOut > 0)
|
||||||
|
/// ms.Write(buffer, 0, buffer.Length - compressor.AvailableBytesOut);
|
||||||
|
/// }
|
||||||
|
/// while (compressor.AvailableBytesIn > 0 || compressor.AvailableBytesOut == 0);
|
||||||
|
///
|
||||||
|
/// compressor.EndDeflate();
|
||||||
|
///
|
||||||
|
/// ms.Seek(0, SeekOrigin.Begin);
|
||||||
|
/// CompressedBytes = new byte[compressor.TotalBytesOut];
|
||||||
|
/// ms.Read(CompressedBytes, 0, CompressedBytes.Length);
|
||||||
|
/// }
|
||||||
|
/// </code>
|
||||||
|
/// </example>
|
||||||
|
/// <param name="flush">whether to flush all data as you deflate. Generally you will want to
|
||||||
|
/// use Z_NO_FLUSH here, in a series of calls to Deflate(), and then call EndDeflate() to
|
||||||
|
/// flush everything.
|
||||||
|
/// </param>
|
||||||
|
/// <returns>Z_OK if all goes well.</returns>
|
||||||
|
public int Deflate(FlushType flush)
|
||||||
|
{
|
||||||
|
if (dstate == null)
|
||||||
|
throw new ZlibException("No Deflate State!");
|
||||||
|
return dstate.Deflate(flush);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// End a deflation session.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Call this after making a series of one or more calls to Deflate(). All buffers are flushed.
|
||||||
|
/// </remarks>
|
||||||
|
/// <returns>Z_OK if all goes well.</returns>
|
||||||
|
public int EndDeflate()
|
||||||
|
{
|
||||||
|
if (dstate == null)
|
||||||
|
throw new ZlibException("No Deflate State!");
|
||||||
|
// TODO: dinoch Tue, 03 Nov 2009 15:39 (test this)
|
||||||
|
//int ret = dstate.End();
|
||||||
|
dstate = null;
|
||||||
|
return ZlibConstants.Z_OK; //ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reset a codec for another deflation session.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Call this to reset the deflation state. For example if a thread is deflating
|
||||||
|
/// non-consecutive blocks, you can call Reset() after the Deflate(Sync) of the first
|
||||||
|
/// block and before the next Deflate(None) of the second block.
|
||||||
|
/// </remarks>
|
||||||
|
/// <returns>Z_OK if all goes well.</returns>
|
||||||
|
public void ResetDeflate()
|
||||||
|
{
|
||||||
|
if (dstate == null)
|
||||||
|
throw new ZlibException("No Deflate State!");
|
||||||
|
dstate.Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set the CompressionStrategy and CompressionLevel for a deflation session.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="level">the level of compression to use.</param>
|
||||||
|
/// <param name="strategy">the strategy to use for compression.</param>
|
||||||
|
/// <returns>Z_OK if all goes well.</returns>
|
||||||
|
public int SetDeflateParams(CompressionLevel level, CompressionStrategy strategy)
|
||||||
|
{
|
||||||
|
if (dstate == null)
|
||||||
|
throw new ZlibException("No Deflate State!");
|
||||||
|
return dstate.SetParams(level, strategy);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set the dictionary to be used for either Inflation or Deflation.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dictionary">The dictionary bytes to use.</param>
|
||||||
|
/// <returns>Z_OK if all goes well.</returns>
|
||||||
|
public int SetDictionary(byte[] dictionary)
|
||||||
|
{
|
||||||
|
if (istate != null)
|
||||||
|
return istate.SetDictionary(dictionary);
|
||||||
|
|
||||||
|
if (dstate != null)
|
||||||
|
return dstate.SetDictionary(dictionary);
|
||||||
|
|
||||||
|
throw new ZlibException("No Inflate or Deflate state!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Flush as much pending output as possible. All deflate() output goes
|
||||||
|
// through this function so some applications may wish to modify it
|
||||||
|
// to avoid allocating a large strm->next_out buffer and copying into it.
|
||||||
|
// (See also read_buf()).
|
||||||
|
internal void flush_pending()
|
||||||
|
{
|
||||||
|
int len = dstate.pendingCount;
|
||||||
|
|
||||||
|
if (len > AvailableBytesOut)
|
||||||
|
len = AvailableBytesOut;
|
||||||
|
if (len == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (dstate.pending.Length <= dstate.nextPending ||
|
||||||
|
OutputBuffer.Length <= NextOut ||
|
||||||
|
dstate.pending.Length < (dstate.nextPending + len) ||
|
||||||
|
OutputBuffer.Length < (NextOut + len))
|
||||||
|
{
|
||||||
|
throw new ZlibException(String.Format("Invalid State. (pending.Length={0}, pendingCount={1})",
|
||||||
|
dstate.pending.Length, dstate.pendingCount));
|
||||||
|
}
|
||||||
|
|
||||||
|
Array.Copy(dstate.pending, dstate.nextPending, OutputBuffer, NextOut, len);
|
||||||
|
|
||||||
|
NextOut += len;
|
||||||
|
dstate.nextPending += len;
|
||||||
|
TotalBytesOut += len;
|
||||||
|
AvailableBytesOut -= len;
|
||||||
|
dstate.pendingCount -= len;
|
||||||
|
if (dstate.pendingCount == 0)
|
||||||
|
{
|
||||||
|
dstate.nextPending = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read a new buffer from the current input stream, update the adler32
|
||||||
|
// and total number of bytes read. All deflate() input goes through
|
||||||
|
// this function so some applications may wish to modify it to avoid
|
||||||
|
// allocating a large strm->next_in buffer and copying from it.
|
||||||
|
// (See also flush_pending()).
|
||||||
|
internal int read_buf(byte[] buf, int start, int size)
|
||||||
|
{
|
||||||
|
int len = AvailableBytesIn;
|
||||||
|
|
||||||
|
if (len > size)
|
||||||
|
len = size;
|
||||||
|
if (len == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
AvailableBytesIn -= len;
|
||||||
|
|
||||||
|
if (dstate.WantRfc1950HeaderBytes)
|
||||||
|
{
|
||||||
|
_Adler32 = Adler.Adler32(_Adler32, InputBuffer, NextIn, len);
|
||||||
|
}
|
||||||
|
Array.Copy(InputBuffer, NextIn, buf, start, len);
|
||||||
|
NextIn += len;
|
||||||
|
TotalBytesIn += len;
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bc104cfa5b2ba31408766b86b9977226
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,128 @@
|
|||||||
|
// ZlibConstants.cs
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Copyright (c) 2009 Dino Chiesa and Microsoft Corporation.
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This code module is part of DotNetZip, a zipfile class library.
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This code is licensed under the Microsoft Public License.
|
||||||
|
// See the file License.txt for the license details.
|
||||||
|
// More info on: http://dotnetzip.codeplex.com
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// last saved (in emacs):
|
||||||
|
// Time-stamp: <2009-November-03 18:50:19>
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This module defines constants used by the zlib class library. This
|
||||||
|
// code is derived from the jzlib implementation of zlib, but
|
||||||
|
// significantly modified. In keeping with the license for jzlib, the
|
||||||
|
// copyright to that code is included here.
|
||||||
|
//
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are met:
|
||||||
|
//
|
||||||
|
// 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
// this list of conditions and the following disclaimer.
|
||||||
|
//
|
||||||
|
// 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer in
|
||||||
|
// the documentation and/or other materials provided with the distribution.
|
||||||
|
//
|
||||||
|
// 3. The names of the authors may not be used to endorse or promote products
|
||||||
|
// derived from this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||||
|
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
||||||
|
// INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||||
|
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||||
|
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
//
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This program is based on zlib-1.1.3; credit to authors
|
||||||
|
// Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
|
||||||
|
// and contributors of zlib.
|
||||||
|
//
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace BestHTTP.Decompression.Zlib
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A bunch of constants used in the Zlib interface.
|
||||||
|
/// </summary>
|
||||||
|
public static class ZlibConstants
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The maximum number of window bits for the Deflate algorithm.
|
||||||
|
/// </summary>
|
||||||
|
public const int WindowBitsMax = 15; // 32K LZ77 window
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The default number of window bits for the Deflate algorithm.
|
||||||
|
/// </summary>
|
||||||
|
public const int WindowBitsDefault = WindowBitsMax;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// indicates everything is A-OK
|
||||||
|
/// </summary>
|
||||||
|
public const int Z_OK = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates that the last operation reached the end of the stream.
|
||||||
|
/// </summary>
|
||||||
|
public const int Z_STREAM_END = 1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The operation ended in need of a dictionary.
|
||||||
|
/// </summary>
|
||||||
|
public const int Z_NEED_DICT = 2;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// There was an error with the stream - not enough data, not open and readable, etc.
|
||||||
|
/// </summary>
|
||||||
|
public const int Z_STREAM_ERROR = -2;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// There was an error with the data - not enough data, bad data, etc.
|
||||||
|
/// </summary>
|
||||||
|
public const int Z_DATA_ERROR = -3;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// There was an error with the working buffer.
|
||||||
|
/// </summary>
|
||||||
|
public const int Z_BUF_ERROR = -5;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The size of the working buffer used in the ZlibCodec class. Defaults to 8192 bytes.
|
||||||
|
/// </summary>
|
||||||
|
#if NETCF
|
||||||
|
public const int WorkingBufferSizeDefault = 8192;
|
||||||
|
#else
|
||||||
|
public const int WorkingBufferSizeDefault = 16384;
|
||||||
|
#endif
|
||||||
|
/// <summary>
|
||||||
|
/// The minimum size of the working buffer used in the ZlibCodec class. Currently it is 128 bytes.
|
||||||
|
/// </summary>
|
||||||
|
public const int WorkingBufferSizeMin = 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4cd9445fbeecd0642955b4ea35e211c8
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user