├── .gitattributes ├── .gitignore ├── ByteOrder.cs ├── CloseEventArgs.cs ├── CloseStatusCode.cs ├── Compatibility ├── SSMonoNetExtensions.cs └── SslProtocols.cs ├── CompressionMethod.cs ├── ErrorEventArgs.cs ├── Ext.cs ├── Fin.cs ├── HttpBase.cs ├── HttpRequest.cs ├── HttpResponse.cs ├── LICENSE.txt ├── LogData.cs ├── LogLevel.cs ├── Logger.cs ├── Mask.cs ├── MessageEventArgs.cs ├── Net ├── AuthenticationBase.cs ├── AuthenticationChallenge.cs ├── AuthenticationResponse.cs ├── AuthenticationSchemes.cs ├── Chunk.cs ├── ChunkStream.cs ├── ChunkedRequestStream.cs ├── ClientSslConfiguration.cs ├── Cookie.cs ├── CookieCollection.cs ├── CookieException.cs ├── CookieExtensions.cs ├── EndPointListener.cs ├── EndPointManager.cs ├── HttpBasicIdentity.cs ├── HttpConnection.cs ├── HttpDigestIdentity.cs ├── HttpHeaderInfo.cs ├── HttpHeaderType.cs ├── HttpListener.cs ├── HttpListenerAsyncResult.cs ├── HttpListenerContext.cs ├── HttpListenerException.cs ├── HttpListenerPrefix.cs ├── HttpListenerPrefixCollection.cs ├── HttpListenerRequest.cs ├── HttpListenerResponse.cs ├── HttpRequestHeader.cs ├── HttpResponseHeader.cs ├── HttpStatusCode.cs ├── HttpStreamAsyncResult.cs ├── HttpUtility.cs ├── HttpVersion.cs ├── InputChunkState.cs ├── InputState.cs ├── LineState.cs ├── NetworkCredential.cs ├── ProtocolViolationException.cs ├── QueryStringCollection.cs ├── ReadBufferState.cs ├── RequestStream.cs ├── ResponseStream.cs ├── RuntimeHelpers.cs ├── ServerSslConfiguration.cs ├── WebEventCodes.cs ├── WebException.cs ├── WebExceptionStatus.cs ├── WebHeaderCollection.cs └── WebSockets │ ├── HttpListenerWebSocketContext.cs │ ├── TcpListenerWebSocketContext.cs │ └── WebSocketContext.cs ├── Opcode.cs ├── PayloadData.cs ├── Properties └── AssemblyInfo.cs ├── Rsv.cs ├── SSharpWebSocketLibrary.csproj ├── Server ├── HttpRequestCancelEventArgs.cs ├── HttpRequestEventArgs.cs ├── HttpResolveWebSocketServiceHostEventArgs.cs ├── HttpServer.cs ├── IWebSocketSession.cs ├── ServerState.cs ├── WebSocketBehavior.cs ├── WebSocketServer.cs ├── WebSocketServiceHost.cs ├── WebSocketServiceHost`1.cs ├── WebSocketServiceManager.cs └── WebSocketSessionManager.cs ├── SocketFlags.cs ├── WebSocket.cs ├── WebSocketException.cs ├── WebSocketFrame.cs └── WebSocketState.cs /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | *.VC.db 84 | *.VC.VC.opendb 85 | 86 | # Visual Studio profiler 87 | *.psess 88 | *.vsp 89 | *.vspx 90 | *.sap 91 | 92 | # TFS 2012 Local Workspace 93 | $tf/ 94 | 95 | # Guidance Automation Toolkit 96 | *.gpState 97 | 98 | # ReSharper is a .NET coding add-in 99 | _ReSharper*/ 100 | *.[Rr]e[Ss]harper 101 | *.DotSettings.user 102 | 103 | # JustCode is a .NET coding add-in 104 | .JustCode 105 | 106 | # TeamCity is a build add-in 107 | _TeamCity* 108 | 109 | # DotCover is a Code Coverage Tool 110 | *.dotCover 111 | 112 | # NCrunch 113 | _NCrunch_* 114 | .*crunch*.local.xml 115 | nCrunchTemp_* 116 | 117 | # MightyMoose 118 | *.mm.* 119 | AutoTest.Net/ 120 | 121 | # Web workbench (sass) 122 | .sass-cache/ 123 | 124 | # Installshield output folder 125 | [Ee]xpress/ 126 | 127 | # DocProject is a documentation generator add-in 128 | DocProject/buildhelp/ 129 | DocProject/Help/*.HxT 130 | DocProject/Help/*.HxC 131 | DocProject/Help/*.hhc 132 | DocProject/Help/*.hhk 133 | DocProject/Help/*.hhp 134 | DocProject/Help/Html2 135 | DocProject/Help/html 136 | 137 | # Click-Once directory 138 | publish/ 139 | 140 | # Publish Web Output 141 | *.[Pp]ublish.xml 142 | *.azurePubxml 143 | # TODO: Comment the next line if you want to checkin your web deploy settings 144 | # but database connection strings (with potential passwords) will be unencrypted 145 | *.pubxml 146 | *.publishproj 147 | 148 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 149 | # checkin your Azure Web App publish settings, but sensitive information contained 150 | # in these scripts will be unencrypted 151 | PublishScripts/ 152 | 153 | # NuGet Packages 154 | *.nupkg 155 | # The packages folder can be ignored because of Package Restore 156 | **/packages/* 157 | # except build/, which is used as an MSBuild target. 158 | !**/packages/build/ 159 | # Uncomment if necessary however generally it will be regenerated when needed 160 | #!**/packages/repositories.config 161 | # NuGet v3's project.json files produces more ignoreable files 162 | *.nuget.props 163 | *.nuget.targets 164 | 165 | # Microsoft Azure Build Output 166 | csx/ 167 | *.build.csdef 168 | 169 | # Microsoft Azure Emulator 170 | ecf/ 171 | rcf/ 172 | 173 | # Windows Store app package directories and files 174 | AppPackages/ 175 | BundleArtifacts/ 176 | Package.StoreAssociation.xml 177 | _pkginfo.txt 178 | 179 | # Visual Studio cache files 180 | # files ending in .cache can be ignored 181 | *.[Cc]ache 182 | # but keep track of directories ending in .cache 183 | !*.[Cc]ache/ 184 | 185 | # Others 186 | ClientBin/ 187 | ~$* 188 | *~ 189 | *.dbmdl 190 | *.dbproj.schemaview 191 | *.pfx 192 | *.publishsettings 193 | node_modules/ 194 | orleans.codegen.cs 195 | 196 | # Since there are multiple workflows, uncomment next line to ignore bower_components 197 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 198 | #bower_components/ 199 | 200 | # RIA/Silverlight projects 201 | Generated_Code/ 202 | 203 | # Backup & report files from converting an old project file 204 | # to a newer Visual Studio version. Backup files are not needed, 205 | # because we have git ;-) 206 | _UpgradeReport_Files/ 207 | Backup*/ 208 | UpgradeLog*.XML 209 | UpgradeLog*.htm 210 | 211 | # SQL Server files 212 | *.mdf 213 | *.ldf 214 | 215 | # Business Intelligence projects 216 | *.rdl.data 217 | *.bim.layout 218 | *.bim_*.settings 219 | 220 | # Microsoft Fakes 221 | FakesAssemblies/ 222 | 223 | # GhostDoc plugin setting file 224 | *.GhostDoc.xml 225 | 226 | # Node.js Tools for Visual Studio 227 | .ntvs_analysis.dat 228 | 229 | # Visual Studio 6 build log 230 | *.plg 231 | 232 | # Visual Studio 6 workspace options file 233 | *.opt 234 | 235 | # Visual Studio LightSwitch build output 236 | **/*.HTMLClient/GeneratedArtifacts 237 | **/*.DesktopClient/GeneratedArtifacts 238 | **/*.DesktopClient/ModelManifest.xml 239 | **/*.Server/GeneratedArtifacts 240 | **/*.Server/ModelManifest.xml 241 | _Pvt_Extensions 242 | 243 | # Paket dependency manager 244 | .paket/paket.exe 245 | paket-files/ 246 | 247 | # FAKE - F# Make 248 | .fake/ 249 | 250 | # JetBrains Rider 251 | .idea/ 252 | *.sln.iml 253 | 254 | # ========================= 255 | # Operating System Files 256 | # ========================= 257 | 258 | # OSX 259 | # ========================= 260 | 261 | .DS_Store 262 | .AppleDouble 263 | .LSOverride 264 | 265 | # Thumbnails 266 | ._* 267 | 268 | # Files that might appear in the root of a volume 269 | .DocumentRevisions-V100 270 | .fseventsd 271 | .Spotlight-V100 272 | .TemporaryItems 273 | .Trashes 274 | .VolumeIcon.icns 275 | 276 | # Directories potentially created on remote AFP share 277 | .AppleDB 278 | .AppleDesktop 279 | Network Trash Folder 280 | Temporary Items 281 | .apdisk 282 | 283 | # Windows 284 | # ========================= 285 | 286 | # Windows image file caches 287 | Thumbs.db 288 | ehthumbs.db 289 | 290 | # Folder config file 291 | Desktop.ini 292 | 293 | # Recycle Bin used on file shares 294 | $RECYCLE.BIN/ 295 | 296 | # Windows Installer files 297 | *.cab 298 | *.msi 299 | *.msm 300 | *.msp 301 | 302 | # Windows shortcuts 303 | *.lnk 304 | 305 | # S# files 306 | *.projectinfo 307 | ControlSystem.cfg 308 | 309 | 310 | -------------------------------------------------------------------------------- /ByteOrder.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/ByteOrder.cs -------------------------------------------------------------------------------- /CloseEventArgs.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/CloseEventArgs.cs -------------------------------------------------------------------------------- /CloseStatusCode.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/CloseStatusCode.cs -------------------------------------------------------------------------------- /Compatibility/SSMonoNetExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Crestron.SimplSharp; 6 | 7 | namespace SSMono.Net 8 | { 9 | public static class SSMonoNetExtensions 10 | { 11 | public static int getMaxAge (this SSMono.Net.Cookie cookie) 12 | { 13 | if (cookie.Expires == DateTime.MinValue) 14 | return 0; 15 | 16 | var expires = cookie.Expires.Kind != DateTimeKind.Local 17 | ? cookie.Expires.ToLocalTime () 18 | : cookie.Expires; 19 | 20 | var span = expires - DateTime.Now; 21 | return span > TimeSpan.Zero 22 | ? (int)span.TotalSeconds 23 | : 0; 24 | } 25 | 26 | public static void setMaxAge (this SSMono.Net.Cookie cookie, int value) 27 | { 28 | cookie.Expires = value > 0 29 | ? DateTime.Now.AddSeconds ((double)value) 30 | : DateTime.Now; 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Compatibility/SslProtocols.cs: -------------------------------------------------------------------------------- 1 | #if NETCF && (BCC || SSL) 2 | // 3 | // System.Net.Security.SslProtocolType.cs 4 | // 5 | // Authors: 6 | // Tim Coleman (tim@timcoleman.com) 7 | // Sebastien Pouliot 8 | // 9 | // Copyright (C) Tim Coleman, 2004 10 | // Copyright (C) 2004, 2006 Novell, Inc (http://www.novell.com) 11 | // Copyright (C) 2014 Xamarin Inc. (http://www.xamarin.com) 12 | // 13 | // Permission is hereby granted, free of charge, to any person obtaining 14 | // a copy of this software and associated documentation files (the 15 | // "Software"), to deal in the Software without restriction, including 16 | // without limitation the rights to use, copy, modify, merge, publish, 17 | // distribute, sublicense, and/or sell copies of the Software, and to 18 | // permit persons to whom the Software is furnished to do so, subject to 19 | // the following conditions: 20 | // 21 | // The above copyright notice and this permission notice shall be 22 | // included in all copies or substantial portions of the Software. 23 | // 24 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 25 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 26 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 27 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 28 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 29 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 30 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 31 | // 32 | using System; 33 | 34 | namespace SSMono.Security.Authentication 35 | { 36 | [Flags] 37 | public enum SslProtocols 38 | { 39 | None, 40 | Ssl2 = 12, 41 | Ssl3 = 48, 42 | Tls = 192, 43 | Tls11 = 768, 44 | Tls12 = 3072, 45 | Default = Ssl3 | Tls 46 | } 47 | } 48 | #endif -------------------------------------------------------------------------------- /CompressionMethod.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/CompressionMethod.cs -------------------------------------------------------------------------------- /ErrorEventArgs.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/ErrorEventArgs.cs -------------------------------------------------------------------------------- /Ext.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Ext.cs -------------------------------------------------------------------------------- /Fin.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Fin.cs -------------------------------------------------------------------------------- /HttpBase.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/HttpBase.cs -------------------------------------------------------------------------------- /HttpRequest.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/HttpRequest.cs -------------------------------------------------------------------------------- /HttpResponse.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/HttpResponse.cs -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2010-2019 sta.blockhead 4 | Copyright (c) 2019 Nivloc Enterprises Ltd 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /LogData.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/LogData.cs -------------------------------------------------------------------------------- /LogLevel.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/LogLevel.cs -------------------------------------------------------------------------------- /Logger.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Logger.cs -------------------------------------------------------------------------------- /Mask.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Mask.cs -------------------------------------------------------------------------------- /MessageEventArgs.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/MessageEventArgs.cs -------------------------------------------------------------------------------- /Net/AuthenticationBase.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/AuthenticationBase.cs -------------------------------------------------------------------------------- /Net/AuthenticationChallenge.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/AuthenticationChallenge.cs -------------------------------------------------------------------------------- /Net/AuthenticationResponse.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/AuthenticationResponse.cs -------------------------------------------------------------------------------- /Net/AuthenticationSchemes.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/AuthenticationSchemes.cs -------------------------------------------------------------------------------- /Net/Chunk.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/Chunk.cs -------------------------------------------------------------------------------- /Net/ChunkStream.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/ChunkStream.cs -------------------------------------------------------------------------------- /Net/ChunkedRequestStream.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/ChunkedRequestStream.cs -------------------------------------------------------------------------------- /Net/ClientSslConfiguration.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * ClientSslConfiguration.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2014 liryna 8 | * Copyright (c) 2014-2017 sta.blockhead 9 | * Copyright © 2017 Nivloc Enterprises Ltd 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in 19 | * all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | * THE SOFTWARE. 28 | */ 29 | #endregion 30 | 31 | #region Authors 32 | /* 33 | * Authors: 34 | * - Liryna 35 | */ 36 | #endregion 37 | 38 | #if !NETCF || BCC || SSL 39 | using System; 40 | #if SSHARP 41 | #if BCC 42 | using Org.BouncyCastle.Crypto.Tls; 43 | using Org.BouncyCastle.X509; 44 | #elif SSL 45 | using Mono.Security.Protocol.Tls; 46 | using SSMono.Net.Security; 47 | using SSMono.Security.Cryptography.X509Certificates; 48 | #endif 49 | using SSMono.Security.Authentication; 50 | #else 51 | using System.Net.Security; 52 | using System.Security.Authentication; 53 | using System.Security.Cryptography.X509Certificates; 54 | #endif 55 | 56 | namespace WebSocketSharp.Net 57 | { 58 | /// 59 | /// Stores the parameters for the used by clients. 60 | /// 61 | public class ClientSslConfiguration 62 | { 63 | #region Private Fields 64 | 65 | private bool _checkCertRevocation; 66 | private LocalCertificateSelectionCallback _clientCertSelectionCallback; 67 | private X509CertificateCollection _clientCerts; 68 | private SslProtocols _enabledSslProtocols; 69 | private RemoteCertificateValidationCallback _serverCertValidationCallback; 70 | private string _targetHost; 71 | 72 | #endregion 73 | 74 | #region Public Constructors 75 | 76 | /// 77 | /// Initializes a new instance of the class. 78 | /// 79 | public ClientSslConfiguration () 80 | { 81 | _enabledSslProtocols = SslProtocols.Default; 82 | } 83 | 84 | /// 85 | /// Copies the parameters from the specified to 86 | /// a new instance of the class. 87 | /// 88 | /// 89 | /// A from which to copy. 90 | /// 91 | /// 92 | /// is . 93 | /// 94 | public ClientSslConfiguration (ClientSslConfiguration configuration) 95 | { 96 | if (configuration == null) 97 | throw new ArgumentNullException ("configuration"); 98 | 99 | _checkCertRevocation = configuration._checkCertRevocation; 100 | _clientCertSelectionCallback = configuration._clientCertSelectionCallback; 101 | _clientCerts = configuration._clientCerts; 102 | _enabledSslProtocols = configuration._enabledSslProtocols; 103 | _serverCertValidationCallback = configuration._serverCertValidationCallback; 104 | _targetHost = configuration._targetHost; 105 | } 106 | 107 | /// 108 | /// Initializes a new instance of the class with 109 | /// the specified . 110 | /// 111 | /// 112 | /// A that represents the target host server name. 113 | /// 114 | public ClientSslConfiguration (string targetHost) 115 | { 116 | _targetHost = targetHost; 117 | _enabledSslProtocols = SslProtocols.Default; 118 | } 119 | 120 | #endregion 121 | 122 | #region Public Properties 123 | 124 | /// 125 | /// Gets or sets a value indicating whether the certificate revocation 126 | /// list is checked during authentication. 127 | /// 128 | /// 129 | /// 130 | /// true if the certificate revocation list is checked during 131 | /// authentication; otherwise, false. 132 | /// 133 | /// 134 | /// The default value is false. 135 | /// 136 | /// 137 | public bool CheckCertificateRevocation 138 | { 139 | get 140 | { 141 | return _checkCertRevocation; 142 | } 143 | 144 | set 145 | { 146 | _checkCertRevocation = value; 147 | } 148 | } 149 | 150 | /// 151 | /// Gets or sets the certificates from which to select one to 152 | /// supply to the server. 153 | /// 154 | /// 155 | /// 156 | /// A or . 157 | /// 158 | /// 159 | /// That collection contains client certificates from which to select. 160 | /// 161 | /// 162 | /// The default value is . 163 | /// 164 | /// 165 | public X509CertificateCollection ClientCertificates 166 | { 167 | get 168 | { 169 | return _clientCerts; 170 | } 171 | 172 | set 173 | { 174 | _clientCerts = value; 175 | } 176 | } 177 | 178 | /// 179 | /// Gets or sets the callback used to select a client certificate to supply to the server. 180 | /// 181 | /// 182 | /// No certificate is supplied if the callback returns 183 | /// . 184 | /// 185 | /// 186 | /// 187 | /// A delegate that 188 | /// invokes the method called for selecting the certificate. 189 | /// 190 | /// 191 | /// The default value is a delegate that invokes a method that 192 | /// only returns . 193 | /// 194 | /// 195 | public LocalCertificateSelectionCallback ClientCertificateSelectionCallback 196 | { 197 | get 198 | { 199 | if (_clientCertSelectionCallback == null) 200 | _clientCertSelectionCallback = defaultSelectClientCertificate; 201 | 202 | return _clientCertSelectionCallback; 203 | } 204 | 205 | set 206 | { 207 | _clientCertSelectionCallback = value; 208 | } 209 | } 210 | 211 | /// 212 | /// Gets or sets the protocols used for authentication. 213 | /// 214 | /// 215 | /// 216 | /// The enum values that represent 217 | /// the protocols used for authentication. 218 | /// 219 | /// 220 | /// The default value is . 221 | /// 222 | /// 223 | public SslProtocols EnabledSslProtocols 224 | { 225 | get 226 | { 227 | return _enabledSslProtocols; 228 | } 229 | 230 | set 231 | { 232 | _enabledSslProtocols = value; 233 | } 234 | } 235 | 236 | /// 237 | /// Gets or sets the callback used to validate the certificate supplied by the server. 238 | /// 239 | /// 240 | /// The certificate is valid if the callback returns true. 241 | /// 242 | /// 243 | /// 244 | /// A delegate that 245 | /// invokes the method called for validating the certificate. 246 | /// 247 | /// 248 | /// The default value is a delegate that invokes a method that 249 | /// only returns true. 250 | /// 251 | /// 252 | public RemoteCertificateValidationCallback ServerCertificateValidationCallback 253 | { 254 | get 255 | { 256 | if (_serverCertValidationCallback == null) 257 | _serverCertValidationCallback = defaultValidateServerCertificate; 258 | 259 | return _serverCertValidationCallback; 260 | } 261 | 262 | set 263 | { 264 | _serverCertValidationCallback = value; 265 | } 266 | } 267 | 268 | /// 269 | /// Gets or sets the target host server name. 270 | /// 271 | /// 272 | /// 273 | /// A or 274 | /// if not specified. 275 | /// 276 | /// 277 | /// That string represents the name of the server that 278 | /// will share a secure connection with a client. 279 | /// 280 | /// 281 | public string TargetHost 282 | { 283 | get 284 | { 285 | return _targetHost; 286 | } 287 | 288 | set 289 | { 290 | _targetHost = value; 291 | } 292 | } 293 | 294 | #endregion 295 | 296 | #region Private Methods 297 | 298 | private static X509Certificate defaultSelectClientCertificate ( 299 | object sender, 300 | string targetHost, 301 | X509CertificateCollection clientCertificates, 302 | X509Certificate serverCertificate, 303 | string[] acceptableIssuers 304 | ) 305 | { 306 | return null; 307 | } 308 | 309 | private static bool defaultValidateServerCertificate ( 310 | object sender, 311 | X509Certificate certificate, 312 | X509Chain chain, 313 | SslPolicyErrors sslPolicyErrors 314 | ) 315 | { 316 | return true; 317 | } 318 | 319 | #endregion 320 | } 321 | } 322 | #endif -------------------------------------------------------------------------------- /Net/Cookie.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * Cookie.cs 4 | * 5 | * This code is derived from System.Net.Cookie.cs of Mono 6 | * (http://www.mono-project.com). 7 | * 8 | * The MIT License 9 | * 10 | * Copyright (c) 2004,2009 Novell, Inc. (http://www.novell.com) 11 | * Copyright (c) 2012-2014 sta.blockhead 12 | * 13 | * Permission is hereby granted, free of charge, to any person obtaining a copy 14 | * of this software and associated documentation files (the "Software"), to deal 15 | * in the Software without restriction, including without limitation the rights 16 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | * copies of the Software, and to permit persons to whom the Software is 18 | * furnished to do so, subject to the following conditions: 19 | * 20 | * The above copyright notice and this permission notice shall be included in 21 | * all copies or substantial portions of the Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | * THE SOFTWARE. 30 | */ 31 | #endregion 32 | 33 | #region Authors 34 | /* 35 | * Authors: 36 | * - Lawrence Pit 37 | * - Gonzalo Paniagua Javier 38 | * - Daniel Nauck 39 | * - Sebastien Pouliot 40 | */ 41 | #endregion 42 | 43 | using System; 44 | using System.Globalization; 45 | using System.Text; 46 | #if SSHARP 47 | using SSMono; 48 | #else 49 | #endif 50 | 51 | namespace WebSocketSharp.Net 52 | { 53 | /// 54 | /// Provides a set of methods and properties used to manage an HTTP Cookie. 55 | /// 56 | /// 57 | /// 58 | /// The Cookie class supports the following cookie formats: 59 | /// Netscape specification, 60 | /// RFC 2109, and 61 | /// RFC 2965 62 | /// 63 | /// 64 | /// The Cookie class cannot be inherited. 65 | /// 66 | /// 67 | [Serializable] 68 | public sealed class Cookie 69 | { 70 | #region Private Fields 71 | 72 | private string _comment; 73 | private Uri _commentUri; 74 | private bool _discard; 75 | private string _domain; 76 | private DateTime _expires; 77 | private bool _httpOnly; 78 | private string _name; 79 | private string _path; 80 | private string _port; 81 | private int[] _ports; 82 | private static readonly char[] _reservedCharsForName; 83 | private static readonly char[] _reservedCharsForValue; 84 | private bool _secure; 85 | private DateTime _timestamp; 86 | private string _value; 87 | private int _version; 88 | 89 | #endregion 90 | 91 | #region Static Constructor 92 | 93 | static Cookie () 94 | { 95 | _reservedCharsForName = new[] { ' ', '=', ';', ',', '\n', '\r', '\t' }; 96 | _reservedCharsForValue = new[] { ';', ',' }; 97 | } 98 | 99 | #endregion 100 | 101 | #region Public Constructors 102 | 103 | /// 104 | /// Initializes a new instance of the class. 105 | /// 106 | public Cookie () 107 | { 108 | _comment = String.Empty; 109 | _domain = String.Empty; 110 | _expires = DateTime.MinValue; 111 | _name = String.Empty; 112 | _path = String.Empty; 113 | _port = String.Empty; 114 | _ports = new int[0]; 115 | _timestamp = DateTime.Now; 116 | _value = String.Empty; 117 | _version = 0; 118 | } 119 | 120 | /// 121 | /// Initializes a new instance of the class with the specified 122 | /// and . 123 | /// 124 | /// 125 | /// A that represents the Name of the cookie. 126 | /// 127 | /// 128 | /// A that represents the Value of the cookie. 129 | /// 130 | /// 131 | /// 132 | /// is or empty. 133 | /// 134 | /// 135 | /// - or - 136 | /// 137 | /// 138 | /// contains an invalid character. 139 | /// 140 | /// 141 | /// - or - 142 | /// 143 | /// 144 | /// is . 145 | /// 146 | /// 147 | /// - or - 148 | /// 149 | /// 150 | /// contains a string not enclosed in double quotes 151 | /// that contains an invalid character. 152 | /// 153 | /// 154 | public Cookie (string name, string value) 155 | : this () 156 | { 157 | Name = name; 158 | Value = value; 159 | } 160 | 161 | /// 162 | /// Initializes a new instance of the class with the specified 163 | /// , , and . 164 | /// 165 | /// 166 | /// A that represents the Name of the cookie. 167 | /// 168 | /// 169 | /// A that represents the Value of the cookie. 170 | /// 171 | /// 172 | /// A that represents the value of the Path attribute of the cookie. 173 | /// 174 | /// 175 | /// 176 | /// is or empty. 177 | /// 178 | /// 179 | /// - or - 180 | /// 181 | /// 182 | /// contains an invalid character. 183 | /// 184 | /// 185 | /// - or - 186 | /// 187 | /// 188 | /// is . 189 | /// 190 | /// 191 | /// - or - 192 | /// 193 | /// 194 | /// contains a string not enclosed in double quotes 195 | /// that contains an invalid character. 196 | /// 197 | /// 198 | public Cookie (string name, string value, string path) 199 | : this (name, value) 200 | { 201 | Path = path; 202 | } 203 | 204 | /// 205 | /// Initializes a new instance of the class with the specified 206 | /// , , , and 207 | /// . 208 | /// 209 | /// 210 | /// A that represents the Name of the cookie. 211 | /// 212 | /// 213 | /// A that represents the Value of the cookie. 214 | /// 215 | /// 216 | /// A that represents the value of the Path attribute of the cookie. 217 | /// 218 | /// 219 | /// A that represents the value of the Domain attribute of the cookie. 220 | /// 221 | /// 222 | /// 223 | /// is or empty. 224 | /// 225 | /// 226 | /// - or - 227 | /// 228 | /// 229 | /// contains an invalid character. 230 | /// 231 | /// 232 | /// - or - 233 | /// 234 | /// 235 | /// is . 236 | /// 237 | /// 238 | /// - or - 239 | /// 240 | /// 241 | /// contains a string not enclosed in double quotes 242 | /// that contains an invalid character. 243 | /// 244 | /// 245 | public Cookie (string name, string value, string path, string domain) 246 | : this (name, value, path) 247 | { 248 | Domain = domain; 249 | } 250 | 251 | #endregion 252 | 253 | #region Internal Properties 254 | 255 | internal bool ExactDomain 256 | { 257 | get; 258 | set; 259 | } 260 | 261 | internal int MaxAge 262 | { 263 | get 264 | { 265 | if (_expires == DateTime.MinValue) 266 | return 0; 267 | 268 | var expires = _expires.Kind != DateTimeKind.Local 269 | ? _expires.ToLocalTime () 270 | : _expires; 271 | 272 | var span = expires - DateTime.Now; 273 | return span > TimeSpan.Zero 274 | ? (int)span.TotalSeconds 275 | : 0; 276 | } 277 | } 278 | 279 | internal int[] Ports 280 | { 281 | get 282 | { 283 | return _ports; 284 | } 285 | } 286 | 287 | #endregion 288 | 289 | #region Public Properties 290 | 291 | /// 292 | /// Gets or sets the value of the Comment attribute of the cookie. 293 | /// 294 | /// 295 | /// A that represents the comment to document intended use of the cookie. 296 | /// 297 | public string Comment 298 | { 299 | get 300 | { 301 | return _comment; 302 | } 303 | 304 | set 305 | { 306 | _comment = value ?? String.Empty; 307 | } 308 | } 309 | 310 | /// 311 | /// Gets or sets the value of the CommentURL attribute of the cookie. 312 | /// 313 | /// 314 | /// A that represents the URI that provides the comment to document intended 315 | /// use of the cookie. 316 | /// 317 | public Uri CommentUri 318 | { 319 | get 320 | { 321 | return _commentUri; 322 | } 323 | 324 | set 325 | { 326 | _commentUri = value; 327 | } 328 | } 329 | 330 | /// 331 | /// Gets or sets a value indicating whether the client discards the cookie unconditionally 332 | /// when the client terminates. 333 | /// 334 | /// 335 | /// true if the client discards the cookie unconditionally when the client terminates; 336 | /// otherwise, false. The default value is false. 337 | /// 338 | public bool Discard 339 | { 340 | get 341 | { 342 | return _discard; 343 | } 344 | 345 | set 346 | { 347 | _discard = value; 348 | } 349 | } 350 | 351 | /// 352 | /// Gets or sets the value of the Domain attribute of the cookie. 353 | /// 354 | /// 355 | /// A that represents the URI for which the cookie is valid. 356 | /// 357 | public string Domain 358 | { 359 | get 360 | { 361 | return _domain; 362 | } 363 | 364 | set 365 | { 366 | if (value.IsNullOrEmpty ()) 367 | { 368 | _domain = String.Empty; 369 | ExactDomain = true; 370 | } 371 | else 372 | { 373 | _domain = value; 374 | ExactDomain = value[0] != '.'; 375 | } 376 | } 377 | } 378 | 379 | /// 380 | /// Gets or sets a value indicating whether the cookie has expired. 381 | /// 382 | /// 383 | /// true if the cookie has expired; otherwise, false. 384 | /// The default value is false. 385 | /// 386 | public bool Expired 387 | { 388 | get 389 | { 390 | return _expires != DateTime.MinValue && _expires <= DateTime.Now; 391 | } 392 | 393 | set 394 | { 395 | _expires = value ? DateTime.Now : DateTime.MinValue; 396 | } 397 | } 398 | 399 | /// 400 | /// Gets or sets the value of the Expires attribute of the cookie. 401 | /// 402 | /// 403 | /// A that represents the date and time at which the cookie expires. 404 | /// The default value is . 405 | /// 406 | public DateTime Expires 407 | { 408 | get 409 | { 410 | return _expires; 411 | } 412 | 413 | set 414 | { 415 | _expires = value; 416 | } 417 | } 418 | 419 | /// 420 | /// Gets or sets a value indicating whether non-HTTP APIs can access the cookie. 421 | /// 422 | /// 423 | /// true if non-HTTP APIs cannot access the cookie; otherwise, false. 424 | /// The default value is false. 425 | /// 426 | public bool HttpOnly 427 | { 428 | get 429 | { 430 | return _httpOnly; 431 | } 432 | 433 | set 434 | { 435 | _httpOnly = value; 436 | } 437 | } 438 | 439 | /// 440 | /// Gets or sets the Name of the cookie. 441 | /// 442 | /// 443 | /// A that represents the Name of the cookie. 444 | /// 445 | /// 446 | /// 447 | /// The value specified for a set operation is or empty. 448 | /// 449 | /// 450 | /// - or - 451 | /// 452 | /// 453 | /// The value specified for a set operation contains an invalid character. 454 | /// 455 | /// 456 | public string Name 457 | { 458 | get 459 | { 460 | return _name; 461 | } 462 | 463 | set 464 | { 465 | string msg; 466 | if (!canSetName (value, out msg)) 467 | throw new CookieException (msg); 468 | 469 | _name = value; 470 | } 471 | } 472 | 473 | /// 474 | /// Gets or sets the value of the Path attribute of the cookie. 475 | /// 476 | /// 477 | /// A that represents the subset of URI on the origin server 478 | /// to which the cookie applies. 479 | /// 480 | public string Path 481 | { 482 | get 483 | { 484 | return _path; 485 | } 486 | 487 | set 488 | { 489 | _path = value ?? String.Empty; 490 | } 491 | } 492 | 493 | /// 494 | /// Gets or sets the value of the Port attribute of the cookie. 495 | /// 496 | /// 497 | /// A that represents the list of TCP ports to which the cookie applies. 498 | /// 499 | /// 500 | /// The value specified for a set operation isn't enclosed in double quotes or 501 | /// couldn't be parsed. 502 | /// 503 | public string Port 504 | { 505 | get 506 | { 507 | return _port; 508 | } 509 | 510 | set 511 | { 512 | if (value.IsNullOrEmpty ()) 513 | { 514 | _port = String.Empty; 515 | _ports = new int[0]; 516 | 517 | return; 518 | } 519 | 520 | if (!value.IsEnclosedIn ('"')) 521 | throw new CookieException ( 522 | "The value specified for the Port attribute isn't enclosed in double quotes."); 523 | 524 | string err; 525 | if (!tryCreatePorts (value, out _ports, out err)) 526 | throw new CookieException ( 527 | String.Format ( 528 | "The value specified for the Port attribute contains an invalid value: {0}", err)); 529 | 530 | _port = value; 531 | } 532 | } 533 | 534 | /// 535 | /// Gets or sets a value indicating whether the security level of the cookie is secure. 536 | /// 537 | /// 538 | /// When this property is true, the cookie may be included in the HTTP request 539 | /// only if the request is transmitted over the HTTPS. 540 | /// 541 | /// 542 | /// true if the security level of the cookie is secure; otherwise, false. 543 | /// The default value is false. 544 | /// 545 | public bool Secure 546 | { 547 | get 548 | { 549 | return _secure; 550 | } 551 | 552 | set 553 | { 554 | _secure = value; 555 | } 556 | } 557 | 558 | /// 559 | /// Gets the time when the cookie was issued. 560 | /// 561 | /// 562 | /// A that represents the time when the cookie was issued. 563 | /// 564 | public DateTime TimeStamp 565 | { 566 | get 567 | { 568 | return _timestamp; 569 | } 570 | } 571 | 572 | /// 573 | /// Gets or sets the Value of the cookie. 574 | /// 575 | /// 576 | /// A that represents the Value of the cookie. 577 | /// 578 | /// 579 | /// 580 | /// The value specified for a set operation is . 581 | /// 582 | /// 583 | /// - or - 584 | /// 585 | /// 586 | /// The value specified for a set operation contains a string not enclosed in double quotes 587 | /// that contains an invalid character. 588 | /// 589 | /// 590 | public string Value 591 | { 592 | get 593 | { 594 | return _value; 595 | } 596 | 597 | set 598 | { 599 | string msg; 600 | if (!canSetValue (value, out msg)) 601 | throw new CookieException (msg); 602 | 603 | _value = value.Length > 0 ? value : "\"\""; 604 | } 605 | } 606 | 607 | /// 608 | /// Gets or sets the value of the Version attribute of the cookie. 609 | /// 610 | /// 611 | /// An that represents the version of the HTTP state management 612 | /// to which the cookie conforms. 613 | /// 614 | /// 615 | /// The value specified for a set operation isn't 0 or 1. 616 | /// 617 | public int Version 618 | { 619 | get 620 | { 621 | return _version; 622 | } 623 | 624 | set 625 | { 626 | if (value < 0 || value > 1) 627 | throw new ArgumentOutOfRangeException ("value", "Not 0 or 1."); 628 | 629 | _version = value; 630 | } 631 | } 632 | 633 | #endregion 634 | 635 | #region Private Methods 636 | 637 | private static bool canSetName (string name, out string message) 638 | { 639 | if (name.IsNullOrEmpty ()) 640 | { 641 | message = "The value specified for the Name is null or empty."; 642 | return false; 643 | } 644 | 645 | if (name[0] == '$' || name.Contains (_reservedCharsForName)) 646 | { 647 | message = "The value specified for the Name contains an invalid character."; 648 | return false; 649 | } 650 | 651 | message = String.Empty; 652 | return true; 653 | } 654 | 655 | private static bool canSetValue (string value, out string message) 656 | { 657 | if (value == null) 658 | { 659 | message = "The value specified for the Value is null."; 660 | return false; 661 | } 662 | 663 | if (value.Contains (_reservedCharsForValue) && !value.IsEnclosedIn ('"')) 664 | { 665 | message = "The value specified for the Value contains an invalid character."; 666 | return false; 667 | } 668 | 669 | message = String.Empty; 670 | return true; 671 | } 672 | 673 | private static int hash (int i, int j, int k, int l, int m) 674 | { 675 | return i ^ 676 | (j << 13 | j >> 19) ^ 677 | (k << 26 | k >> 6) ^ 678 | (l << 7 | l >> 25) ^ 679 | (m << 20 | m >> 12); 680 | } 681 | 682 | private string toResponseStringVersion0 () 683 | { 684 | var output = new StringBuilder (64); 685 | output.AppendFormat ("{0}={1}", _name, _value); 686 | 687 | if (_expires != DateTime.MinValue) 688 | output.AppendFormat ( 689 | "; Expires={0}", 690 | _expires.ToUniversalTime ().ToString ( 691 | "ddd, dd'-'MMM'-'yyyy HH':'mm':'ss 'GMT'", 692 | CultureInfo.CreateSpecificCulture ("en-US"))); 693 | 694 | if (!_path.IsNullOrEmpty ()) 695 | output.AppendFormat ("; Path={0}", _path); 696 | 697 | if (!_domain.IsNullOrEmpty ()) 698 | output.AppendFormat ("; Domain={0}", _domain); 699 | 700 | if (_secure) 701 | output.Append ("; Secure"); 702 | 703 | if (_httpOnly) 704 | output.Append ("; HttpOnly"); 705 | 706 | return output.ToString (); 707 | } 708 | 709 | private string toResponseStringVersion1 () 710 | { 711 | var buff = new StringBuilder (64); 712 | buff.AppendFormat ("{0}={1}; Version={2}", _name, _value, _version); 713 | 714 | if (_expires != DateTime.MinValue) 715 | buff.AppendFormat ("; Max-Age={0}", MaxAge); 716 | 717 | if (!_path.IsNullOrEmpty ()) 718 | buff.AppendFormat ("; Path={0}", _path); 719 | 720 | if (!_domain.IsNullOrEmpty ()) 721 | buff.AppendFormat ("; Domain={0}", _domain); 722 | 723 | if (!_port.IsNullOrEmpty ()) 724 | { 725 | buff.Append (_port != "\"\"" ? String.Format ("; Port={0}", _port) : "; Port"); 726 | } 727 | 728 | if (!_comment.IsNullOrEmpty ()) 729 | buff.AppendFormat ("; Comment={0}", HttpUtility.UrlEncode (_comment)); 730 | 731 | if (_commentUri != null) 732 | { 733 | var url = _commentUri.OriginalString; 734 | buff.AppendFormat ("; CommentURL={0}", url.IsToken () ? url : url.Quote ()); 735 | } 736 | 737 | if (_discard) 738 | buff.Append ("; Discard"); 739 | 740 | if (_secure) 741 | buff.Append ("; Secure"); 742 | 743 | return buff.ToString (); 744 | } 745 | 746 | private static bool tryCreatePorts (string value, out int[] result, out string parseError) 747 | { 748 | var ports = value.Trim ('"').Split (','); 749 | var len = ports.Length; 750 | var res = new int[len]; 751 | for (var i = 0; i < len; i++) 752 | { 753 | res[i] = Int32.MinValue; 754 | 755 | var port = ports[i].Trim (); 756 | if (port.Length == 0) 757 | continue; 758 | 759 | #if SSHARP 760 | if (!TryParsers.Int32TryParse (port, out res[i])) 761 | #else 762 | if (!Int32.TryParse (port, out res[i])) 763 | #endif 764 | { 765 | result = new int[0]; 766 | parseError = port; 767 | 768 | return false; 769 | } 770 | } 771 | 772 | result = res; 773 | parseError = String.Empty; 774 | 775 | return true; 776 | } 777 | 778 | #endregion 779 | 780 | #region Internal Methods 781 | 782 | // From client to server 783 | internal string ToRequestString (Uri uri) 784 | { 785 | if (_name.Length == 0) 786 | return String.Empty; 787 | 788 | if (_version == 0) 789 | return String.Format ("{0}={1}", _name, _value); 790 | 791 | var output = new StringBuilder (64); 792 | output.AppendFormat ("$Version={0}; {1}={2}", _version, _name, _value); 793 | 794 | if (!_path.IsNullOrEmpty ()) 795 | output.AppendFormat ("; $Path={0}", _path); 796 | else if (uri != null) 797 | output.AppendFormat ("; $Path={0}", uri.GetAbsolutePath ()); 798 | else 799 | output.Append ("; $Path=/"); 800 | 801 | var appendDomain = uri == null || uri.Host != _domain; 802 | if (appendDomain && !_domain.IsNullOrEmpty ()) 803 | output.AppendFormat ("; $Domain={0}", _domain); 804 | 805 | if (!_port.IsNullOrEmpty ()) 806 | { 807 | if (_port == "\"\"") 808 | output.Append ("; $Port"); 809 | else 810 | output.AppendFormat ("; $Port={0}", _port); 811 | } 812 | 813 | return output.ToString (); 814 | } 815 | 816 | // From server to client 817 | internal string ToResponseString () 818 | { 819 | return _name.Length > 0 820 | ? (_version == 0 ? toResponseStringVersion0 () : toResponseStringVersion1 ()) 821 | : String.Empty; 822 | } 823 | 824 | #endregion 825 | 826 | #region Public Methods 827 | 828 | /// 829 | /// Determines whether the specified is equal to the current 830 | /// . 831 | /// 832 | /// 833 | /// An to compare with the current . 834 | /// 835 | /// 836 | /// true if is equal to the current ; 837 | /// otherwise, false. 838 | /// 839 | public override bool Equals (Object comparand) 840 | { 841 | var cookie = comparand as Cookie; 842 | return cookie != null && 843 | _name.Equals (cookie.Name, StringComparison.InvariantCultureIgnoreCase) && 844 | _value.Equals (cookie.Value, StringComparison.InvariantCulture) && 845 | _path.Equals (cookie.Path, StringComparison.InvariantCulture) && 846 | _domain.Equals (cookie.Domain, StringComparison.InvariantCultureIgnoreCase) && 847 | _version == cookie.Version; 848 | } 849 | 850 | /// 851 | /// Serves as a hash function for a object. 852 | /// 853 | /// 854 | /// An that represents the hash code for the current . 855 | /// 856 | public override int GetHashCode () 857 | { 858 | return hash ( 859 | StringComparer.InvariantCultureIgnoreCase.GetHashCode (_name), 860 | _value.GetHashCode (), 861 | _path.GetHashCode (), 862 | StringComparer.InvariantCultureIgnoreCase.GetHashCode (_domain), 863 | _version); 864 | } 865 | 866 | /// 867 | /// Returns a that represents the current . 868 | /// 869 | /// 870 | /// This method returns a to use to send an HTTP Cookie to 871 | /// an origin server. 872 | /// 873 | /// 874 | /// A that represents the current . 875 | /// 876 | public override string ToString () 877 | { 878 | // i.e., only used for clients 879 | // See para 4.2.2 of RFC 2109 and para 3.3.4 of RFC 2965 880 | // See also bug #316017 881 | return ToRequestString (null); 882 | } 883 | 884 | #endregion 885 | } 886 | } 887 | -------------------------------------------------------------------------------- /Net/CookieCollection.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/CookieCollection.cs -------------------------------------------------------------------------------- /Net/CookieException.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * CookieException.cs 4 | * 5 | * This code is derived from System.Net.CookieException.cs of Mono 6 | * (http://www.mono-project.com). 7 | * 8 | * The MIT License 9 | * 10 | * Copyright (c) 2012-2014 sta.blockhead 11 | * 12 | * Permission is hereby granted, free of charge, to any person obtaining a copy 13 | * of this software and associated documentation files (the "Software"), to deal 14 | * in the Software without restriction, including without limitation the rights 15 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | * copies of the Software, and to permit persons to whom the Software is 17 | * furnished to do so, subject to the following conditions: 18 | * 19 | * The above copyright notice and this permission notice shall be included in 20 | * all copies or substantial portions of the Software. 21 | * 22 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 28 | * THE SOFTWARE. 29 | */ 30 | #endregion 31 | 32 | #region Authors 33 | /* 34 | * Authors: 35 | * - Lawrence Pit 36 | */ 37 | #endregion 38 | 39 | using System; 40 | #if !NETCF 41 | using System.Runtime.Serialization; 42 | using System.Security.Permissions; 43 | #endif 44 | 45 | namespace WebSocketSharp.Net 46 | { 47 | /// 48 | /// The exception that is thrown when a gets an error. 49 | /// 50 | [Serializable] 51 | public class CookieException : FormatException 52 | #if !NETCF 53 | , ISerializable 54 | #endif 55 | { 56 | #region Internal Constructors 57 | 58 | internal CookieException (string message) 59 | : base (message) 60 | { 61 | } 62 | 63 | internal CookieException (string message, Exception innerException) 64 | : base (message, innerException) 65 | { 66 | } 67 | 68 | #endregion 69 | 70 | #region Protected Constructors 71 | 72 | /// 73 | /// Initializes a new instance of the class from 74 | /// the specified and . 75 | /// 76 | /// 77 | /// A that contains the serialized object data. 78 | /// 79 | /// 80 | /// A that specifies the source for the deserialization. 81 | /// 82 | #if !NETCF 83 | protected CookieException ( 84 | SerializationInfo serializationInfo, StreamingContext streamingContext) 85 | : base (serializationInfo, streamingContext) 86 | { 87 | } 88 | #endif 89 | 90 | #endregion 91 | 92 | #region Public Constructors 93 | 94 | /// 95 | /// Initializes a new instance of the class. 96 | /// 97 | public CookieException () 98 | : base () 99 | { 100 | } 101 | 102 | #endregion 103 | 104 | #region Public Methods 105 | 106 | #if !NETCF 107 | /// 108 | /// Populates the specified with the data needed to serialize 109 | /// the current . 110 | /// 111 | /// 112 | /// A that holds the serialized object data. 113 | /// 114 | /// 115 | /// A that specifies the destination for the serialization. 116 | /// 117 | [SecurityPermission ( 118 | SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)] 119 | public override void GetObjectData ( 120 | SerializationInfo serializationInfo, StreamingContext streamingContext) 121 | { 122 | base.GetObjectData (serializationInfo, streamingContext); 123 | } 124 | #endif 125 | #endregion 126 | 127 | #region Explicit Interface Implementation 128 | 129 | #if !NETCF 130 | /// 131 | /// Populates the specified with the data needed to serialize 132 | /// the current . 133 | /// 134 | /// 135 | /// A that holds the serialized object data. 136 | /// 137 | /// 138 | /// A that specifies the destination for the serialization. 139 | /// 140 | [SecurityPermission ( 141 | SecurityAction.LinkDemand, 142 | Flags = SecurityPermissionFlag.SerializationFormatter, 143 | SerializationFormatter = true)] 144 | void ISerializable.GetObjectData ( 145 | SerializationInfo serializationInfo, StreamingContext streamingContext) 146 | { 147 | base.GetObjectData (serializationInfo, streamingContext); 148 | } 149 | #endif 150 | 151 | #endregion 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /Net/CookieExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Crestron.SimplSharp; 6 | using SSMono.Net; 7 | 8 | namespace WebSocketSharp.Net 9 | { 10 | public static class CookieExtensions 11 | { 12 | internal static bool EqualsWithoutValue (this Cookie thisCookie, Cookie cookie) 13 | { 14 | var caseSensitive = StringComparison.InvariantCulture; 15 | var caseInsensitive = StringComparison.InvariantCultureIgnoreCase; 16 | 17 | return thisCookie.Name.Equals (cookie.Name, caseInsensitive) 18 | && thisCookie.Path.Equals (cookie.Path, caseSensitive) 19 | && thisCookie.Domain.Equals (cookie.Domain, caseInsensitive) 20 | && thisCookie.Version == cookie.Version; 21 | } 22 | 23 | } 24 | } -------------------------------------------------------------------------------- /Net/EndPointListener.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/EndPointListener.cs -------------------------------------------------------------------------------- /Net/EndPointManager.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/EndPointManager.cs -------------------------------------------------------------------------------- /Net/HttpBasicIdentity.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/HttpBasicIdentity.cs -------------------------------------------------------------------------------- /Net/HttpConnection.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/HttpConnection.cs -------------------------------------------------------------------------------- /Net/HttpDigestIdentity.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/HttpDigestIdentity.cs -------------------------------------------------------------------------------- /Net/HttpHeaderInfo.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/HttpHeaderInfo.cs -------------------------------------------------------------------------------- /Net/HttpHeaderType.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/HttpHeaderType.cs -------------------------------------------------------------------------------- /Net/HttpListener.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/HttpListener.cs -------------------------------------------------------------------------------- /Net/HttpListenerAsyncResult.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/HttpListenerAsyncResult.cs -------------------------------------------------------------------------------- /Net/HttpListenerContext.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/HttpListenerContext.cs -------------------------------------------------------------------------------- /Net/HttpListenerException.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/HttpListenerException.cs -------------------------------------------------------------------------------- /Net/HttpListenerPrefix.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/HttpListenerPrefix.cs -------------------------------------------------------------------------------- /Net/HttpListenerPrefixCollection.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/HttpListenerPrefixCollection.cs -------------------------------------------------------------------------------- /Net/HttpListenerRequest.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/HttpListenerRequest.cs -------------------------------------------------------------------------------- /Net/HttpListenerResponse.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/HttpListenerResponse.cs -------------------------------------------------------------------------------- /Net/HttpRequestHeader.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/HttpRequestHeader.cs -------------------------------------------------------------------------------- /Net/HttpResponseHeader.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/HttpResponseHeader.cs -------------------------------------------------------------------------------- /Net/HttpStatusCode.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * HttpStatusCode.cs 4 | * 5 | * This code is derived from System.Net.HttpStatusCode.cs of Mono 6 | * (http://www.mono-project.com). 7 | * 8 | * It was automatically generated from ECMA CLI XML Library Specification. 9 | * Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)] 10 | * Created: Wed, 5 Sep 2001 06:32:05 UTC 11 | * Source file: AllTypes.xml 12 | * URL: http://msdn.microsoft.com/net/ecma/AllTypes.xml 13 | * 14 | * The MIT License 15 | * 16 | * Copyright (c) 2001 Ximian, Inc. (http://www.ximian.com) 17 | * Copyright (c) 2012-2014 sta.blockhead 18 | * 19 | * Permission is hereby granted, free of charge, to any person obtaining a copy 20 | * of this software and associated documentation files (the "Software"), to deal 21 | * in the Software without restriction, including without limitation the rights 22 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 23 | * copies of the Software, and to permit persons to whom the Software is 24 | * furnished to do so, subject to the following conditions: 25 | * 26 | * The above copyright notice and this permission notice shall be included in 27 | * all copies or substantial portions of the Software. 28 | * 29 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 35 | * THE SOFTWARE. 36 | */ 37 | #endregion 38 | 39 | namespace WebSocketSharp.Net 40 | { 41 | /// 42 | /// Contains the values of the HTTP status codes. 43 | /// 44 | /// 45 | /// The HttpStatusCode enumeration contains the values of the HTTP status codes defined in 46 | /// RFC 2616 for the HTTP/1.1. 47 | /// 48 | public enum HttpStatusCode 49 | { 50 | /// 51 | /// Equivalent to status code 100. 52 | /// Indicates that the client should continue with its request. 53 | /// 54 | Continue = 100, 55 | /// 56 | /// Equivalent to status code 101. 57 | /// Indicates that the server is switching the HTTP version or protocol on the connection. 58 | /// 59 | SwitchingProtocols = 101, 60 | /// 61 | /// Equivalent to status code 200. 62 | /// Indicates that the client's request has succeeded. 63 | /// 64 | OK = 200, 65 | /// 66 | /// Equivalent to status code 201. 67 | /// Indicates that the client's request has been fulfilled and resulted in a new resource being 68 | /// created. 69 | /// 70 | Created = 201, 71 | /// 72 | /// Equivalent to status code 202. 73 | /// Indicates that the client's request has been accepted for processing, but the processing 74 | /// hasn't been completed. 75 | /// 76 | Accepted = 202, 77 | /// 78 | /// Equivalent to status code 203. 79 | /// Indicates that the returned metainformation is from a local or a third-party copy instead of 80 | /// the origin server. 81 | /// 82 | NonAuthoritativeInformation = 203, 83 | /// 84 | /// Equivalent to status code 204. 85 | /// Indicates that the server has fulfilled the client's request but doesn't need to return 86 | /// an entity-body. 87 | /// 88 | NoContent = 204, 89 | /// 90 | /// Equivalent to status code 205. 91 | /// Indicates that the server has fulfilled the client's request, and the user agent should 92 | /// reset the document view which caused the request to be sent. 93 | /// 94 | ResetContent = 205, 95 | /// 96 | /// Equivalent to status code 206. 97 | /// Indicates that the server has fulfilled the partial GET request for the resource. 98 | /// 99 | PartialContent = 206, 100 | /// 101 | /// 102 | /// Equivalent to status code 300. 103 | /// Indicates that the requested resource corresponds to any of multiple representations. 104 | /// 105 | /// 106 | /// MultipleChoices is a synonym for Ambiguous. 107 | /// 108 | /// 109 | MultipleChoices = 300, 110 | /// 111 | /// 112 | /// Equivalent to status code 300. 113 | /// Indicates that the requested resource corresponds to any of multiple representations. 114 | /// 115 | /// 116 | /// Ambiguous is a synonym for MultipleChoices. 117 | /// 118 | /// 119 | Ambiguous = 300, 120 | /// 121 | /// 122 | /// Equivalent to status code 301. 123 | /// Indicates that the requested resource has been assigned a new permanent URI and 124 | /// any future references to this resource should use one of the returned URIs. 125 | /// 126 | /// 127 | /// MovedPermanently is a synonym for Moved. 128 | /// 129 | /// 130 | MovedPermanently = 301, 131 | /// 132 | /// 133 | /// Equivalent to status code 301. 134 | /// Indicates that the requested resource has been assigned a new permanent URI and 135 | /// any future references to this resource should use one of the returned URIs. 136 | /// 137 | /// 138 | /// Moved is a synonym for MovedPermanently. 139 | /// 140 | /// 141 | Moved = 301, 142 | /// 143 | /// 144 | /// Equivalent to status code 302. 145 | /// Indicates that the requested resource is located temporarily under a different URI. 146 | /// 147 | /// 148 | /// Found is a synonym for Redirect. 149 | /// 150 | /// 151 | Found = 302, 152 | /// 153 | /// 154 | /// Equivalent to status code 302. 155 | /// Indicates that the requested resource is located temporarily under a different URI. 156 | /// 157 | /// 158 | /// Redirect is a synonym for Found. 159 | /// 160 | /// 161 | Redirect = 302, 162 | /// 163 | /// 164 | /// Equivalent to status code 303. 165 | /// Indicates that the response to the request can be found under a different URI and 166 | /// should be retrieved using a GET method on that resource. 167 | /// 168 | /// 169 | /// SeeOther is a synonym for RedirectMethod. 170 | /// 171 | /// 172 | SeeOther = 303, 173 | /// 174 | /// 175 | /// Equivalent to status code 303. 176 | /// Indicates that the response to the request can be found under a different URI and 177 | /// should be retrieved using a GET method on that resource. 178 | /// 179 | /// 180 | /// RedirectMethod is a synonym for SeeOther. 181 | /// 182 | /// 183 | RedirectMethod = 303, 184 | /// 185 | /// Equivalent to status code 304. 186 | /// Indicates that the client has performed a conditional GET request and access is allowed, 187 | /// but the document hasn't been modified. 188 | /// 189 | NotModified = 304, 190 | /// 191 | /// Equivalent to status code 305. 192 | /// Indicates that the requested resource must be accessed through the proxy given by 193 | /// the Location field. 194 | /// 195 | UseProxy = 305, 196 | /// 197 | /// Equivalent to status code 306. 198 | /// This status code was used in a previous version of the specification, is no longer used, 199 | /// and is reserved for future use. 200 | /// 201 | Unused = 306, 202 | /// 203 | /// 204 | /// Equivalent to status code 307. 205 | /// Indicates that the requested resource is located temporarily under a different URI. 206 | /// 207 | /// 208 | /// TemporaryRedirect is a synonym for RedirectKeepVerb. 209 | /// 210 | /// 211 | TemporaryRedirect = 307, 212 | /// 213 | /// 214 | /// Equivalent to status code 307. 215 | /// Indicates that the requested resource is located temporarily under a different URI. 216 | /// 217 | /// 218 | /// RedirectKeepVerb is a synonym for TemporaryRedirect. 219 | /// 220 | /// 221 | RedirectKeepVerb = 307, 222 | /// 223 | /// Equivalent to status code 400. 224 | /// Indicates that the client's request couldn't be understood by the server due to 225 | /// malformed syntax. 226 | /// 227 | BadRequest = 400, 228 | /// 229 | /// Equivalent to status code 401. 230 | /// Indicates that the client's request requires user authentication. 231 | /// 232 | Unauthorized = 401, 233 | /// 234 | /// Equivalent to status code 402. 235 | /// This status code is reserved for future use. 236 | /// 237 | PaymentRequired = 402, 238 | /// 239 | /// Equivalent to status code 403. 240 | /// Indicates that the server understood the client's request but is refusing to fulfill it. 241 | /// 242 | Forbidden = 403, 243 | /// 244 | /// Equivalent to status code 404. 245 | /// Indicates that the server hasn't found anything matching the request URI. 246 | /// 247 | NotFound = 404, 248 | /// 249 | /// Equivalent to status code 405. 250 | /// Indicates that the method specified in the request line isn't allowed for the resource 251 | /// identified by the request URI. 252 | /// 253 | MethodNotAllowed = 405, 254 | /// 255 | /// Equivalent to status code 406. 256 | /// Indicates that the server doesn't have the appropriate resource to respond to the Accept 257 | /// headers in the client's request. 258 | /// 259 | NotAcceptable = 406, 260 | /// 261 | /// Equivalent to status code 407. 262 | /// Indicates that the client must first authenticate itself with the proxy. 263 | /// 264 | ProxyAuthenticationRequired = 407, 265 | /// 266 | /// Equivalent to status code 408. 267 | /// Indicates that the client didn't produce a request within the time that the server was 268 | /// prepared to wait. 269 | /// 270 | RequestTimeout = 408, 271 | /// 272 | /// Equivalent to status code 409. 273 | /// Indicates that the client's request couldn't be completed due to a conflict on the server. 274 | /// 275 | Conflict = 409, 276 | /// 277 | /// Equivalent to status code 410. 278 | /// Indicates that the requested resource is no longer available at the server and 279 | /// no forwarding address is known. 280 | /// 281 | Gone = 410, 282 | /// 283 | /// Equivalent to status code 411. 284 | /// Indicates that the server refuses to accept the client's request without a defined 285 | /// Content-Length. 286 | /// 287 | LengthRequired = 411, 288 | /// 289 | /// Equivalent to status code 412. 290 | /// Indicates that the precondition given in one or more of the request headers evaluated to 291 | /// false when it was tested on the server. 292 | /// 293 | PreconditionFailed = 412, 294 | /// 295 | /// Equivalent to status code 413. 296 | /// Indicates that the entity of the client's request is larger than the server is willing or 297 | /// able to process. 298 | /// 299 | RequestEntityTooLarge = 413, 300 | /// 301 | /// Equivalent to status code 414. 302 | /// Indicates that the request URI is longer than the server is willing to interpret. 303 | /// 304 | RequestUriTooLong = 414, 305 | /// 306 | /// Equivalent to status code 415. 307 | /// Indicates that the entity of the client's request is in a format not supported by 308 | /// the requested resource for the requested method. 309 | /// 310 | UnsupportedMediaType = 415, 311 | /// 312 | /// Equivalent to status code 416. 313 | /// Indicates that none of the range specifier values in a Range request header overlap 314 | /// the current extent of the selected resource. 315 | /// 316 | RequestedRangeNotSatisfiable = 416, 317 | /// 318 | /// Equivalent to status code 417. 319 | /// Indicates that the expectation given in an Expect request header couldn't be met by 320 | /// the server. 321 | /// 322 | ExpectationFailed = 417, 323 | /// 324 | /// Equivalent to status code 500. 325 | /// Indicates that the server encountered an unexpected condition which prevented it from 326 | /// fulfilling the client's request. 327 | /// 328 | InternalServerError = 500, 329 | /// 330 | /// Equivalent to status code 501. 331 | /// Indicates that the server doesn't support the functionality required to fulfill the client's 332 | /// request. 333 | /// 334 | NotImplemented = 501, 335 | /// 336 | /// Equivalent to status code 502. 337 | /// Indicates that a gateway or proxy server received an invalid response from the upstream 338 | /// server. 339 | /// 340 | BadGateway = 502, 341 | /// 342 | /// Equivalent to status code 503. 343 | /// Indicates that the server is currently unable to handle the client's request due to 344 | /// a temporary overloading or maintenance of the server. 345 | /// 346 | ServiceUnavailable = 503, 347 | /// 348 | /// Equivalent to status code 504. 349 | /// Indicates that a gateway or proxy server didn't receive a timely response from the upstream 350 | /// server or some other auxiliary server. 351 | /// 352 | GatewayTimeout = 504, 353 | /// 354 | /// Equivalent to status code 505. 355 | /// Indicates that the server doesn't support the HTTP version used in the client's request. 356 | /// 357 | HttpVersionNotSupported = 505, 358 | } 359 | } 360 | -------------------------------------------------------------------------------- /Net/HttpStreamAsyncResult.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/HttpStreamAsyncResult.cs -------------------------------------------------------------------------------- /Net/HttpUtility.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | 3 | /* 4 | * HttpUtility.cs 5 | * 6 | * This code is derived from HttpUtility.cs (System.Net) of Mono 7 | * (http://www.mono-project.com). 8 | * 9 | * The MIT License 10 | * 11 | * Copyright (c) 2005-2009 Novell, Inc. (http://www.novell.com) 12 | * Copyright (c) 2012-2019 sta.blockhead 13 | * Copyright © 2019 Nivloc Enterprises Ltd 14 | * 15 | * Permission is hereby granted, free of charge, to any person obtaining a copy 16 | * of this software and associated documentation files (the "Software"), to deal 17 | * in the Software without restriction, including without limitation the rights 18 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 19 | * copies of the Software, and to permit persons to whom the Software is 20 | * furnished to do so, subject to the following conditions: 21 | * 22 | * The above copyright notice and this permission notice shall be included in 23 | * all copies or substantial portions of the Software. 24 | * 25 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 27 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 28 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 29 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 30 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 31 | * THE SOFTWARE. 32 | */ 33 | 34 | #endregion 35 | 36 | #region Authors 37 | 38 | /* 39 | * Authors: 40 | * - Patrik Torstensson 41 | * - Wictor Wilén (decode/encode functions) 42 | * - Tim Coleman 43 | * - Gonzalo Paniagua Javier 44 | */ 45 | 46 | #endregion 47 | 48 | using System; 49 | using System.Collections; 50 | using System.Collections.Generic; 51 | using System.Collections.Specialized; 52 | using System.Globalization; 53 | #if SSHARP 54 | using Crestron.SimplSharp; 55 | using Crestron.SimplSharp.CrestronIO; 56 | using SSMono.Security.Principal; 57 | using SSMono.Web; 58 | #else 59 | using System.IO; 60 | using System.Security.Principal; 61 | #endif 62 | using System.Text; 63 | 64 | namespace WebSocketSharp.Net 65 | { 66 | internal static class HttpUtility 67 | { 68 | #region Private Fields 69 | 70 | private static Dictionary _entities; 71 | private static char[] _hexChars; 72 | private static object _sync; 73 | 74 | #endregion 75 | 76 | #region Static Constructor 77 | 78 | static HttpUtility () 79 | { 80 | _hexChars = "0123456789ABCDEF".ToCharArray (); 81 | _sync = new object (); 82 | } 83 | 84 | #endregion 85 | 86 | #region Private Methods 87 | 88 | private static Dictionary getEntities () 89 | { 90 | lock (_sync) 91 | { 92 | if (_entities == null) 93 | initEntities (); 94 | 95 | return _entities; 96 | } 97 | } 98 | 99 | private static int getNumber (char c) 100 | { 101 | return c >= '0' && c <= '9' ? c - '0' : c >= 'A' && c <= 'F' ? c - 'A' + 10 : c >= 'a' && c <= 'f' ? c - 'a' + 10 : -1; 102 | } 103 | 104 | private static int getNumber (byte[] bytes, int offset, int count) 105 | { 106 | var ret = 0; 107 | 108 | var end = offset + count - 1; 109 | for (var i = offset; i <= end; i++) 110 | { 111 | var num = getNumber ((char)bytes[i]); 112 | if (num == -1) 113 | return -1; 114 | 115 | ret = (ret << 4) + num; 116 | } 117 | 118 | return ret; 119 | } 120 | 121 | private static int getNumber (string s, int offset, int count) 122 | { 123 | var ret = 0; 124 | 125 | var end = offset + count - 1; 126 | for (var i = offset; i <= end; i++) 127 | { 128 | var num = getNumber (s[i]); 129 | if (num == -1) 130 | return -1; 131 | 132 | ret = (ret << 4) + num; 133 | } 134 | 135 | return ret; 136 | } 137 | 138 | private static string htmlDecode (string s) 139 | { 140 | var buff = new StringBuilder (); 141 | 142 | // 0: None 143 | // 1: Right after '&' 144 | // 2: Between '&' and ';' but no NCR 145 | // 3: '#' found after '&' and getting numbers 146 | // 4: 'x' found after '#' and getting numbers 147 | var state = 0; 148 | 149 | var reference = new StringBuilder (); 150 | var num = 0; 151 | 152 | foreach (var c in s) 153 | { 154 | if (state == 0) 155 | { 156 | if (c == '&') 157 | { 158 | reference.Append ('&'); 159 | state = 1; 160 | 161 | continue; 162 | } 163 | 164 | buff.Append (c); 165 | continue; 166 | } 167 | 168 | if (c == '&') 169 | { 170 | buff.Append (reference.ToString ()); 171 | 172 | reference.Length = 0; 173 | reference.Append ('&'); 174 | state = 1; 175 | 176 | continue; 177 | } 178 | 179 | reference.Append (c); 180 | 181 | if (state == 1) 182 | { 183 | if (c == ';') 184 | { 185 | buff.Append (reference.ToString ()); 186 | 187 | reference.Length = 0; 188 | state = 0; 189 | 190 | continue; 191 | } 192 | 193 | num = 0; 194 | 195 | state = c == '#' ? 3 : 2; 196 | 197 | continue; 198 | } 199 | 200 | if (state == 2) 201 | { 202 | if (c == ';') 203 | { 204 | var entity = reference.ToString (); 205 | var name = entity.Substring (1, entity.Length - 2); 206 | 207 | var entities = getEntities (); 208 | if (entities.ContainsKey (name)) 209 | buff.Append (entities[name]); 210 | else 211 | buff.Append (entity); 212 | 213 | reference.Length = 0; 214 | state = 0; 215 | 216 | continue; 217 | } 218 | 219 | continue; 220 | } 221 | 222 | if (state == 3) 223 | { 224 | if (c == ';') 225 | { 226 | if (reference.Length > 3 && num < 65536) 227 | buff.Append ((char)num); 228 | else 229 | buff.Append (reference.ToString ()); 230 | 231 | reference.Length = 0; 232 | state = 0; 233 | 234 | continue; 235 | } 236 | 237 | if (c == 'x') 238 | { 239 | state = reference.Length == 3 ? 4 : 2; 240 | continue; 241 | } 242 | 243 | if (!isNumeric (c)) 244 | { 245 | state = 2; 246 | 247 | continue; 248 | } 249 | 250 | num = num * 10 + (c - '0'); 251 | continue; 252 | } 253 | 254 | if (state == 4) 255 | { 256 | if (c == ';') 257 | { 258 | if (reference.Length > 4 && num < 65536) 259 | buff.Append ((char)num); 260 | else 261 | buff.Append (reference.ToString ()); 262 | 263 | reference.Length = 0; 264 | state = 0; 265 | 266 | continue; 267 | } 268 | 269 | var n = getNumber (c); 270 | if (n == -1) 271 | { 272 | state = 2; 273 | continue; 274 | } 275 | 276 | num = (num << 4) + n; 277 | } 278 | } 279 | 280 | if (reference.Length > 0) 281 | buff.Append (reference.ToString ()); 282 | 283 | return buff.ToString (); 284 | } 285 | 286 | /// 287 | /// Converts the specified string to an HTML-encoded string. 288 | /// 289 | /// 290 | /// 291 | /// This method starts encoding with a NCR from the character code 160 292 | /// but does not stop at the character code 255. 293 | /// 294 | /// 295 | /// One reason is the unicode characters < and > that 296 | /// look like < and >. 297 | /// 298 | /// 299 | /// 300 | /// A that represents an encoded string. 301 | /// 302 | /// 303 | /// A to encode. 304 | /// 305 | /// 306 | /// A : true if encodes without a NCR; 307 | /// otherwise, false. 308 | /// 309 | private static string htmlEncode (string s, bool minimal) 310 | { 311 | var buff = new StringBuilder (); 312 | 313 | foreach (var c in s) 314 | { 315 | buff.Append (c == '"' 316 | ? """ : c == '&' ? "&" : c == '<' ? "<" : c == '>' ? ">" : !minimal && c > 159 ? String.Format ("&#{0};", (int)c) : c.ToString ()); 317 | } 318 | 319 | return buff.ToString (); 320 | } 321 | 322 | /// 323 | /// Initializes the _entities field. 324 | /// 325 | /// 326 | /// This method builds a dictionary of HTML character entity references. 327 | /// This dictionary comes from the HTML 4.01 W3C recommendation. 328 | /// 329 | private static void initEntities () 330 | { 331 | _entities = new Dictionary (); 332 | _entities.Add ("nbsp", '\u00A0'); 333 | _entities.Add ("iexcl", '\u00A1'); 334 | _entities.Add ("cent", '\u00A2'); 335 | _entities.Add ("pound", '\u00A3'); 336 | _entities.Add ("curren", '\u00A4'); 337 | _entities.Add ("yen", '\u00A5'); 338 | _entities.Add ("brvbar", '\u00A6'); 339 | _entities.Add ("sect", '\u00A7'); 340 | _entities.Add ("uml", '\u00A8'); 341 | _entities.Add ("copy", '\u00A9'); 342 | _entities.Add ("ordf", '\u00AA'); 343 | _entities.Add ("laquo", '\u00AB'); 344 | _entities.Add ("not", '\u00AC'); 345 | _entities.Add ("shy", '\u00AD'); 346 | _entities.Add ("reg", '\u00AE'); 347 | _entities.Add ("macr", '\u00AF'); 348 | _entities.Add ("deg", '\u00B0'); 349 | _entities.Add ("plusmn", '\u00B1'); 350 | _entities.Add ("sup2", '\u00B2'); 351 | _entities.Add ("sup3", '\u00B3'); 352 | _entities.Add ("acute", '\u00B4'); 353 | _entities.Add ("micro", '\u00B5'); 354 | _entities.Add ("para", '\u00B6'); 355 | _entities.Add ("middot", '\u00B7'); 356 | _entities.Add ("cedil", '\u00B8'); 357 | _entities.Add ("sup1", '\u00B9'); 358 | _entities.Add ("ordm", '\u00BA'); 359 | _entities.Add ("raquo", '\u00BB'); 360 | _entities.Add ("frac14", '\u00BC'); 361 | _entities.Add ("frac12", '\u00BD'); 362 | _entities.Add ("frac34", '\u00BE'); 363 | _entities.Add ("iquest", '\u00BF'); 364 | _entities.Add ("Agrave", '\u00C0'); 365 | _entities.Add ("Aacute", '\u00C1'); 366 | _entities.Add ("Acirc", '\u00C2'); 367 | _entities.Add ("Atilde", '\u00C3'); 368 | _entities.Add ("Auml", '\u00C4'); 369 | _entities.Add ("Aring", '\u00C5'); 370 | _entities.Add ("AElig", '\u00C6'); 371 | _entities.Add ("Ccedil", '\u00C7'); 372 | _entities.Add ("Egrave", '\u00C8'); 373 | _entities.Add ("Eacute", '\u00C9'); 374 | _entities.Add ("Ecirc", '\u00CA'); 375 | _entities.Add ("Euml", '\u00CB'); 376 | _entities.Add ("Igrave", '\u00CC'); 377 | _entities.Add ("Iacute", '\u00CD'); 378 | _entities.Add ("Icirc", '\u00CE'); 379 | _entities.Add ("Iuml", '\u00CF'); 380 | _entities.Add ("ETH", '\u00D0'); 381 | _entities.Add ("Ntilde", '\u00D1'); 382 | _entities.Add ("Ograve", '\u00D2'); 383 | _entities.Add ("Oacute", '\u00D3'); 384 | _entities.Add ("Ocirc", '\u00D4'); 385 | _entities.Add ("Otilde", '\u00D5'); 386 | _entities.Add ("Ouml", '\u00D6'); 387 | _entities.Add ("times", '\u00D7'); 388 | _entities.Add ("Oslash", '\u00D8'); 389 | _entities.Add ("Ugrave", '\u00D9'); 390 | _entities.Add ("Uacute", '\u00DA'); 391 | _entities.Add ("Ucirc", '\u00DB'); 392 | _entities.Add ("Uuml", '\u00DC'); 393 | _entities.Add ("Yacute", '\u00DD'); 394 | _entities.Add ("THORN", '\u00DE'); 395 | _entities.Add ("szlig", '\u00DF'); 396 | _entities.Add ("agrave", '\u00E0'); 397 | _entities.Add ("aacute", '\u00E1'); 398 | _entities.Add ("acirc", '\u00E2'); 399 | _entities.Add ("atilde", '\u00E3'); 400 | _entities.Add ("auml", '\u00E4'); 401 | _entities.Add ("aring", '\u00E5'); 402 | _entities.Add ("aelig", '\u00E6'); 403 | _entities.Add ("ccedil", '\u00E7'); 404 | _entities.Add ("egrave", '\u00E8'); 405 | _entities.Add ("eacute", '\u00E9'); 406 | _entities.Add ("ecirc", '\u00EA'); 407 | _entities.Add ("euml", '\u00EB'); 408 | _entities.Add ("igrave", '\u00EC'); 409 | _entities.Add ("iacute", '\u00ED'); 410 | _entities.Add ("icirc", '\u00EE'); 411 | _entities.Add ("iuml", '\u00EF'); 412 | _entities.Add ("eth", '\u00F0'); 413 | _entities.Add ("ntilde", '\u00F1'); 414 | _entities.Add ("ograve", '\u00F2'); 415 | _entities.Add ("oacute", '\u00F3'); 416 | _entities.Add ("ocirc", '\u00F4'); 417 | _entities.Add ("otilde", '\u00F5'); 418 | _entities.Add ("ouml", '\u00F6'); 419 | _entities.Add ("divide", '\u00F7'); 420 | _entities.Add ("oslash", '\u00F8'); 421 | _entities.Add ("ugrave", '\u00F9'); 422 | _entities.Add ("uacute", '\u00FA'); 423 | _entities.Add ("ucirc", '\u00FB'); 424 | _entities.Add ("uuml", '\u00FC'); 425 | _entities.Add ("yacute", '\u00FD'); 426 | _entities.Add ("thorn", '\u00FE'); 427 | _entities.Add ("yuml", '\u00FF'); 428 | _entities.Add ("fnof", '\u0192'); 429 | _entities.Add ("Alpha", '\u0391'); 430 | _entities.Add ("Beta", '\u0392'); 431 | _entities.Add ("Gamma", '\u0393'); 432 | _entities.Add ("Delta", '\u0394'); 433 | _entities.Add ("Epsilon", '\u0395'); 434 | _entities.Add ("Zeta", '\u0396'); 435 | _entities.Add ("Eta", '\u0397'); 436 | _entities.Add ("Theta", '\u0398'); 437 | _entities.Add ("Iota", '\u0399'); 438 | _entities.Add ("Kappa", '\u039A'); 439 | _entities.Add ("Lambda", '\u039B'); 440 | _entities.Add ("Mu", '\u039C'); 441 | _entities.Add ("Nu", '\u039D'); 442 | _entities.Add ("Xi", '\u039E'); 443 | _entities.Add ("Omicron", '\u039F'); 444 | _entities.Add ("Pi", '\u03A0'); 445 | _entities.Add ("Rho", '\u03A1'); 446 | _entities.Add ("Sigma", '\u03A3'); 447 | _entities.Add ("Tau", '\u03A4'); 448 | _entities.Add ("Upsilon", '\u03A5'); 449 | _entities.Add ("Phi", '\u03A6'); 450 | _entities.Add ("Chi", '\u03A7'); 451 | _entities.Add ("Psi", '\u03A8'); 452 | _entities.Add ("Omega", '\u03A9'); 453 | _entities.Add ("alpha", '\u03B1'); 454 | _entities.Add ("beta", '\u03B2'); 455 | _entities.Add ("gamma", '\u03B3'); 456 | _entities.Add ("delta", '\u03B4'); 457 | _entities.Add ("epsilon", '\u03B5'); 458 | _entities.Add ("zeta", '\u03B6'); 459 | _entities.Add ("eta", '\u03B7'); 460 | _entities.Add ("theta", '\u03B8'); 461 | _entities.Add ("iota", '\u03B9'); 462 | _entities.Add ("kappa", '\u03BA'); 463 | _entities.Add ("lambda", '\u03BB'); 464 | _entities.Add ("mu", '\u03BC'); 465 | _entities.Add ("nu", '\u03BD'); 466 | _entities.Add ("xi", '\u03BE'); 467 | _entities.Add ("omicron", '\u03BF'); 468 | _entities.Add ("pi", '\u03C0'); 469 | _entities.Add ("rho", '\u03C1'); 470 | _entities.Add ("sigmaf", '\u03C2'); 471 | _entities.Add ("sigma", '\u03C3'); 472 | _entities.Add ("tau", '\u03C4'); 473 | _entities.Add ("upsilon", '\u03C5'); 474 | _entities.Add ("phi", '\u03C6'); 475 | _entities.Add ("chi", '\u03C7'); 476 | _entities.Add ("psi", '\u03C8'); 477 | _entities.Add ("omega", '\u03C9'); 478 | _entities.Add ("thetasym", '\u03D1'); 479 | _entities.Add ("upsih", '\u03D2'); 480 | _entities.Add ("piv", '\u03D6'); 481 | _entities.Add ("bull", '\u2022'); 482 | _entities.Add ("hellip", '\u2026'); 483 | _entities.Add ("prime", '\u2032'); 484 | _entities.Add ("Prime", '\u2033'); 485 | _entities.Add ("oline", '\u203E'); 486 | _entities.Add ("frasl", '\u2044'); 487 | _entities.Add ("weierp", '\u2118'); 488 | _entities.Add ("image", '\u2111'); 489 | _entities.Add ("real", '\u211C'); 490 | _entities.Add ("trade", '\u2122'); 491 | _entities.Add ("alefsym", '\u2135'); 492 | _entities.Add ("larr", '\u2190'); 493 | _entities.Add ("uarr", '\u2191'); 494 | _entities.Add ("rarr", '\u2192'); 495 | _entities.Add ("darr", '\u2193'); 496 | _entities.Add ("harr", '\u2194'); 497 | _entities.Add ("crarr", '\u21B5'); 498 | _entities.Add ("lArr", '\u21D0'); 499 | _entities.Add ("uArr", '\u21D1'); 500 | _entities.Add ("rArr", '\u21D2'); 501 | _entities.Add ("dArr", '\u21D3'); 502 | _entities.Add ("hArr", '\u21D4'); 503 | _entities.Add ("forall", '\u2200'); 504 | _entities.Add ("part", '\u2202'); 505 | _entities.Add ("exist", '\u2203'); 506 | _entities.Add ("empty", '\u2205'); 507 | _entities.Add ("nabla", '\u2207'); 508 | _entities.Add ("isin", '\u2208'); 509 | _entities.Add ("notin", '\u2209'); 510 | _entities.Add ("ni", '\u220B'); 511 | _entities.Add ("prod", '\u220F'); 512 | _entities.Add ("sum", '\u2211'); 513 | _entities.Add ("minus", '\u2212'); 514 | _entities.Add ("lowast", '\u2217'); 515 | _entities.Add ("radic", '\u221A'); 516 | _entities.Add ("prop", '\u221D'); 517 | _entities.Add ("infin", '\u221E'); 518 | _entities.Add ("ang", '\u2220'); 519 | _entities.Add ("and", '\u2227'); 520 | _entities.Add ("or", '\u2228'); 521 | _entities.Add ("cap", '\u2229'); 522 | _entities.Add ("cup", '\u222A'); 523 | _entities.Add ("int", '\u222B'); 524 | _entities.Add ("there4", '\u2234'); 525 | _entities.Add ("sim", '\u223C'); 526 | _entities.Add ("cong", '\u2245'); 527 | _entities.Add ("asymp", '\u2248'); 528 | _entities.Add ("ne", '\u2260'); 529 | _entities.Add ("equiv", '\u2261'); 530 | _entities.Add ("le", '\u2264'); 531 | _entities.Add ("ge", '\u2265'); 532 | _entities.Add ("sub", '\u2282'); 533 | _entities.Add ("sup", '\u2283'); 534 | _entities.Add ("nsub", '\u2284'); 535 | _entities.Add ("sube", '\u2286'); 536 | _entities.Add ("supe", '\u2287'); 537 | _entities.Add ("oplus", '\u2295'); 538 | _entities.Add ("otimes", '\u2297'); 539 | _entities.Add ("perp", '\u22A5'); 540 | _entities.Add ("sdot", '\u22C5'); 541 | _entities.Add ("lceil", '\u2308'); 542 | _entities.Add ("rceil", '\u2309'); 543 | _entities.Add ("lfloor", '\u230A'); 544 | _entities.Add ("rfloor", '\u230B'); 545 | _entities.Add ("lang", '\u2329'); 546 | _entities.Add ("rang", '\u232A'); 547 | _entities.Add ("loz", '\u25CA'); 548 | _entities.Add ("spades", '\u2660'); 549 | _entities.Add ("clubs", '\u2663'); 550 | _entities.Add ("hearts", '\u2665'); 551 | _entities.Add ("diams", '\u2666'); 552 | _entities.Add ("quot", '\u0022'); 553 | _entities.Add ("amp", '\u0026'); 554 | _entities.Add ("lt", '\u003C'); 555 | _entities.Add ("gt", '\u003E'); 556 | _entities.Add ("OElig", '\u0152'); 557 | _entities.Add ("oelig", '\u0153'); 558 | _entities.Add ("Scaron", '\u0160'); 559 | _entities.Add ("scaron", '\u0161'); 560 | _entities.Add ("Yuml", '\u0178'); 561 | _entities.Add ("circ", '\u02C6'); 562 | _entities.Add ("tilde", '\u02DC'); 563 | _entities.Add ("ensp", '\u2002'); 564 | _entities.Add ("emsp", '\u2003'); 565 | _entities.Add ("thinsp", '\u2009'); 566 | _entities.Add ("zwnj", '\u200C'); 567 | _entities.Add ("zwj", '\u200D'); 568 | _entities.Add ("lrm", '\u200E'); 569 | _entities.Add ("rlm", '\u200F'); 570 | _entities.Add ("ndash", '\u2013'); 571 | _entities.Add ("mdash", '\u2014'); 572 | _entities.Add ("lsquo", '\u2018'); 573 | _entities.Add ("rsquo", '\u2019'); 574 | _entities.Add ("sbquo", '\u201A'); 575 | _entities.Add ("ldquo", '\u201C'); 576 | _entities.Add ("rdquo", '\u201D'); 577 | _entities.Add ("bdquo", '\u201E'); 578 | _entities.Add ("dagger", '\u2020'); 579 | _entities.Add ("Dagger", '\u2021'); 580 | _entities.Add ("permil", '\u2030'); 581 | _entities.Add ("lsaquo", '\u2039'); 582 | _entities.Add ("rsaquo", '\u203A'); 583 | _entities.Add ("euro", '\u20AC'); 584 | } 585 | 586 | private static bool isAlphabet (char c) 587 | { 588 | return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'); 589 | } 590 | 591 | private static bool isNumeric (char c) 592 | { 593 | return c >= '0' && c <= '9'; 594 | } 595 | 596 | private static bool isUnreserved (char c) 597 | { 598 | return c == '*' || c == '-' || c == '.' || c == '_'; 599 | } 600 | 601 | private static bool isUnreservedInRfc2396 (char c) 602 | { 603 | return c == '!' || c == '\'' || c == '(' || c == ')' || c == '*' || c == '-' || c == '.' || c == '_' || c == '~'; 604 | } 605 | 606 | private static bool isUnreservedInRfc3986 (char c) 607 | { 608 | return c == '-' || c == '.' || c == '_' || c == '~'; 609 | } 610 | 611 | private static byte[] urlDecodeToBytes (byte[] bytes, int offset, int count) 612 | { 613 | using (var buff = new MemoryStream ()) 614 | { 615 | var end = offset + count - 1; 616 | for (var i = offset; i <= end; i++) 617 | { 618 | var b = bytes[i]; 619 | 620 | var c = (char)b; 621 | if (c == '%') 622 | { 623 | if (i > end - 2) 624 | break; 625 | 626 | var num = getNumber (bytes, i + 1, 2); 627 | if (num == -1) 628 | break; 629 | 630 | buff.WriteByte ((byte)num); 631 | i += 2; 632 | 633 | continue; 634 | } 635 | 636 | if (c == '+') 637 | { 638 | buff.WriteByte ((byte)' '); 639 | continue; 640 | } 641 | 642 | buff.WriteByte (b); 643 | } 644 | 645 | buff.Close (); 646 | return buff.ToArray (); 647 | } 648 | } 649 | 650 | private static void urlEncode (byte b, Stream output) 651 | { 652 | if (b > 31 && b < 127) 653 | { 654 | var c = (char)b; 655 | if (c == ' ') 656 | { 657 | output.WriteByte ((byte)'+'); 658 | return; 659 | } 660 | 661 | if (isNumeric (c)) 662 | { 663 | output.WriteByte (b); 664 | return; 665 | } 666 | 667 | if (isAlphabet (c)) 668 | { 669 | output.WriteByte (b); 670 | return; 671 | } 672 | 673 | if (isUnreserved (c)) 674 | { 675 | output.WriteByte (b); 676 | return; 677 | } 678 | } 679 | 680 | var i = (int)b; 681 | var bytes = new byte[] { 682 | (byte) '%', 683 | (byte) _hexChars[i >> 4], 684 | (byte) _hexChars[i & 0x0F] 685 | }; 686 | 687 | output.Write (bytes, 0, 3); 688 | } 689 | 690 | private static byte[] urlEncodeToBytes (byte[] bytes, int offset, int count) 691 | { 692 | using (var buff = new MemoryStream ()) 693 | { 694 | var end = offset + count - 1; 695 | for (var i = offset; i <= end; i++) 696 | urlEncode (bytes[i], buff); 697 | 698 | buff.Close (); 699 | return buff.ToArray (); 700 | } 701 | } 702 | 703 | #endregion 704 | 705 | #region Internal Methods 706 | 707 | internal static Uri CreateRequestUrl (string requestUri, string host, bool websocketRequest, bool secure) 708 | { 709 | if (requestUri == null || requestUri.Length == 0) 710 | return null; 711 | 712 | if (host == null || host.Length == 0) 713 | return null; 714 | 715 | string schm = null; 716 | string path = null; 717 | 718 | if (requestUri.IndexOf ('/') == 0) 719 | { 720 | path = requestUri; 721 | } 722 | else if (requestUri.MaybeUri ()) 723 | { 724 | Uri uri; 725 | if (!Uri.TryCreate (requestUri, UriKind.Absolute, out uri)) 726 | return null; 727 | 728 | schm = uri.Scheme; 729 | var valid = websocketRequest 730 | ? schm == "ws" || schm == "wss" 731 | : schm == "http" || schm == "https"; 732 | 733 | if (!valid) 734 | return null; 735 | 736 | host = uri.Authority; 737 | path = uri.PathAndQuery; 738 | } 739 | else if (requestUri == "*") 740 | { 741 | } 742 | else 743 | { 744 | // As the authority form 745 | host = requestUri; 746 | } 747 | 748 | if (schm == null) 749 | { 750 | schm = websocketRequest 751 | ? (secure ? "wss" : "ws") 752 | : (secure ? "https" : "http"); 753 | } 754 | 755 | if (host.IndexOf (':') == -1) 756 | host = String.Format ("{0}:{1}", host, secure ? 443 : 80); 757 | 758 | var url = String.Format ("{0}://{1}{2}", schm, host, path); 759 | 760 | Uri ret; 761 | return Uri.TryCreate (url, UriKind.Absolute, out ret) ? ret : null; 762 | } 763 | 764 | internal static IPrincipal CreateUser (string response, AuthenticationSchemes scheme, string realm, string method, Func credentialsFinder) 765 | { 766 | if (response == null || response.Length == 0) 767 | return null; 768 | 769 | if (scheme == AuthenticationSchemes.Digest) 770 | { 771 | if (realm == null || realm.Length == 0) 772 | return null; 773 | 774 | if (method == null || method.Length == 0) 775 | return null; 776 | } 777 | else 778 | { 779 | if (scheme != AuthenticationSchemes.Basic) 780 | return null; 781 | } 782 | 783 | if (credentialsFinder == null) 784 | return null; 785 | 786 | var compType = StringComparison.OrdinalIgnoreCase; 787 | if (response.IndexOf (scheme.ToString (), compType) != 0) 788 | return null; 789 | 790 | var res = AuthenticationResponse.Parse (response); 791 | if (res == null) 792 | return null; 793 | 794 | var id = res.ToIdentity (); 795 | if (id == null) 796 | return null; 797 | 798 | NetworkCredential cred = null; 799 | try 800 | { 801 | cred = credentialsFinder (id); 802 | } 803 | catch 804 | { 805 | } 806 | 807 | if (cred == null) 808 | return null; 809 | 810 | if (scheme == AuthenticationSchemes.Basic) 811 | { 812 | var basicId = (HttpBasicIdentity)id; 813 | return basicId.Password == cred.Password 814 | ? new GenericPrincipal (id, cred.Roles) 815 | : null; 816 | } 817 | 818 | var digestId = (HttpDigestIdentity)id; 819 | return digestId.IsValid (cred.Password, realm, method, null) 820 | ? new GenericPrincipal (id, cred.Roles) 821 | : null; 822 | } 823 | 824 | internal static Encoding GetEncoding (string contentType) 825 | { 826 | var name = "charset="; 827 | var compType = StringComparison.OrdinalIgnoreCase; 828 | 829 | foreach (var elm in contentType.SplitHeaderValue (';')) 830 | { 831 | var part = elm.Trim (); 832 | if (part.IndexOf (name, compType) != 0) 833 | continue; 834 | 835 | var val = part.GetValue ('=', true); 836 | if (val == null || val.Length == 0) 837 | return null; 838 | 839 | return Encoding.GetEncoding (val); 840 | } 841 | 842 | return null; 843 | } 844 | 845 | internal static string GetMimeType (string contentType) 846 | { 847 | if (String.IsNullOrEmpty (contentType)) 848 | return null; 849 | 850 | var parts = contentType.Split (';'); 851 | 852 | return parts[0].Trim (); 853 | } 854 | 855 | internal static bool TryGetEncoding (string contentType, out Encoding result) 856 | { 857 | result = null; 858 | 859 | try 860 | { 861 | result = GetEncoding (contentType); 862 | } 863 | catch 864 | { 865 | return false; 866 | } 867 | 868 | return result != null; 869 | } 870 | 871 | #endregion 872 | 873 | #region Public Methods 874 | 875 | //#if !SSHARP 876 | public static string HtmlAttributeEncode (string s) 877 | { 878 | if (s == null) 879 | throw new ArgumentNullException ("s"); 880 | 881 | return s.Length > 0 ? htmlEncode (s, true) : s; 882 | } 883 | 884 | public static void HtmlAttributeEncode (string s, TextWriter output) 885 | { 886 | if (s == null) 887 | throw new ArgumentNullException ("s"); 888 | 889 | if (output == null) 890 | throw new ArgumentNullException ("output"); 891 | 892 | if (s.Length == 0) 893 | return; 894 | 895 | output.Write (htmlEncode (s, true)); 896 | } 897 | 898 | public static string HtmlDecode (string s) 899 | { 900 | if (s == null) 901 | throw new ArgumentNullException ("s"); 902 | 903 | return s.Length > 0 ? htmlDecode (s) : s; 904 | } 905 | 906 | public static void HtmlDecode (string s, TextWriter output) 907 | { 908 | if (s == null) 909 | throw new ArgumentNullException ("s"); 910 | 911 | if (output == null) 912 | throw new ArgumentNullException ("output"); 913 | 914 | if (s.Length == 0) 915 | return; 916 | 917 | output.Write (htmlDecode (s)); 918 | } 919 | 920 | public static string HtmlEncode (string s) 921 | { 922 | if (s == null) 923 | throw new ArgumentNullException ("s"); 924 | 925 | return s.Length > 0 ? htmlEncode (s, false) : s; 926 | } 927 | 928 | public static void HtmlEncode (string s, TextWriter output) 929 | { 930 | if (s == null) 931 | throw new ArgumentNullException ("s"); 932 | 933 | if (output == null) 934 | throw new ArgumentNullException ("output"); 935 | 936 | if (s.Length == 0) 937 | return; 938 | 939 | output.Write (htmlEncode (s, false)); 940 | } 941 | 942 | public static string UrlDecode (string s) 943 | { 944 | return UrlDecode (s, Encoding.UTF8); 945 | } 946 | 947 | public static string UrlDecode (byte[] bytes, Encoding encoding) 948 | { 949 | if (bytes == null) 950 | throw new ArgumentNullException ("bytes"); 951 | 952 | var len = bytes.Length; 953 | return len > 0 ? (encoding ?? Encoding.UTF8).GetString (urlDecodeToBytes (bytes, 0, len)) : String.Empty; 954 | } 955 | 956 | public static string UrlDecode (string s, Encoding encoding) 957 | { 958 | if (s == null) 959 | throw new ArgumentNullException ("s"); 960 | 961 | if (s.Length == 0) 962 | return s; 963 | 964 | var bytes = Encoding.ASCII.GetBytes (s); 965 | return (encoding ?? Encoding.UTF8).GetString (urlDecodeToBytes (bytes, 0, bytes.Length)); 966 | } 967 | 968 | public static string UrlDecode (byte[] bytes, int offset, int count, Encoding encoding) 969 | { 970 | if (bytes == null) 971 | throw new ArgumentNullException ("bytes"); 972 | 973 | var len = bytes.Length; 974 | if (len == 0) 975 | { 976 | if (offset != 0) 977 | throw new ArgumentOutOfRangeException ("offset"); 978 | 979 | if (count != 0) 980 | throw new ArgumentOutOfRangeException ("count"); 981 | 982 | return String.Empty; 983 | } 984 | 985 | if (offset < 0 || offset >= len) 986 | throw new ArgumentOutOfRangeException ("offset"); 987 | 988 | if (count < 0 || count > len - offset) 989 | throw new ArgumentOutOfRangeException ("count"); 990 | 991 | return count > 0 ? (encoding ?? Encoding.UTF8).GetString (urlDecodeToBytes (bytes, offset, count)) : String.Empty; 992 | } 993 | 994 | public static byte[] UrlDecodeToBytes (byte[] bytes) 995 | { 996 | if (bytes == null) 997 | throw new ArgumentNullException ("bytes"); 998 | 999 | var len = bytes.Length; 1000 | return len > 0 ? urlDecodeToBytes (bytes, 0, len) : bytes; 1001 | } 1002 | 1003 | public static byte[] UrlDecodeToBytes (string s) 1004 | { 1005 | if (s == null) 1006 | throw new ArgumentNullException ("s"); 1007 | 1008 | if (s.Length == 0) 1009 | return new byte[0]; 1010 | 1011 | var bytes = Encoding.ASCII.GetBytes (s); 1012 | return urlDecodeToBytes (bytes, 0, bytes.Length); 1013 | } 1014 | 1015 | public static byte[] UrlDecodeToBytes (byte[] bytes, int offset, int count) 1016 | { 1017 | if (bytes == null) 1018 | throw new ArgumentNullException ("bytes"); 1019 | 1020 | var len = bytes.Length; 1021 | if (len == 0) 1022 | { 1023 | if (offset != 0) 1024 | throw new ArgumentOutOfRangeException ("offset"); 1025 | 1026 | if (count != 0) 1027 | throw new ArgumentOutOfRangeException ("count"); 1028 | 1029 | return bytes; 1030 | } 1031 | 1032 | if (offset < 0 || offset >= len) 1033 | throw new ArgumentOutOfRangeException ("offset"); 1034 | 1035 | if (count < 0 || count > len - offset) 1036 | throw new ArgumentOutOfRangeException ("count"); 1037 | 1038 | return count > 0 ? urlDecodeToBytes (bytes, offset, count) : new byte[0]; 1039 | } 1040 | 1041 | public static string UrlEncode (byte[] bytes) 1042 | { 1043 | if (bytes == null) 1044 | throw new ArgumentNullException ("bytes"); 1045 | 1046 | var len = bytes.Length; 1047 | return len > 0 ? Encoding.ASCII.GetString (urlEncodeToBytes (bytes, 0, len)) : String.Empty; 1048 | } 1049 | 1050 | public static string UrlEncode (string s) 1051 | { 1052 | return UrlEncode (s, Encoding.UTF8); 1053 | } 1054 | 1055 | public static string UrlEncode (string s, Encoding encoding) 1056 | { 1057 | if (s == null) 1058 | throw new ArgumentNullException ("s"); 1059 | 1060 | var len = s.Length; 1061 | if (len == 0) 1062 | return s; 1063 | 1064 | if (encoding == null) 1065 | encoding = Encoding.UTF8; 1066 | 1067 | var bytes = new byte[encoding.GetMaxByteCount (len)]; 1068 | var realLen = encoding.GetBytes (s, 0, len, bytes, 0); 1069 | 1070 | return Encoding.ASCII.GetString (urlEncodeToBytes (bytes, 0, realLen)); 1071 | } 1072 | 1073 | public static string UrlEncode (byte[] bytes, int offset, int count) 1074 | { 1075 | if (bytes == null) 1076 | throw new ArgumentNullException ("bytes"); 1077 | 1078 | var len = bytes.Length; 1079 | if (len == 0) 1080 | { 1081 | if (offset != 0) 1082 | throw new ArgumentOutOfRangeException ("offset"); 1083 | 1084 | if (count != 0) 1085 | throw new ArgumentOutOfRangeException ("count"); 1086 | 1087 | return String.Empty; 1088 | } 1089 | 1090 | if (offset < 0 || offset >= len) 1091 | throw new ArgumentOutOfRangeException ("offset"); 1092 | 1093 | if (count < 0 || count > len - offset) 1094 | throw new ArgumentOutOfRangeException ("count"); 1095 | 1096 | return count > 0 ? Encoding.ASCII.GetString (urlEncodeToBytes (bytes, offset, count)) : String.Empty; 1097 | } 1098 | 1099 | public static byte[] UrlEncodeToBytes (byte[] bytes) 1100 | { 1101 | if (bytes == null) 1102 | throw new ArgumentNullException ("bytes"); 1103 | 1104 | var len = bytes.Length; 1105 | return len > 0 ? urlEncodeToBytes (bytes, 0, len) : bytes; 1106 | } 1107 | 1108 | public static byte[] UrlEncodeToBytes (string s) 1109 | { 1110 | return UrlEncodeToBytes (s, Encoding.UTF8); 1111 | } 1112 | 1113 | public static byte[] UrlEncodeToBytes (string s, Encoding encoding) 1114 | { 1115 | if (s == null) 1116 | throw new ArgumentNullException ("s"); 1117 | 1118 | if (s.Length == 0) 1119 | return new byte[0]; 1120 | 1121 | var bytes = (encoding ?? Encoding.UTF8).GetBytes (s); 1122 | return urlEncodeToBytes (bytes, 0, bytes.Length); 1123 | } 1124 | 1125 | public static byte[] UrlEncodeToBytes (byte[] bytes, int offset, int count) 1126 | { 1127 | if (bytes == null) 1128 | throw new ArgumentNullException ("bytes"); 1129 | 1130 | var len = bytes.Length; 1131 | if (len == 0) 1132 | { 1133 | if (offset != 0) 1134 | throw new ArgumentOutOfRangeException ("offset"); 1135 | 1136 | if (count != 0) 1137 | throw new ArgumentOutOfRangeException ("count"); 1138 | 1139 | return bytes; 1140 | } 1141 | 1142 | if (offset < 0 || offset >= len) 1143 | throw new ArgumentOutOfRangeException ("offset"); 1144 | 1145 | if (count < 0 || count > len - offset) 1146 | throw new ArgumentOutOfRangeException ("count"); 1147 | 1148 | return count > 0 ? urlEncodeToBytes (bytes, offset, count) : new byte[0]; 1149 | } 1150 | 1151 | //#endif 1152 | 1153 | #endregion 1154 | } 1155 | } 1156 | -------------------------------------------------------------------------------- /Net/HttpVersion.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/HttpVersion.cs -------------------------------------------------------------------------------- /Net/InputChunkState.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/InputChunkState.cs -------------------------------------------------------------------------------- /Net/InputState.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/InputState.cs -------------------------------------------------------------------------------- /Net/LineState.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/LineState.cs -------------------------------------------------------------------------------- /Net/NetworkCredential.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/NetworkCredential.cs -------------------------------------------------------------------------------- /Net/ProtocolViolationException.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.Net.ProtocolViolationException.cs 3 | // 4 | // Author: 5 | // Lawrence Pit (loz@cable.a2000.nl) 6 | // 7 | 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | using System.Globalization; 31 | #if !NETCF 32 | using System.Runtime.Serialization; 33 | #endif 34 | 35 | #if SSHARP 36 | namespace SSMono.Net 37 | #else 38 | namespace System.Net 39 | #endif 40 | { 41 | [Serializable] 42 | public class ProtocolViolationException : InvalidOperationException 43 | #if !NETCF 44 | , ISerializable 45 | #endif 46 | { 47 | 48 | // Constructors 49 | public ProtocolViolationException () : base () 50 | { 51 | } 52 | 53 | public ProtocolViolationException (string message) : base (message) 54 | { 55 | } 56 | 57 | #if !NETCF 58 | protected ProtocolViolationException (SerializationInfo serializationInfo, StreamingContext streamingContext) 59 | : base (serializationInfo, streamingContext) 60 | { 61 | } 62 | 63 | // Methods 64 | void ISerializable.GetObjectData (SerializationInfo info, StreamingContext context) 65 | { 66 | base.GetObjectData (info, context); 67 | } 68 | 69 | public override void GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext) 70 | { 71 | base.GetObjectData (serializationInfo, streamingContext); 72 | } 73 | #endif 74 | } 75 | } 76 | 77 | -------------------------------------------------------------------------------- /Net/QueryStringCollection.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | 3 | /* 4 | * QueryStringCollection.cs 5 | * 6 | * This code is derived from HttpUtility.cs (System.Net) of Mono 7 | * (http://www.mono-project.com). 8 | * 9 | * The MIT License 10 | * 11 | * Copyright (c) 2005-2009 Novell, Inc. (http://www.novell.com) 12 | * Copyright (c) 2018 sta.blockhead 13 | * Copyright © 2018 Nivloc Enterprises Ltd 14 | * 15 | * Permission is hereby granted, free of charge, to any person obtaining a copy 16 | * of this software and associated documentation files (the "Software"), to deal 17 | * in the Software without restriction, including without limitation the rights 18 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 19 | * copies of the Software, and to permit persons to whom the Software is 20 | * furnished to do so, subject to the following conditions: 21 | * 22 | * The above copyright notice and this permission notice shall be included in 23 | * all copies or substantial portions of the Software. 24 | * 25 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 27 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 28 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 29 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 30 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 31 | * THE SOFTWARE. 32 | */ 33 | 34 | #endregion 35 | 36 | #region Authors 37 | 38 | /* 39 | * Authors: 40 | * - Patrik Torstensson 41 | * - Wictor Wilén (decode/encode functions) 42 | * - Tim Coleman 43 | * - Gonzalo Paniagua Javier 44 | */ 45 | 46 | #endregion 47 | 48 | using System; 49 | using System.Collections.Specialized; 50 | using System.Text; 51 | 52 | 53 | namespace WebSocketSharp.Net 54 | { 55 | internal sealed class QueryStringCollection : NameValueCollection 56 | { 57 | #region Public Constructors 58 | 59 | public QueryStringCollection () 60 | { 61 | } 62 | 63 | public QueryStringCollection (int capacity) 64 | : base (capacity) 65 | { 66 | } 67 | 68 | #endregion 69 | 70 | #region Private Methods 71 | 72 | private static string urlDecode (string s, Encoding encoding) 73 | { 74 | return s.IndexOfAny (new[] { '%', '+' }) > -1 75 | #if SSHARP 76 | ? Crestron.SimplSharp.Net.HttpUtility.UrlDecode (s, encoding) 77 | #else 78 | ? HttpUtility.UrlDecode (s, encoding) 79 | #endif 80 | : s; 81 | } 82 | 83 | #endregion 84 | 85 | #region Public Methods 86 | 87 | public static QueryStringCollection Parse (string query) 88 | { 89 | return Parse (query, Encoding.UTF8); 90 | } 91 | 92 | public static QueryStringCollection Parse (string query, Encoding encoding) 93 | { 94 | if (query == null) 95 | return new QueryStringCollection (1); 96 | 97 | var len = query.Length; 98 | if (len == 0) 99 | return new QueryStringCollection (1); 100 | 101 | if (query == "?") 102 | return new QueryStringCollection (1); 103 | 104 | if (query[0] == '?') 105 | query = query.Substring (1); 106 | 107 | if (encoding == null) 108 | encoding = Encoding.UTF8; 109 | 110 | var ret = new QueryStringCollection (); 111 | 112 | var components = query.Split ('&'); 113 | foreach (var component in components) 114 | { 115 | len = component.Length; 116 | if (len == 0) 117 | continue; 118 | 119 | if (component == "=") 120 | continue; 121 | 122 | var i = component.IndexOf ('='); 123 | if (i < 0) 124 | { 125 | ret.Add (null, urlDecode (component, encoding)); 126 | continue; 127 | } 128 | 129 | if (i == 0) 130 | { 131 | ret.Add (null, urlDecode (component.Substring (1), encoding)); 132 | continue; 133 | } 134 | 135 | var name = urlDecode (component.Substring (0, i), encoding); 136 | 137 | var start = i + 1; 138 | var val = start < len 139 | ? urlDecode (component.Substring (start), encoding) 140 | : String.Empty; 141 | 142 | ret.Add (name, val); 143 | } 144 | 145 | return ret; 146 | } 147 | 148 | public override string ToString () 149 | { 150 | var buff = new StringBuilder (); 151 | 152 | foreach (var key in AllKeys) 153 | buff.AppendFormat ("{0}={1}&", key, this[key]); 154 | 155 | if (buff.Length > 0) 156 | buff.Length--; 157 | 158 | return buff.ToString (); 159 | } 160 | 161 | #endregion 162 | } 163 | } -------------------------------------------------------------------------------- /Net/ReadBufferState.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/ReadBufferState.cs -------------------------------------------------------------------------------- /Net/RequestStream.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/RequestStream.cs -------------------------------------------------------------------------------- /Net/ResponseStream.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/ResponseStream.cs -------------------------------------------------------------------------------- /Net/RuntimeHelpers.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.Web.Util.RuntimeHelpers 3 | // 4 | // Authors: 5 | // Marek Habersack (mhabersack@novell.com) 6 | // 7 | // (C) 2006-2010 Novell, Inc (http://www.novell.com) 8 | // 9 | 10 | // 11 | // Permission is hereby granted, free of charge, to any person obtaining 12 | // a copy of this software and associated documentation files (the 13 | // "Software"), to deal in the Software without restriction, including 14 | // without limitation the rights to use, copy, modify, merge, publish, 15 | // distribute, sublicense, and/or sell copies of the Software, and to 16 | // permit persons to whom the Software is furnished to do so, subject to 17 | // the following conditions: 18 | // 19 | // The above copyright notice and this permission notice shall be 20 | // included in all copies or substantial portions of the Software. 21 | // 22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 23 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 24 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 25 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 26 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 27 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 28 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 29 | // 30 | using System; 31 | using System.Collections.Generic; 32 | #if SSHARP 33 | using SSMono.ComponentModel; 34 | using Crestron.SimplSharp; 35 | using Crestron.SimplSharp.Reflection; 36 | using Crestron.SimplSharp.CrestronIO; 37 | using Environment = SSMono.Environment; 38 | #else 39 | using System.ComponentModel; 40 | using System.Reflection; 41 | using System.Web.Configuration; 42 | #endif 43 | 44 | #if SSHARP 45 | namespace SSMono.Web.Util 46 | #else 47 | namespace System.Web.Util 48 | #endif 49 | { 50 | public static class RuntimeHelpers 51 | { 52 | public static bool CaseInsensitive 53 | { 54 | get; 55 | private set; 56 | } 57 | 58 | public static bool DebuggingEnabled { 59 | get { 60 | #if !NETCF 61 | CompilationSection cs = WebConfigurationManager.GetSection ("system.web/compilation") as CompilationSection; 62 | if (cs != null) 63 | return cs.Debug; 64 | #endif 65 | 66 | return false; 67 | } 68 | } 69 | 70 | public static IEqualityComparer StringEqualityComparer 71 | { 72 | get; 73 | private set; 74 | } 75 | 76 | public static IEqualityComparer StringEqualityComparerCulture 77 | { 78 | get; 79 | private set; 80 | } 81 | 82 | public static bool IsUncShare 83 | { 84 | get; 85 | private set; 86 | } 87 | 88 | public static string MonoVersion 89 | { 90 | get; 91 | private set; 92 | } 93 | 94 | public static bool RunningOnWindows 95 | { 96 | get; 97 | private set; 98 | } 99 | 100 | public static StringComparison StringComparison 101 | { 102 | get; 103 | private set; 104 | } 105 | 106 | public static StringComparison StringComparisonCulture 107 | { 108 | get; 109 | private set; 110 | } 111 | 112 | static RuntimeHelpers () 113 | { 114 | PlatformID pid = Environment.OSVersion.Platform; 115 | RunningOnWindows = ((int)pid != 128 && pid != PlatformID.Unix 116 | #if !NETCF 117 | && pid != PlatformID.MacOSX 118 | #endif 119 | ); 120 | 121 | if (RunningOnWindows) 122 | { 123 | CaseInsensitive = true; 124 | #if SSHARP 125 | string appDomainAppPath = Path.Combine (InitialParametersClass.ProgramDirectory.ToString (), "wwwroot").Replace ('\\', '/'); 126 | #else 127 | string appDomainAppPath = AppDomain.CurrentDomain.GetData (".appPath") as string; 128 | #endif 129 | if (!String.IsNullOrEmpty (appDomainAppPath)) 130 | { 131 | try 132 | { 133 | IsUncShare = new Uri (appDomainAppPath).IsUnc; 134 | } 135 | catch 136 | { 137 | // ignore 138 | } 139 | } 140 | } 141 | #if !NETCF 142 | else 143 | { 144 | string mono_iomap = Environment.GetEnvironmentVariable ("MONO_IOMAP"); 145 | if (!String.IsNullOrEmpty (mono_iomap)) 146 | { 147 | if (mono_iomap == "all") 148 | CaseInsensitive = true; 149 | else 150 | { 151 | string[] parts = mono_iomap.Split (':'); 152 | foreach (string p in parts) 153 | { 154 | if (p == "all" || p == "case") 155 | { 156 | CaseInsensitive = true; 157 | break; 158 | } 159 | } 160 | } 161 | } 162 | } 163 | #endif 164 | if (CaseInsensitive) 165 | { 166 | StringEqualityComparer = StringComparer.OrdinalIgnoreCase; 167 | StringEqualityComparerCulture = StringComparer.CurrentCultureIgnoreCase; 168 | StringComparison = StringComparison.OrdinalIgnoreCase; 169 | StringComparisonCulture = StringComparison.CurrentCultureIgnoreCase; 170 | } 171 | else 172 | { 173 | StringEqualityComparer = StringComparer.Ordinal; 174 | StringEqualityComparerCulture = StringComparer.CurrentCulture; 175 | StringComparison = StringComparison.Ordinal; 176 | StringComparisonCulture = StringComparison.CurrentCulture; 177 | } 178 | 179 | string monoVersion = null; 180 | #if !NETCF 181 | try 182 | { 183 | Type monoRuntime = Type.GetType ("Mono.Runtime", false); 184 | if (monoRuntime != null) 185 | { 186 | MethodInfo mi = monoRuntime.GetMethod ("GetDisplayName", BindingFlags.Static | BindingFlags.NonPublic); 187 | if (mi != null) 188 | monoVersion = mi.Invoke (null, new object[0]) as string; 189 | } 190 | } 191 | catch 192 | { 193 | // ignore 194 | } 195 | #endif 196 | if (monoVersion == null) 197 | monoVersion = Environment.Version.ToString (); 198 | 199 | MonoVersion = monoVersion; 200 | } 201 | } 202 | } 203 | -------------------------------------------------------------------------------- /Net/ServerSslConfiguration.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | /* 3 | * ServerSslConfiguration.cs 4 | * 5 | * The MIT License 6 | * 7 | * Copyright (c) 2014 liryna 8 | * Copyright (c) 2014-2017 sta.blockhead 9 | * Copyright © 2017 Nivloc Enterprises Ltd 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in 19 | * all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | * THE SOFTWARE. 28 | */ 29 | #endregion 30 | 31 | #region Authors 32 | /* 33 | * Authors: 34 | * - Liryna 35 | */ 36 | #endregion 37 | 38 | #if !NETCF || BCC || SSL 39 | using System; 40 | #if SSHARP 41 | #if BCC 42 | #elif SSL 43 | using SSMono.Security.Cryptography.X509Certificates; 44 | using Mono.Security.Protocol.Tls; 45 | using SSMono.Net.Security; 46 | #endif 47 | using SSMono.Security.Authentication; 48 | #else 49 | using System.Net.Security; 50 | using System.Security.Authentication; 51 | using System.Security.Cryptography.X509Certificates; 52 | #endif 53 | 54 | namespace WebSocketSharp.Net 55 | { 56 | /// 57 | /// Stores the parameters for the used by servers. 58 | /// 59 | public class ServerSslConfiguration 60 | { 61 | #region Private Fields 62 | 63 | private bool _checkCertRevocation; 64 | private bool _clientCertRequired; 65 | private RemoteCertificateValidationCallback _clientCertValidationCallback; 66 | private SslProtocols _enabledSslProtocols; 67 | private X509Certificate2 _serverCert; 68 | 69 | #endregion 70 | 71 | #region Public Constructors 72 | 73 | /// 74 | /// Initializes a new instance of the class. 75 | /// 76 | public ServerSslConfiguration () 77 | { 78 | _enabledSslProtocols = SslProtocols.Default; 79 | } 80 | 81 | /// 82 | /// Copies the parameters from the specified to 83 | /// a new instance of the class. 84 | /// 85 | /// 86 | /// A from which to copy. 87 | /// 88 | /// 89 | /// is . 90 | /// 91 | public ServerSslConfiguration (ServerSslConfiguration configuration) 92 | { 93 | if (configuration == null) 94 | throw new ArgumentNullException ("configuration"); 95 | 96 | _checkCertRevocation = configuration._checkCertRevocation; 97 | _clientCertRequired = configuration._clientCertRequired; 98 | _clientCertValidationCallback = configuration._clientCertValidationCallback; 99 | _enabledSslProtocols = configuration._enabledSslProtocols; 100 | _serverCert = configuration._serverCert; 101 | } 102 | 103 | /// 104 | /// Initializes a new instance of the class with 105 | /// the specified . 106 | /// 107 | /// 108 | /// A that represents the certificate used to 109 | /// authenticate the server. 110 | /// 111 | public ServerSslConfiguration (X509Certificate2 serverCertificate) 112 | { 113 | _serverCert = serverCertificate; 114 | _enabledSslProtocols = SslProtocols.Default; 115 | } 116 | 117 | #endregion 118 | 119 | #region Public Properties 120 | 121 | /// 122 | /// Gets or sets a value indicating whether the certificate revocation 123 | /// list is checked during authentication. 124 | /// 125 | /// 126 | /// 127 | /// true if the certificate revocation list is checked during 128 | /// authentication; otherwise, false. 129 | /// 130 | /// 131 | /// The default value is false. 132 | /// 133 | /// 134 | public bool CheckCertificateRevocation 135 | { 136 | get 137 | { 138 | return _checkCertRevocation; 139 | } 140 | 141 | set 142 | { 143 | _checkCertRevocation = value; 144 | } 145 | } 146 | 147 | /// 148 | /// Gets or sets a value indicating whether the client is asked for 149 | /// a certificate for authentication. 150 | /// 151 | /// 152 | /// 153 | /// true if the client is asked for a certificate for 154 | /// authentication; otherwise, false. 155 | /// 156 | /// 157 | /// The default value is false. 158 | /// 159 | /// 160 | public bool ClientCertificateRequired 161 | { 162 | get 163 | { 164 | return _clientCertRequired; 165 | } 166 | 167 | set 168 | { 169 | _clientCertRequired = value; 170 | } 171 | } 172 | 173 | /// 174 | /// Gets or sets the callback used to validate the certificate supplied by the client. 175 | /// 176 | /// 177 | /// The certificate is valid if the callback returns true. 178 | /// 179 | /// 180 | /// 181 | /// A delegate that 182 | /// invokes the method called for validating the certificate. 183 | /// 184 | /// 185 | /// The default value is a delegate that invokes a method that 186 | /// only returns true. 187 | /// 188 | /// 189 | public RemoteCertificateValidationCallback ClientCertificateValidationCallback 190 | { 191 | get 192 | { 193 | if (_clientCertValidationCallback == null) 194 | _clientCertValidationCallback = defaultValidateClientCertificate; 195 | 196 | return _clientCertValidationCallback; 197 | } 198 | 199 | set 200 | { 201 | _clientCertValidationCallback = value; 202 | } 203 | } 204 | 205 | /// 206 | /// Gets or sets the protocols used for authentication. 207 | /// 208 | /// 209 | /// 210 | /// The enum values that represent 211 | /// the protocols used for authentication. 212 | /// 213 | /// 214 | /// The default value is . 215 | /// 216 | /// 217 | public SslProtocols EnabledSslProtocols 218 | { 219 | get 220 | { 221 | return _enabledSslProtocols; 222 | } 223 | 224 | set 225 | { 226 | _enabledSslProtocols = value; 227 | } 228 | } 229 | 230 | /// 231 | /// Gets or sets the certificate used to authenticate the server. 232 | /// 233 | /// 234 | /// 235 | /// A or 236 | /// if not specified. 237 | /// 238 | /// 239 | /// That instance represents an X.509 certificate. 240 | /// 241 | /// 242 | public X509Certificate2 ServerCertificate 243 | { 244 | get 245 | { 246 | return _serverCert; 247 | } 248 | 249 | set 250 | { 251 | _serverCert = value; 252 | } 253 | } 254 | 255 | #endregion 256 | 257 | #region Private Methods 258 | 259 | private static bool defaultValidateClientCertificate ( 260 | object sender, 261 | X509Certificate certificate, 262 | X509Chain chain, 263 | SslPolicyErrors sslPolicyErrors 264 | ) 265 | { 266 | return true; 267 | } 268 | 269 | #endregion 270 | } 271 | } 272 | #endif -------------------------------------------------------------------------------- /Net/WebEventCodes.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.Web.Management.WebEventFormatter.cs 3 | // 4 | // Authors: 5 | // Marek Habersack 6 | // 7 | // Copyright (C) 2007 Novell, Inc (http://www.novell.com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | // 29 | 30 | #if NET_2_0 31 | #if SSHARP 32 | namespace SSMono.Web.Management 33 | #else 34 | namespace System.Web.Management 35 | #endif 36 | { 37 | public sealed class WebEventCodes 38 | { 39 | public const int InvalidEventCode = -1; 40 | 41 | public const int UndefinedEventCode = 0; 42 | public const int UndefinedEventDetailCode = 0; 43 | 44 | public const int ApplicationCodeBase = 0x003E8; 45 | public const int ApplicationStart = ApplicationCodeBase + 0x01; 46 | public const int ApplicationShutdown = ApplicationCodeBase + 0x02; 47 | public const int ApplicationCompilationStart = ApplicationCodeBase + 0x03; 48 | public const int ApplicationCompilationEnd = ApplicationCodeBase + 0x04; 49 | public const int ApplicationHeartbeat = ApplicationCodeBase + 0x05; 50 | 51 | public const int RequestCodeBase = 0x007D0; 52 | public const int RequestTransactionComplete = RequestCodeBase + 0x01; 53 | public const int RequestTransactionAbort = RequestCodeBase + 0x02; 54 | 55 | public const int ErrorCodeBase = 0x00BB8; 56 | public const int RuntimeErrorRequestAbort = ErrorCodeBase + 0x01; 57 | public const int RuntimeErrorViewStateFailure = ErrorCodeBase + 0x02; 58 | public const int RuntimeErrorValidationFailure = ErrorCodeBase + 0x03; 59 | public const int RuntimeErrorPostTooLarge = ErrorCodeBase + 0x04; 60 | public const int RuntimeErrorUnhandledException = ErrorCodeBase + 0x05; 61 | public const int WebErrorParserError = ErrorCodeBase + 0x06; 62 | public const int WebErrorCompilationError = ErrorCodeBase + 0x07; 63 | public const int WebErrorConfigurationError = ErrorCodeBase + 0x08; 64 | public const int WebErrorOtherError = ErrorCodeBase + 0x09; 65 | public const int WebErrorPropertyDeserializationError = ErrorCodeBase + 0x0A; 66 | public const int WebErrorObjectStateFormatterDeserializationError = ErrorCodeBase + 0x0B; 67 | 68 | public const int AuditCodeBase = 0x00FA0; 69 | public const int AuditFormsAuthenticationSuccess = AuditCodeBase + 0x01; 70 | public const int AuditMembershipAuthenticationSuccess = AuditCodeBase + 0x02; 71 | public const int AuditUrlAuthorizationSuccess = AuditCodeBase + 0x03; 72 | public const int AuditFileAuthorizationSuccess = AuditCodeBase + 0x04; 73 | public const int AuditFormsAuthenticationFailure = AuditCodeBase + 0x05; 74 | public const int AuditMembershipAuthenticationFailure = AuditCodeBase + 0x06; 75 | public const int AuditUrlAuthorizationFailure = AuditCodeBase + 0x07; 76 | public const int AuditFileAuthorizationFailure = AuditCodeBase + 0x08; 77 | public const int AuditInvalidViewStateFailure = AuditCodeBase + 0x09; 78 | public const int AuditUnhandledSecurityException = AuditCodeBase + 0x0A; 79 | public const int AuditUnhandledAccessException = AuditCodeBase + 0x0B; 80 | 81 | public const int MiscCodeBase = 0x01770; 82 | public const int WebEventProviderInformation = MiscCodeBase + 0x01; 83 | 84 | public const int ApplicationDetailCodeBase = 0x0C350; 85 | public const int ApplicationShutdownUnknown = ApplicationDetailCodeBase + 0x01; 86 | public const int ApplicationShutdownHostingEnvironment = ApplicationDetailCodeBase + 0x02; 87 | public const int ApplicationShutdownChangeInGlobalAsax = ApplicationDetailCodeBase + 0x03; 88 | public const int ApplicationShutdownConfigurationChange = ApplicationDetailCodeBase + 0x04; 89 | public const int ApplicationShutdownUnloadAppDomainCalled = ApplicationDetailCodeBase + 0x05; 90 | public const int ApplicationShutdownChangeInSecurityPolicyFile = ApplicationDetailCodeBase + 0x06; 91 | public const int ApplicationShutdownBinDirChangeOrDirectoryRename = ApplicationDetailCodeBase + 0x07; 92 | public const int ApplicationShutdownBrowsersDirChangeOrDirectoryRename = ApplicationDetailCodeBase + 0x08; 93 | public const int ApplicationShutdownCodeDirChangeOrDirectoryRename = ApplicationDetailCodeBase + 0x09; 94 | public const int ApplicationShutdownResourcesDirChangeOrDirectoryRename = ApplicationDetailCodeBase + 0x0A; 95 | public const int ApplicationShutdownIdleTimeout = ApplicationDetailCodeBase + 0x0B; 96 | public const int ApplicationShutdownPhysicalApplicationPathChanged = ApplicationDetailCodeBase + 0x0C; 97 | public const int ApplicationShutdownHttpRuntimeClose = ApplicationDetailCodeBase + 0x0D; 98 | public const int ApplicationShutdownInitializationError = ApplicationDetailCodeBase + 0x0E; 99 | public const int ApplicationShutdownMaxRecompilationsReached = ApplicationDetailCodeBase + 0x0F; 100 | public const int StateServerConnectionError = ApplicationDetailCodeBase + 0x10; 101 | 102 | public const int AuditDetailCodeBase = 0x0C418; 103 | public const int InvalidTicketFailure = AuditDetailCodeBase + 0x01; 104 | public const int ExpiredTicketFailure = AuditDetailCodeBase + 0x02; 105 | public const int InvalidViewStateMac = AuditDetailCodeBase + 0x03; 106 | public const int InvalidViewState = AuditDetailCodeBase + 0x04; 107 | 108 | public const int WebEventDetailCodeBase = 0x0C47C; 109 | public const int SqlProviderEventsDropped = WebEventDetailCodeBase + 0x01; 110 | 111 | public const int WebExtendedBase = 0x186A0; 112 | } 113 | } 114 | #endif -------------------------------------------------------------------------------- /Net/WebException.cs: -------------------------------------------------------------------------------- 1 | // 2 | // System.Net.WebException.cs 3 | // 4 | // Author: 5 | // Lawrence Pit (loz@cable.a2000.nl) 6 | // 7 | 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining 10 | // a copy of this software and associated documentation files (the 11 | // "Software"), to deal in the Software without restriction, including 12 | // without limitation the rights to use, copy, modify, merge, publish, 13 | // distribute, sublicense, and/or sell copies of the Software, and to 14 | // permit persons to whom the Software is furnished to do so, subject to 15 | // the following conditions: 16 | // 17 | // The above copyright notice and this permission notice shall be 18 | // included in all copies or substantial portions of the Software. 19 | // 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 22 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 24 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 25 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 26 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | using System; 30 | #if !NETCF 31 | using System.Runtime.Serialization; 32 | #endif 33 | 34 | #if SSHARP 35 | namespace SSMono.Net 36 | #else 37 | namespace System.Net 38 | #endif 39 | { 40 | [Serializable] 41 | public class WebException : InvalidOperationException 42 | #if !NETCF 43 | , ISerializable 44 | #endif 45 | { 46 | private object response; 47 | private WebExceptionStatus status = WebExceptionStatus.UnknownError; 48 | 49 | // Constructors 50 | 51 | public WebException () 52 | : base () 53 | { 54 | } 55 | 56 | public WebException (string message) 57 | : base (message) 58 | { 59 | } 60 | 61 | #if !NETCF 62 | protected WebException (SerializationInfo serializationInfo, StreamingContext streamingContext) 63 | : base (serializationInfo, streamingContext) 64 | { 65 | } 66 | #endif 67 | 68 | public WebException (string message, Exception innerException) 69 | : base (message, innerException) 70 | { 71 | } 72 | 73 | public WebException (string message, WebExceptionStatus status) 74 | : base (message) 75 | { 76 | this.status = status; 77 | } 78 | 79 | internal WebException (string message, Exception innerException, WebExceptionStatus status) 80 | : base (message, innerException) 81 | { 82 | this.status = status; 83 | } 84 | 85 | public WebException (string message, 86 | Exception innerException, 87 | WebExceptionStatus status, 88 | object response) 89 | : base (message, innerException) 90 | { 91 | this.status = status; 92 | this.response = response; 93 | } 94 | 95 | // Properties 96 | 97 | public object Response 98 | { 99 | get { return this.response; } 100 | } 101 | 102 | public WebExceptionStatus Status 103 | { 104 | get { return this.status; } 105 | } 106 | 107 | #if !NETCF 108 | // Methods 109 | void ISerializable.GetObjectData (SerializationInfo info, StreamingContext context) 110 | { 111 | base.GetObjectData (info, context); 112 | } 113 | 114 | public override void GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext) 115 | { 116 | base.GetObjectData (serializationInfo, 117 | streamingContext); 118 | } 119 | #endif 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /Net/WebExceptionStatus.cs: -------------------------------------------------------------------------------- 1 | // System.Net.WebExceptionStatus.cs 2 | // 3 | // Author: 4 | // Andreas Nahr (ClassDevelopment@A-SoftTech.com) 5 | // originally autogenerated by Sergey Chaban (serge@wildwestsoftware.com) 6 | // 7 | // (C) 2001 Ximian, Inc. http://www.ximian.com 8 | 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining 11 | // a copy of this software and associated documentation files (the 12 | // "Software"), to deal in the Software without restriction, including 13 | // without limitation the rights to use, copy, modify, merge, publish, 14 | // distribute, sublicense, and/or sell copies of the Software, and to 15 | // permit persons to whom the Software is furnished to do so, subject to 16 | // the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be 19 | // included in all copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 25 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 26 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | // 29 | 30 | #if SSHARP 31 | namespace SSMono.Net 32 | #else 33 | namespace System.Net 34 | #endif 35 | { 36 | public 37 | enum WebExceptionStatus 38 | { 39 | Success = 0, 40 | NameResolutionFailure = 1, 41 | ConnectFailure = 2, 42 | ReceiveFailure = 3, 43 | SendFailure = 4, 44 | PipelineFailure = 5, 45 | RequestCanceled = 6, 46 | ProtocolError = 7, 47 | ConnectionClosed = 8, 48 | TrustFailure = 9, 49 | SecureChannelFailure = 10, 50 | ServerProtocolViolation = 11, 51 | KeepAliveFailure = 12, 52 | Pending = 13, 53 | Timeout = 14, 54 | ProxyNameResolutionFailure = 15, 55 | 56 | 57 | UnknownError = 16, 58 | MessageLengthLimitExceeded = 17, 59 | 60 | CacheEntryNotFound = 18, 61 | RequestProhibitedByCachePolicy = 19, 62 | RequestProhibitedByProxy = 20, 63 | 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Net/WebHeaderCollection.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/WebHeaderCollection.cs -------------------------------------------------------------------------------- /Net/WebSockets/HttpListenerWebSocketContext.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/WebSockets/HttpListenerWebSocketContext.cs -------------------------------------------------------------------------------- /Net/WebSockets/TcpListenerWebSocketContext.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/WebSockets/TcpListenerWebSocketContext.cs -------------------------------------------------------------------------------- /Net/WebSockets/WebSocketContext.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Net/WebSockets/WebSocketContext.cs -------------------------------------------------------------------------------- /Opcode.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Opcode.cs -------------------------------------------------------------------------------- /PayloadData.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/PayloadData.cs -------------------------------------------------------------------------------- /Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Properties/AssemblyInfo.cs -------------------------------------------------------------------------------- /Rsv.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Rsv.cs -------------------------------------------------------------------------------- /SSharpWebSocketLibrary.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | Release 4 | AnyCPU 5 | 9.0.30729 6 | 2.0 7 | {77241A0E-0292-4C5F-97A7-A61FD0F7B315} 8 | Library 9 | Properties 10 | SSharpWebSocketLibrary 11 | SSharpWebSocketLibrary 12 | {0B4745B0-194B-4BB6-8E21-E9057CA92300};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 13 | WindowsCE 14 | E2BECB1F-8C8C-41ba-B736-9BE7D946A398 15 | 5.0 16 | SmartDeviceProject1 17 | v3.5 18 | Windows CE 19 | 20 | 21 | SAK 22 | SAK 23 | SAK 24 | SAK 25 | 26 | 27 | .allowedReferenceRelatedFileExtensions 28 | true 29 | full 30 | false 31 | bin\Debug\ 32 | DEBUG;TRACE;NETCF;SSHARP;NET_2_0;SSL;BUFFERED 33 | prompt 34 | 4 35 | 512 36 | true 37 | true 38 | off 39 | false 40 | 41 | 42 | .allowedReferenceRelatedFileExtensions 43 | none 44 | true 45 | bin\Release\ 46 | prompt 47 | 4 48 | 512 49 | true 50 | true 51 | off 52 | NETCF;SSHARP;NET_2_0;SSL; BUFFERED 53 | false 54 | 55 | 56 | 57 | 58 | False 59 | ..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCryptographyInterface.dll 60 | 61 | 62 | False 63 | C:\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll 64 | False 65 | 66 | 67 | False 68 | C:\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll 69 | False 70 | 71 | 72 | False 73 | C:\ProgramData\Crestron\SDK\SimplSharpPro.exe 74 | False 75 | 76 | 77 | False 78 | ..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpReflectionInterface.dll 79 | 80 | 81 | False 82 | ..\..\SSharpCrestronExtensionsLibrary\SSharpCrestronExtensionsLibrary\bin\Release\SSharpCrestronExtensionsLibrary.dll 83 | 84 | 85 | False 86 | ..\..\SSharpReflectionExtensionsLibrary\SSharpReflectionExtensionsLibrary\bin\Release\SSharpReflectionExtensionsLibrary.dll 87 | 88 | 89 | False 90 | ..\..\SSMonoCryptographyLibrary\SSMonoCryptographyLibrary\bin\Release\SSMonoCryptographyLibrary.dll 91 | 92 | 93 | False 94 | ..\..\SSMonoIOLibrary\SSMonoIOLibrary\bin\Release\SSMonoIOLibrary.dll 95 | 96 | 97 | False 98 | ..\..\SSMonoNetLibrary\SSMonoNetLibrary\bin\Release\SSMonoNetLibrary.dll 99 | 100 | 101 | False 102 | ..\..\SSMonoThreadingLibrary\SSMonoProThreadingLibrary\bin\Release\SSMonoProThreadingLibrary.dll 103 | 104 | 105 | False 106 | ..\..\SSMonoSslStreamLibrary\SSMonoSslStreamLibrary\bin\Release\SSMonoSslStreamLibrary.dll 107 | 108 | 109 | False 110 | ..\..\SSMonoWebLibrary\SSMonoWebLibrary\bin\Release\SSMonoWebLibrary.dll 111 | 112 | 113 | False 114 | ..\..\SSMonoX509CertificatesLibrary\SSMonoX509CertificatesLibrary\bin\Release\SSMonoX509CertificatesLibrary.dll 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | Code 124 | 125 | 126 | 127 | Code 128 | 129 | 130 | Code 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | rem S# Pro preparation will execute after these operations 222 | 223 | -------------------------------------------------------------------------------- /Server/HttpRequestCancelEventArgs.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Server/HttpRequestCancelEventArgs.cs -------------------------------------------------------------------------------- /Server/HttpRequestEventArgs.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Server/HttpRequestEventArgs.cs -------------------------------------------------------------------------------- /Server/HttpResolveWebSocketServiceHostEventArgs.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Server/HttpResolveWebSocketServiceHostEventArgs.cs -------------------------------------------------------------------------------- /Server/HttpServer.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Server/HttpServer.cs -------------------------------------------------------------------------------- /Server/IWebSocketSession.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Server/IWebSocketSession.cs -------------------------------------------------------------------------------- /Server/ServerState.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Server/ServerState.cs -------------------------------------------------------------------------------- /Server/WebSocketBehavior.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Server/WebSocketBehavior.cs -------------------------------------------------------------------------------- /Server/WebSocketServer.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Server/WebSocketServer.cs -------------------------------------------------------------------------------- /Server/WebSocketServiceHost.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Server/WebSocketServiceHost.cs -------------------------------------------------------------------------------- /Server/WebSocketServiceHost`1.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Server/WebSocketServiceHost`1.cs -------------------------------------------------------------------------------- /Server/WebSocketServiceManager.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Server/WebSocketServiceManager.cs -------------------------------------------------------------------------------- /Server/WebSocketSessionManager.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/Server/WebSocketSessionManager.cs -------------------------------------------------------------------------------- /SocketFlags.cs: -------------------------------------------------------------------------------- 1 | // SocketFlags.cs 2 | // 3 | // This code was automatically generated from 4 | // ECMA CLI XML Library Specification. 5 | // Generator: libgen.xsl [1.0; (C) Sergey Chaban (serge@wildwestsoftware.com)] 6 | // Created: Wed, 5 Sep 2001 06:32:49 UTC 7 | // Source file: AllTypes.xml 8 | // URL: http://msdn.microsoft.com/net/ecma/AllTypes.xml 9 | // 10 | // (C) 2001 Ximian, Inc. http://www.ximian.com 11 | 12 | // 13 | // Permission is hereby granted, free of charge, to any person obtaining 14 | // a copy of this software and associated documentation files (the 15 | // "Software"), to deal in the Software without restriction, including 16 | // without limitation the rights to use, copy, modify, merge, publish, 17 | // distribute, sublicense, and/or sell copies of the Software, and to 18 | // permit persons to whom the Software is furnished to do so, subject to 19 | // the following conditions: 20 | // 21 | // The above copyright notice and this permission notice shall be 22 | // included in all copies or substantial portions of the Software. 23 | // 24 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 25 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 26 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 27 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 28 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 29 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 30 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 31 | // 32 | 33 | using System; 34 | #if SSHARP 35 | namespace Crestron.SimplSharp.CrestronSockets 36 | #else 37 | namespace System.Net.Sockets 38 | #endif 39 | { 40 | [Flags] 41 | public enum SocketFlags 42 | { 43 | None = 0x00000000, 44 | OutOfBand = 0x00000001, 45 | Peek = 0x00000002, 46 | DontRoute = 0x00000004, 47 | MaxIOVectorLength = 0x00000010, 48 | Truncated = 0x00000100, 49 | ControlDataTruncated = 0x00000200, 50 | Broadcast = 0x00000400, 51 | Multicast = 0x00000800, 52 | Partial = 0x00008000, 53 | } // SocketFlags 54 | 55 | } // System.Net.Sockets 56 | -------------------------------------------------------------------------------- /WebSocket.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/WebSocket.cs -------------------------------------------------------------------------------- /WebSocketException.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/WebSocketException.cs -------------------------------------------------------------------------------- /WebSocketFrame.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/WebSocketFrame.cs -------------------------------------------------------------------------------- /WebSocketState.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oznetmaster/SSharpWebSocketLibrary/56505a443375412c89e85a6fa28342f6aa272ee5/WebSocketState.cs --------------------------------------------------------------------------------