diff --git a/Example/Example.pidb b/Example/Example.pidb index e3d7fd5b..9d9da458 100644 Binary files a/Example/Example.pidb and b/Example/Example.pidb differ diff --git a/Example/Program.cs b/Example/Program.cs index 418b99ef..b555e452 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -111,6 +111,7 @@ namespace Example "notification-message-im"); }; + //ws.Origin = "http://echo.websocket.org"; //ws.SetCookie(new Cookie("nobita", "\"idiot, gunfighter\"")); //ws.SetCookie(new Cookie("dora", "tanuki")); ws.Connect(); diff --git a/Example/bin/Debug_Ubuntu/example.exe b/Example/bin/Debug_Ubuntu/example.exe index 434ffc53..9b6571cf 100755 Binary files a/Example/bin/Debug_Ubuntu/example.exe and b/Example/bin/Debug_Ubuntu/example.exe differ diff --git a/Example/bin/Debug_Ubuntu/example.exe.mdb b/Example/bin/Debug_Ubuntu/example.exe.mdb index 60c2179d..38e8176b 100644 Binary files a/Example/bin/Debug_Ubuntu/example.exe.mdb and b/Example/bin/Debug_Ubuntu/example.exe.mdb differ diff --git a/Example/bin/Debug_Ubuntu/websocket-sharp.dll b/Example/bin/Debug_Ubuntu/websocket-sharp.dll index 5eb73187..7bdd9999 100755 Binary files a/Example/bin/Debug_Ubuntu/websocket-sharp.dll and b/Example/bin/Debug_Ubuntu/websocket-sharp.dll differ diff --git a/Example/bin/Debug_Ubuntu/websocket-sharp.dll.mdb b/Example/bin/Debug_Ubuntu/websocket-sharp.dll.mdb index 0148324e..804869eb 100644 Binary files a/Example/bin/Debug_Ubuntu/websocket-sharp.dll.mdb and b/Example/bin/Debug_Ubuntu/websocket-sharp.dll.mdb differ diff --git a/Example1/bin/Debug_Ubuntu/example1.exe b/Example1/bin/Debug_Ubuntu/example1.exe index 6be232dc..2aba5157 100755 Binary files a/Example1/bin/Debug_Ubuntu/example1.exe and b/Example1/bin/Debug_Ubuntu/example1.exe differ diff --git a/Example1/bin/Debug_Ubuntu/example1.exe.mdb b/Example1/bin/Debug_Ubuntu/example1.exe.mdb index c78addd8..09b14c1a 100644 Binary files a/Example1/bin/Debug_Ubuntu/example1.exe.mdb and b/Example1/bin/Debug_Ubuntu/example1.exe.mdb differ diff --git a/Example1/bin/Debug_Ubuntu/websocket-sharp.dll b/Example1/bin/Debug_Ubuntu/websocket-sharp.dll index 5eb73187..7bdd9999 100755 Binary files a/Example1/bin/Debug_Ubuntu/websocket-sharp.dll and b/Example1/bin/Debug_Ubuntu/websocket-sharp.dll differ diff --git a/Example1/bin/Debug_Ubuntu/websocket-sharp.dll.mdb b/Example1/bin/Debug_Ubuntu/websocket-sharp.dll.mdb index 0148324e..804869eb 100644 Binary files a/Example1/bin/Debug_Ubuntu/websocket-sharp.dll.mdb and b/Example1/bin/Debug_Ubuntu/websocket-sharp.dll.mdb differ diff --git a/Example2/bin/Debug_Ubuntu/example2.exe b/Example2/bin/Debug_Ubuntu/example2.exe index 4a998740..a025f78b 100755 Binary files a/Example2/bin/Debug_Ubuntu/example2.exe and b/Example2/bin/Debug_Ubuntu/example2.exe differ diff --git a/Example2/bin/Debug_Ubuntu/example2.exe.mdb b/Example2/bin/Debug_Ubuntu/example2.exe.mdb index 2bb408de..299127e5 100644 Binary files a/Example2/bin/Debug_Ubuntu/example2.exe.mdb and b/Example2/bin/Debug_Ubuntu/example2.exe.mdb differ diff --git a/Example2/bin/Debug_Ubuntu/websocket-sharp.dll b/Example2/bin/Debug_Ubuntu/websocket-sharp.dll index 5eb73187..7bdd9999 100755 Binary files a/Example2/bin/Debug_Ubuntu/websocket-sharp.dll and b/Example2/bin/Debug_Ubuntu/websocket-sharp.dll differ diff --git a/Example2/bin/Debug_Ubuntu/websocket-sharp.dll.mdb b/Example2/bin/Debug_Ubuntu/websocket-sharp.dll.mdb index 0148324e..804869eb 100644 Binary files a/Example2/bin/Debug_Ubuntu/websocket-sharp.dll.mdb and b/Example2/bin/Debug_Ubuntu/websocket-sharp.dll.mdb differ diff --git a/Example3/bin/Debug_Ubuntu/Example3.exe b/Example3/bin/Debug_Ubuntu/Example3.exe index e72bc2f0..6309b6ec 100755 Binary files a/Example3/bin/Debug_Ubuntu/Example3.exe and b/Example3/bin/Debug_Ubuntu/Example3.exe differ diff --git a/Example3/bin/Debug_Ubuntu/Example3.exe.mdb b/Example3/bin/Debug_Ubuntu/Example3.exe.mdb index 2ca9a352..99d939e5 100644 Binary files a/Example3/bin/Debug_Ubuntu/Example3.exe.mdb and b/Example3/bin/Debug_Ubuntu/Example3.exe.mdb differ diff --git a/Example3/bin/Debug_Ubuntu/websocket-sharp.dll b/Example3/bin/Debug_Ubuntu/websocket-sharp.dll index 5eb73187..7bdd9999 100755 Binary files a/Example3/bin/Debug_Ubuntu/websocket-sharp.dll and b/Example3/bin/Debug_Ubuntu/websocket-sharp.dll differ diff --git a/Example3/bin/Debug_Ubuntu/websocket-sharp.dll.mdb b/Example3/bin/Debug_Ubuntu/websocket-sharp.dll.mdb index 0148324e..804869eb 100644 Binary files a/Example3/bin/Debug_Ubuntu/websocket-sharp.dll.mdb and b/Example3/bin/Debug_Ubuntu/websocket-sharp.dll.mdb differ diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 01162a7f..a4c718b1 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -50,7 +50,8 @@ namespace WebSocketSharp { /// Implements the WebSocket interface. /// /// - /// The WebSocket class provides methods and properties for two-way communication using the WebSocket protocol (RFC 6455). + /// The WebSocket class provides a set of methods and properties for two-way communication + /// using the WebSocket protocol (RFC 6455). /// public class WebSocket : IDisposable { @@ -73,6 +74,7 @@ namespace WebSocketSharp { private AutoResetEvent _exitReceiving; private Object _forClose; private Object _forSend; + private string _origin; private string _protocol; private string _protocols; private volatile WsState _readyState; @@ -92,6 +94,7 @@ namespace WebSocketSharp { _extensions = String.Empty; _forClose = new Object(); _forSend = new Object(); + _origin = String.Empty; _protocol = String.Empty; _readyState = WsState.CONNECTING; } @@ -123,11 +126,8 @@ namespace WebSocketSharp { /// /// Initializes a new instance of the class with the specified WebSocket URL and subprotocols. /// - /// - /// - /// /// - /// A that contains a WebSocket URL. + /// A that contains a WebSocket URL to connect. /// /// /// An array of that contains the WebSocket subprotocols if any. @@ -166,7 +166,7 @@ namespace WebSocketSharp { /// establishes a WebSocket connection. /// /// - /// A that contains a WebSocket URL. + /// A that contains a WebSocket URL to connect. /// /// /// An event handler. @@ -241,7 +241,8 @@ namespace WebSocketSharp { /// Gets the extensions selected by the server. /// /// - /// A that contains the extensions if any. By default, String.Empty. (Currently this will only ever be the String.Empty.) + /// A that contains the extensions if any. The default is . + /// (Currently this will only ever be the .) /// public string Extensions { get { @@ -276,6 +277,47 @@ namespace WebSocketSharp { } } + /// + /// Gets or sets the value of the Origin header used in the WebSocket opening handshake. + /// + /// + /// A instance does not send the Origin header in the WebSocket opening handshake + /// if the value of this property is . + /// + /// + /// + /// A that contains the value of the HTTP Origin header to send. + /// The default is . + /// + /// + /// The value of the Origin header has the following syntax: <scheme>://<host>[:<port>] + /// + /// + public string Origin { + get { + return _origin; + } + + set { + var origin = value.ToUri(); + var msg = _readyState == WsState.OPEN + ? "The WebSocket connection has been established already." + : !origin.IsNull() && (!origin.IsAbsoluteUri || origin.Segments.Length > 1) + ? "The syntax of value must be '://[:]'." + : String.Empty; + + if (!msg.IsEmpty()) + { + onError(msg); + return; + } + + _origin = origin.IsNull() + ? String.Empty + : value.TrimEnd('/'); + } + } + /// /// Gets the subprotocol selected by the server. /// @@ -517,6 +559,8 @@ namespace WebSocketSharp { var req = new RequestHandshake(path); req.AddHeader("Host", host); + if (!_origin.IsEmpty()) + req.AddHeader("Origin", _origin); req.AddHeader("Sec-WebSocket-Key", _base64key); if (!_protocols.IsNullOrEmpty()) req.AddHeader("Sec-WebSocket-Protocol", _protocols); diff --git a/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll b/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll index 5eb73187..7bdd9999 100755 Binary files a/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll and b/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll differ diff --git a/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll.mdb b/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll.mdb index 0148324e..804869eb 100644 Binary files a/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll.mdb and b/websocket-sharp/bin/Debug_Ubuntu/websocket-sharp.dll.mdb differ diff --git a/websocket-sharp/bin/Release_Ubuntu/websocket-sharp.dll b/websocket-sharp/bin/Release_Ubuntu/websocket-sharp.dll index f663f380..46f5cdb5 100755 Binary files a/websocket-sharp/bin/Release_Ubuntu/websocket-sharp.dll and b/websocket-sharp/bin/Release_Ubuntu/websocket-sharp.dll differ diff --git a/websocket-sharp/bin/Release_Ubuntu/websocket-sharp.xml b/websocket-sharp/bin/Release_Ubuntu/websocket-sharp.xml index 68134321..fd4e964f 100644 --- a/websocket-sharp/bin/Release_Ubuntu/websocket-sharp.xml +++ b/websocket-sharp/bin/Release_Ubuntu/websocket-sharp.xml @@ -867,17 +867,16 @@ Implements the WebSocket interface. - The WebSocket class provides methods and properties for two-way communication using the WebSocket protocol (RFC 6455). + The WebSocket class provides a set of methods and properties for two-way communication + using the WebSocket protocol (RFC 6455). Initializes a new instance of the class with the specified WebSocket URL and subprotocols. - - - A that contains a WebSocket URL. + A that contains a WebSocket URL to connect. An array of that contains the WebSocket subprotocols if any. @@ -899,7 +898,7 @@ establishes a WebSocket connection. - A that contains a WebSocket URL. + A that contains a WebSocket URL to connect. An event handler. @@ -957,7 +956,8 @@ Gets the extensions selected by the server. - A that contains the extensions if any. By default, String.Empty. (Currently this will only ever be the String.Empty.) + A that contains the extensions if any. The default is . + (Currently this will only ever be the .) @@ -976,6 +976,23 @@ true if the connection is secure; otherwise, false. + + + Gets or sets the value of the Origin header used in the WebSocket opening handshake. + + + A instance does not send the Origin header in the WebSocket opening handshake + if the value of this property is . + + + + A that contains the value of the HTTP Origin header to send. + The default is . + + + The value of the Origin header has the following syntax: <scheme>://<host>[:<port>] + + Gets the subprotocol selected by the server. diff --git a/websocket-sharp/doc/html/WebSocketSharp/WebSocket.html b/websocket-sharp/doc/html/WebSocketSharp/WebSocket.html index 1f4410ae..b45d0748 100644 --- a/websocket-sharp/doc/html/WebSocketSharp/WebSocket.html +++ b/websocket-sharp/doc/html/WebSocketSharp/WebSocket.html @@ -216,7 +216,8 @@

Remarks

- The WebSocket class provides methods and properties for two-way communication using the WebSocket protocol (RFC 6455). + The WebSocket class provides a set of methods and properties for two-way communication + using the WebSocket protocol (RFC 6455).

Requirements

@@ -323,6 +324,23 @@ bool . Gets a value indicating whether a connection is secure. + + + + +
+
+ + + + Origin + + + + + string + . + Gets or sets the value of the Origin header used in the WebSocket opening handshake. @@ -685,7 +703,7 @@ url
- A string that contains a WebSocket URL. + A string that contains a WebSocket URL to connect.
protocols @@ -743,7 +761,7 @@ url
- A string that contains a WebSocket URL. + A string that contains a WebSocket URL to connect.
onOpen @@ -1016,7 +1034,8 @@
public string Extensions { get; }

Value

- A string that contains the extensions if any. By default, String.Empty. (Currently this will only ever be the String.Empty.) + A string that contains the extensions if any. The default is string.Empty. + (Currently this will only ever be the string.Empty.)

Remarks

@@ -1131,6 +1150,32 @@ Namespace: WebSocketSharp
Assembly: websocket-sharp (in websocket-sharp.dll)

+

Origin Property

+
+

+ Gets or sets the value of the Origin header used in the WebSocket opening handshake. +

+

Syntax

+
public string Origin { get; set; }
+

Value

+
+

+ A string that contains the value of the HTTP Origin header to send. + The default is string.Empty. +

+

+ The value of the Origin header has the following syntax: <scheme>://<host>[:<port>]

+
+

Remarks

+
+ A WebSocketSharp.WebSocket instance does not send the Origin header in the WebSocket opening handshake + if the value of this property is string.Empty. +
+

Requirements

+
+ Namespace: WebSocketSharp
Assembly: websocket-sharp (in websocket-sharp.dll)
+
+

Ping Method

diff --git a/websocket-sharp/doc/mdoc/WebSocketSharp/WebSocket.xml b/websocket-sharp/doc/mdoc/WebSocketSharp/WebSocket.xml index 102dd9e1..ac93a701 100644 --- a/websocket-sharp/doc/mdoc/WebSocketSharp/WebSocket.xml +++ b/websocket-sharp/doc/mdoc/WebSocketSharp/WebSocket.xml @@ -17,7 +17,8 @@ Implements the WebSocket interface.

- The WebSocket class provides methods and properties for two-way communication using the WebSocket protocol (RFC 6455). + The WebSocket class provides a set of methods and properties for two-way communication + using the WebSocket protocol (RFC 6455). @@ -37,7 +38,7 @@ - A that contains a WebSocket URL. + A that contains a WebSocket URL to connect. An array of that contains the WebSocket subprotocols if any. @@ -74,7 +75,7 @@ - A that contains a WebSocket URL. + A that contains a WebSocket URL to connect. An event handler. @@ -282,7 +283,8 @@ Gets the extensions selected by the server. - A that contains the extensions if any. By default, String.Empty. (Currently this will only ever be the String.Empty.) + A that contains the extensions if any. The default is . + (Currently this will only ever be the .) To be added. @@ -377,6 +379,31 @@ To be added.
+ + + + Property + + System.String + + + + Gets or sets the value of the Origin header used in the WebSocket opening handshake. + + + + A that contains the value of the HTTP Origin header to send. + The default is . + + + The value of the Origin header has the following syntax: <scheme>://<host>[:<port>] + + + A instance does not send the Origin header in the WebSocket opening handshake + if the value of this property is . + + + diff --git a/websocket-sharp/doc/mdoc/index.xml b/websocket-sharp/doc/mdoc/index.xml index a32518ab..f43406b0 100644 --- a/websocket-sharp/doc/mdoc/index.xml +++ b/websocket-sharp/doc/mdoc/index.xml @@ -1,6 +1,6 @@ - + [00 24 00 00 04 80 00 00 94 00 00 00 06 02 00 00 00 24 00 00 52 53 41 31 00 04 00 00 11 00 00 00 29 17 fb 89 fe c3 91 f7 2b cb 8b e2 61 d2 3f 05 93 6d 65 a8 9e 63 72 a6 f5 d5 2c f2 9d 20 fa 0b c0 70 6a f6 88 7e 8b 90 3f 39 f5 76 c8 48 e0 bb 7b b2 7b ed d3 10 a7 1a 0f 70 98 0f 7f f4 4b 53 09 d2 a5 ef 36 c3 56 b4 aa f0 91 72 63 25 07 89 e0 93 3e 3f 2e f2 b9 73 0e 12 15 5d 43 56 c3 f4 70 a5 89 fe f7 f6 ac 3e 77 c2 d8 d0 84 91 f4 0c d1 f3 8e dc c3 c3 b8 38 3d 0c bf 17 de 20 78 c1 ] diff --git a/websocket-sharp/websocket-sharp.pidb b/websocket-sharp/websocket-sharp.pidb index 9826ad53..f40c51f8 100644 Binary files a/websocket-sharp/websocket-sharp.pidb and b/websocket-sharp/websocket-sharp.pidb differ