MtGox API and websocketpp

瘦欲@ 提交于 2019-12-07 08:04:24

MtGox appears to be doing origin filtering. Browser based WebSocket connections will have an origin header sent automatically with the value of the domain that the script is being run from. As this is primarily a security measure for browsers running potentially unknown Javascript code, WebSocket++ does not send an origin header by default.

MtGox appears to work fine with any origin that I have tried as long as one is set at all. Presumably they use this to blacklist origins that they deem malicious. You can send an origin header using WebSocket++ with the following code (Fill in whatever origin seems appropriate for your application):

con->replace_header("Origin","http://www.example.com");

Run this after you request your new connection with endpoint::get_connection, but before calling endpoint::connect.

See http://en.wikipedia.org/wiki/Same-origin_policy for more details about the 'same-origin policy' security method that is being used here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!