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 @@