Browse Source

Issue #12 fixed

master
Nikita 13 years ago
parent
commit
13c406572d
  1. 3
      src/main/java/com/corundumstudio/socketio/AuthorizeHandler.java
  2. 18
      src/main/java/com/corundumstudio/socketio/Configuration.java

3
src/main/java/com/corundumstudio/socketio/AuthorizeHandler.java

@ -76,7 +76,8 @@ public class AuthorizeHandler extends SimpleChannelUpstreamHandler implements Di
HttpRequest req = (HttpRequest) msg;
Channel channel = ctx.getChannel();
QueryStringDecoder queryDecoder = new QueryStringDecoder(req.getUri());
if (!queryDecoder.getPath().startsWith(connectPath)) {
if (!configuration.isAllowCustomRequests()
&& !queryDecoder.getPath().startsWith(connectPath)) {
HttpResponse res = new DefaultHttpResponse(HTTP_1_1, HttpResponseStatus.BAD_REQUEST);
ChannelFuture f = channel.write(res);
f.addListener(ChannelFutureListener.CLOSE);

18
src/main/java/com/corundumstudio/socketio/Configuration.java

@ -27,6 +27,7 @@ public class Configuration {
private Executor bossExecutor = Executors.newCachedThreadPool();
private Executor workerExecutor = Executors.newCachedThreadPool();
private boolean allowCustomRequests = false;
private int heartbeatThreadPoolSize = Runtime.getRuntime().availableProcessors() * 2;
private int heartbeatTimeout = 60;
private int heartbeatInterval = 25;
@ -57,6 +58,8 @@ public class Configuration {
setObjectMapper(conf.getObjectMapper());
setPort(conf.getPort());
setWorkerExecutor(conf.getWorkerExecutor());
setContext(conf.getContext());
setAllowCustomRequests(conf.isAllowCustomRequests());
}
public ObjectMapper getObjectMapper() {
@ -157,4 +160,19 @@ public class Configuration {
this.context = context;
}
public boolean isAllowCustomRequests() {
return allowCustomRequests;
}
/**
* Allow to service custom requests differs from socket.io protocol.
* In this case it's necessary to add own handler which handle them
* to avoid hang connections.
*
* @param allowCustomRequests - true to allow
*/
public void setAllowCustomRequests(boolean allowCustomRequests) {
this.allowCustomRequests = allowCustomRequests;
}
}
Loading…
Cancel
Save