Skip to content

Commit 068232e

Browse files
committed
[Modify] Edit it
1 parent 616674e commit 068232e

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

README.md

+11-10
Original file line numberDiff line numberDiff line change
@@ -522,13 +522,13 @@ As a WebSocket client, if you would like to send the query string in the handsha
522522
var ws = new WebSocket ("ws://example.com/?name=nobita");
523523
```
524524

525-
If you would like to send the Origin header in the handshake request, you should set the `WebSocket.Origin` property to an allowable value as the [Origin] header before calling the connect method.
525+
And if you would like to send the Origin header in the handshake request, you should set the `WebSocket.Origin` property to an allowable value as the [Origin] header before calling the connect method.
526526

527527
```csharp
528528
ws.Origin = "http://example.com";
529529
```
530530

531-
And if you would like to send the cookies in the handshake request, you should set any cookie by using the `WebSocket.SetCookie (WebSocketSharp.Net.Cookie)` method before calling the connect method.
531+
And also if you would like to send the cookies in the handshake request, you should set any cookie by using the `WebSocket.SetCookie (WebSocketSharp.Net.Cookie)` method before calling the connect method.
532532

533533
```csharp
534534
ws.SetCookie (new Cookie ("name", "nobita"));
@@ -551,30 +551,31 @@ public class Chat : WebSocketBehavior
551551
}
552552
```
553553

554-
If you would like to get the value of the Origin header included in a handshake request, you should access the `WebSocketBehavior.Context.Origin` property.
555-
556-
If you would like to get the cookies included in a handshake request, you should access the `WebSocketBehavior.Context.CookieCollection` property.
557-
558554
And if you would like to validate the Origin header, cookies, or both, you should set each validation for it with your `WebSocketBehavior`, for example, by using the `WebSocketServer.AddWebSocketService<TBehavior> (string, Action<TBehavior>)` method with initializing, such as the following.
559555

560556
```csharp
561557
wssv.AddWebSocketService<Chat> (
562558
"/Chat",
563559
s => {
564-
s.OriginValidator = val => {
560+
s.OriginValidator =
561+
val => {
565562
// Check the value of the Origin header, and return true if valid.
563+
566564
Uri origin;
567565

568566
return !val.IsNullOrEmpty ()
569567
&& Uri.TryCreate (val, UriKind.Absolute, out origin)
570568
&& origin.Host == "example.com";
571569
};
572570

573-
s.CookiesValidator = (req, res) => {
574-
// Check the cookies in 'req', and set the cookies to send to
575-
// the client with 'res' if necessary.
571+
s.CookiesValidator =
572+
(req, res) => {
573+
// Check the cookies in "req", and set the cookies to send to
574+
// the client with "res" if necessary.
575+
576576
foreach (var cookie in req) {
577577
cookie.Expired = true;
578+
578579
res.Add (cookie);
579580
}
580581

0 commit comments

Comments
 (0)