1、在Google官方维护的code.google.com\p\go.net\websocket包中的server.go文件中,曾经有这么一段描述:
Handler is a simple interface to a WebSocket browser client. It checks if Origin header is
valid URL by default. You might want to verify websocket.Conn.Config().Origin in the func.
If you use Server instead of Handler, you could call websocket.Origin and check the origin
in your Handshake func. So, if you want to accept non-browser client, which doesn't send
Origin header, you could use Server. that doesn't check origin in its Handshake.
这里说到,Handler是一个针对Websocket浏览器客户端的简单接口,默认情况下,Handler会检查Http请求的头文件的Origin是否是一个有效的值。最后说到,如果你想接收一个并不带有Origin字段信息的非浏览器客户端发送的websocket请求,你应该使用Server,使用Server不会在Websocket握手时对Origin进行检查。