jubilee 2.1.0.rc1-java → 3.0.0.beta2-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/Gemfile +1 -1
  4. data/Gemfile.lock +2 -14
  5. data/Guardfile +24 -0
  6. data/README.md +34 -66
  7. data/Rakefile +1 -1
  8. data/examples/chatapp/Gemfile +2 -1
  9. data/examples/chatapp/Gemfile.lock +2 -2
  10. data/examples/chatapp/README.md +2 -14
  11. data/examples/chatapp/app.rb +19 -11
  12. data/examples/chatapp/public/assets/javascripts/application.js +1 -1
  13. data/examples/chatapp/public/assets/javascripts/vertxbus.js +60 -48
  14. data/examples/client/vertxbus.js +60 -48
  15. data/examples/shims_example/log/development.log +0 -0
  16. data/jars/hazelcast-3.5.2.jar +0 -0
  17. data/jars/jackson-annotations-2.6.0.jar +0 -0
  18. data/jars/jackson-core-2.6.1.jar +0 -0
  19. data/jars/jackson-databind-2.6.1.jar +0 -0
  20. data/jars/netty-buffer-4.0.33.Final.jar +0 -0
  21. data/jars/netty-codec-4.0.33.Final.jar +0 -0
  22. data/jars/netty-codec-http-4.0.33.Final.jar +0 -0
  23. data/jars/netty-common-4.0.33.Final.jar +0 -0
  24. data/jars/netty-handler-4.0.33.Final.jar +0 -0
  25. data/jars/netty-transport-4.0.33.Final.jar +0 -0
  26. data/jars/vertx-auth-common-3.2.1.jar +0 -0
  27. data/jars/vertx-core-3.2.1.jar +0 -0
  28. data/jars/vertx-hazelcast-3.2.1.jar +0 -0
  29. data/jars/vertx-lang-ruby-3.2.1.jar +0 -0
  30. data/jars/vertx-web-3.2.1.jar +0 -0
  31. data/jubilee.gemspec +40 -42
  32. data/lib/jubilee.rb +7 -2
  33. data/lib/jubilee/cli.rb +4 -4
  34. data/lib/jubilee/jubilee.jar +0 -0
  35. data/lib/jubilee/response.rb +1 -1
  36. data/lib/jubilee/version.rb +3 -3
  37. data/pom.xml +10 -94
  38. data/spec/apps/rails4/basic/Gemfile +2 -2
  39. data/spec/apps/rails4/basic/Gemfile.lock +5 -6
  40. data/src/main/java/org/jruby/jubilee/Const.java +1 -4
  41. data/src/main/java/org/jruby/jubilee/JubileeVerticle.java +41 -46
  42. data/src/main/java/org/jruby/jubilee/RackApplication.java +37 -57
  43. data/src/main/java/org/jruby/jubilee/RackEnvironment.java +38 -35
  44. data/src/main/java/org/jruby/jubilee/RackEnvironmentHash.java +1 -7
  45. data/src/main/java/org/jruby/jubilee/RubyHttpServerResponse.java +12 -6
  46. data/src/main/java/org/jruby/jubilee/RubyNetSocket.java +9 -12
  47. data/src/main/java/org/jruby/jubilee/RubyPlatformManager.java +39 -43
  48. data/src/main/java/org/jruby/jubilee/impl/RubyIORackInput.java +2 -1
  49. data/src/main/java/org/jruby/jubilee/vertx/JubileeVertx.java +1 -1
  50. metadata +30 -54
  51. data/examples/chatapp/config.json +0 -4
  52. data/jars/annotations-1.3.2.jar +0 -0
  53. data/jars/hazelcast-3.2.3.jar +0 -0
  54. data/jars/jackson-annotations-2.2.2.jar +0 -0
  55. data/jars/jackson-core-2.2.2.jar +0 -0
  56. data/jars/jackson-databind-2.2.2.jar +0 -0
  57. data/jars/lang-jruby-2.1.0-final.jar +0 -0
  58. data/jars/log4j-1.2.16.jar +0 -0
  59. data/jars/netty-all-4.0.20.Final.jar +0 -0
  60. data/jars/slf4j-api-1.6.2.jar +0 -0
  61. data/jars/vertx-core-2.1.2.jar +0 -0
  62. data/jars/vertx-hazelcast-2.1.2.jar +0 -0
  63. data/jars/vertx-platform-2.1.2.jar +0 -0
  64. data/lib/container.rb +0 -117
  65. data/lib/core/buffer.rb +0 -251
  66. data/lib/core/datagram.rb +0 -280
  67. data/lib/core/dns.rb +0 -143
  68. data/lib/core/event_bus.rb +0 -277
  69. data/lib/core/file_system.rb +0 -479
  70. data/lib/core/http.rb +0 -1307
  71. data/lib/core/net.rb +0 -251
  72. data/lib/core/network_support.rb +0 -77
  73. data/lib/core/parsetools.rb +0 -105
  74. data/lib/core/shared_data.rb +0 -214
  75. data/lib/core/sock_js.rb +0 -116
  76. data/lib/core/ssl_support.rb +0 -163
  77. data/lib/core/streams.rb +0 -183
  78. data/lib/core/tcp_support.rb +0 -136
  79. data/lib/core/timers.rb +0 -73
  80. data/lib/core/vertx_require.rb +0 -25
  81. data/lib/core/wrapped_handler.rb +0 -28
  82. data/lib/jubilee/jubilee_require.rb +0 -24
  83. data/lib/test_utils.rb +0 -66
  84. data/lib/vertx.rb +0 -30
  85. data/lib/vertx_tests.rb +0 -8
  86. data/src/main/assembly/mod.xml +0 -21
  87. data/src/main/java/org/jruby/jubilee/JubileeVerticleFactory.java +0 -258
  88. data/src/main/java/org/jruby/jubilee/RubyCallable.java +0 -52
  89. data/src/main/resources/META-INF/services/org.vertx.java.deploy.impl.jruby.JubileeVerticleFactory +0 -1
  90. data/src/main/resources/mod.json +0 -11
  91. data/vertx_classpath.txt +0 -12
@@ -1,7 +1,7 @@
1
- source :rubygems
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
4
- gem 'rails', '4.0.1'
4
+ gem 'rails'
5
5
 
6
6
  # Use jdbcsqlite3 as the database for Active Record
7
7
  gem 'activerecord-jdbc-adapter'
@@ -1,5 +1,5 @@
1
1
  GEM
2
- remote: http://rubygems.org/
2
+ remote: https://rubygems.org/
3
3
  specs:
4
4
  actionmailer (4.0.1)
5
5
  actionpack (= 4.0.1)
@@ -28,7 +28,6 @@ GEM
28
28
  thread_safe (~> 0.1)
29
29
  tzinfo (~> 0.3.37)
30
30
  arel (4.0.1)
31
- atomic (1.1.14)
32
31
  atomic (1.1.14-java)
33
32
  builder (3.1.4)
34
33
  coffee-rails (4.0.1)
@@ -49,7 +48,6 @@ GEM
49
48
  jquery-rails (3.0.4)
50
49
  railties (>= 3.0, < 5.0)
51
50
  thor (>= 0.14, < 2.0)
52
- json (1.8.1)
53
51
  json (1.8.1-java)
54
52
  mail (2.5.4)
55
53
  mime-types (~> 1.16)
@@ -93,8 +91,6 @@ GEM
93
91
  therubyrhino_jar (>= 1.7.3)
94
92
  therubyrhino_jar (1.7.4)
95
93
  thor (0.18.1)
96
- thread_safe (0.1.3)
97
- atomic
98
94
  thread_safe (0.1.3-java)
99
95
  atomic
100
96
  tilt (1.4.1)
@@ -117,8 +113,11 @@ DEPENDENCIES
117
113
  jbuilder (~> 1.2)
118
114
  jdbc-sqlite3
119
115
  jquery-rails (>= 3.0)
120
- rails (= 4.0.1)
116
+ rails
121
117
  sass-rails (~> 4.0.0)
122
118
  therubyrhino
123
119
  turbolinks
124
120
  uglifier (>= 1.3.0)
121
+
122
+ BUNDLED WITH
123
+ 1.10.5
@@ -8,9 +8,7 @@ package org.jruby.jubilee;
8
8
  */
9
9
  public final class Const {
10
10
 
11
- public static final String JUBILEE_VERSION = "Jubilee(2.1.0)";
12
- public static final String HTTP_11 = "HTTP/1.1";
13
- public static final String HTTP_10 = "HTTP/1.0";
11
+ public static final String JUBILEE_VERSION = "Jubilee(3.0.0)";
14
12
 
15
13
  public static final String LOCALHOST = "localhost";
16
14
  public static final String PORT_80 = "80";
@@ -27,6 +25,5 @@ public final class Const {
27
25
  }
28
26
 
29
27
  // Internal
30
- public static final String END_OF_BODY = "__EOF__";
31
28
  public static final byte EOL = '\n';
32
29
  }
@@ -1,17 +1,18 @@
1
1
  package org.jruby.jubilee;
2
2
 
3
+ import io.vertx.core.*;
4
+ import io.vertx.core.http.HttpServerOptions;
5
+ import io.vertx.core.json.JsonArray;
6
+ import io.vertx.core.json.JsonObject;
7
+ import io.vertx.core.net.JksOptions;
8
+ import io.vertx.ext.web.Router;
9
+ import io.vertx.ext.web.handler.sockjs.BridgeOptions;
10
+ import io.vertx.ext.web.handler.sockjs.PermittedOptions;
11
+ import io.vertx.ext.web.handler.sockjs.SockJSHandler;
3
12
  import org.jruby.Ruby;
4
13
  import org.jruby.RubyArray;
5
14
  import org.jruby.RubyInstanceConfig;
6
15
  import org.jruby.runtime.builtin.IRubyObject;
7
- import org.vertx.java.core.Handler;
8
- import org.vertx.java.core.http.HttpServer;
9
- import org.vertx.java.core.http.HttpServerRequest;
10
- import org.vertx.java.core.json.JsonArray;
11
- import org.vertx.java.core.json.JsonObject;
12
- import org.vertx.java.platform.Verticle;
13
- import org.vertx.java.platform.impl.JRubyVerticleFactory;
14
- import org.vertx.java.platform.impl.WrappedVertx;
15
16
 
16
17
  import java.io.IOException;
17
18
  import java.util.ArrayList;
@@ -21,21 +22,17 @@ import java.util.List;
21
22
  /**
22
23
  * Created by isaiah on 23/01/2014.
23
24
  */
24
- public class JubileeVerticle extends Verticle {
25
- private String rackup;
26
-
27
- public JubileeVerticle(){}
28
-
29
- public JubileeVerticle(String rackup) {
30
- this.rackup = rackup;
31
- }
25
+ public class JubileeVerticle extends AbstractVerticle {
32
26
 
33
27
  @Override
34
- public void start() {
35
- JRubyVerticleFactory.vertx = vertx;
36
- JRubyVerticleFactory.container = container;
37
- JsonObject config = container.config();
38
- HttpServer httpServer = vertx.createHttpServer();
28
+ public void start() throws Exception {
29
+ JsonObject config = config();
30
+ HttpServerOptions httpServerOptions = new HttpServerOptions();
31
+ httpServerOptions.setPort(config.getInteger("port"));
32
+ httpServerOptions.setHost(config.getString("host"));
33
+ httpServerOptions.setAcceptBacklog(10000);
34
+ httpServerOptions.setClientAuthRequired(false);
35
+
39
36
  String root = config.getString("root", ".");
40
37
  this.runtime = createRuntime(root, config);
41
38
  String expandedRoot = this.runtime.evalScriptlet("File.expand_path(%q(" + root + "))").asJavaString();
@@ -43,31 +40,34 @@ public class JubileeVerticle extends Verticle {
43
40
  IRubyObject rackApplication = initRackApplication(config);
44
41
  final RackApplication app;
45
42
  boolean ssl = config.getBoolean("ssl");
43
+ if (ssl) {
44
+ httpServerOptions.setSsl(true).setKeyStoreOptions(
45
+ new JksOptions().setPath(config.getString("keystore_path"))
46
+ .setPassword(config.getString("keystore_password"))
47
+ );
48
+ }
49
+ Router router = Router.router(vertx);
46
50
  try {
47
- app = new RackApplication((WrappedVertx) vertx, runtime.getCurrentContext(), rackApplication, config);
48
- httpServer.setAcceptBacklog(10000);
49
- httpServer.requestHandler(new Handler<HttpServerRequest>() {
50
- public void handle(final HttpServerRequest req) {
51
- app.call(req);
52
- }
53
- });
54
- if (config.containsField("event_bus")) {
55
- JsonArray allowAll = new JsonArray();
56
- allowAll.add(new JsonObject());
57
- JsonObject ebconf = new JsonObject();
58
- ebconf.putString("prefix", config.getString("event_bus"));
59
- vertx.createSockJSServer(httpServer).bridge(ebconf, allowAll, allowAll);
51
+ app = new RackApplication(vertx, runtime.getCurrentContext(), rackApplication, config);
52
+ if (config.containsKey("event_bus")) {
53
+ BridgeOptions options = new BridgeOptions().addOutboundPermitted(new PermittedOptions().setAddressRegex(".+"));
54
+ options.addInboundPermitted(new PermittedOptions().setAddressRegex(".+"));
55
+ router.route("/" + config.getString("event_bus") + "/*").handler(SockJSHandler.create(vertx).bridge(options, event -> {
56
+ event.complete(true);
57
+ }));
60
58
  }
61
- if (ssl) httpServer.setSSL(true).setKeyStorePath(config.getString("keystore_path"))
62
- .setKeyStorePassword(config.getString("keystore_password"));
63
- httpServer.listen(config.getInteger("port"), config.getString("host"));
59
+ router.route("/*").handler(ctx -> {
60
+ app.call(ctx.request());
61
+ });
64
62
  } catch (IOException e) {
65
- container.logger().fatal("Failed to create RackApplication");
63
+ runtime.getErrorStream().println("Failed to create RackApplication");
66
64
  }
65
+
66
+ vertx.createHttpServer(httpServerOptions).requestHandler(router::accept).listen();
67
67
  }
68
68
 
69
69
  @Override
70
- public void stop() {
70
+ public void stop(Future<Void> future) throws Exception {
71
71
  this.runtime.tearDown();
72
72
  }
73
73
 
@@ -77,17 +77,13 @@ public class JubileeVerticle extends Verticle {
77
77
 
78
78
  private Ruby createRuntime(String root, JsonObject options) {
79
79
  Ruby runtime;
80
- // if (Ruby.isGlobalRuntimeReady()) {
81
- // runtime = Ruby.getGlobalRuntime();
82
- // } else {
83
80
  RubyInstanceConfig instanceConfig = new RubyInstanceConfig();
84
81
  String jrubyHome = options.getString("jruby-home", "");
85
82
  if (!jrubyHome.isEmpty()) {
86
83
  instanceConfig.setJRubyHome(jrubyHome);
87
84
  }
88
- Object[] argv = options.getArray("argv", new JsonArray(new String[]{})).toArray();
85
+ Object[] argv = options.getJsonArray("argv", new JsonArray()).getList().toArray();
89
86
  instanceConfig.setArgv(Arrays.copyOf(argv, argv.length, String[].class));
90
- // }
91
87
  RubyArray globalLoadPaths = (RubyArray) Ruby.getGlobalRuntime().getLoadService().getLoadPath();
92
88
  List<String> loadPaths = new ArrayList<>();
93
89
  for (int i = 0; i < globalLoadPaths.size(); i++) {
@@ -102,8 +98,7 @@ public class JubileeVerticle extends Verticle {
102
98
  }
103
99
 
104
100
  private IRubyObject initRackApplication(JsonObject config) {
105
- if (this.rackup == null)
106
- this.rackup = config.getString("rackup");
101
+ String rackup = config.getString("rackup");
107
102
  String rackScript = "require 'rack'\n" +
108
103
  "require 'jubilee'\n" +
109
104
  "app, _ = Rack::Builder.parse_file('" + rackup + "')\n";
@@ -2,21 +2,15 @@ package org.jruby.jubilee;
2
2
 
3
3
  import io.netty.buffer.ByteBuf;
4
4
  import io.netty.buffer.Unpooled;
5
+ import io.vertx.core.Vertx;
6
+ import io.vertx.core.http.HttpServerRequest;
7
+ import io.vertx.core.json.JsonObject;
5
8
  import org.jruby.Ruby;
6
- import org.jruby.RubyArray;
7
9
  import org.jruby.RubyClass;
8
- import org.jruby.RubyFixnum;
9
10
  import org.jruby.javasupport.JavaEmbedUtils;
10
11
  import org.jruby.jubilee.impl.RubyIORackInput;
11
- import org.jruby.jubilee.impl.RubyNullIO;
12
12
  import org.jruby.runtime.ThreadContext;
13
13
  import org.jruby.runtime.builtin.IRubyObject;
14
- import org.vertx.java.core.Handler;
15
- import org.vertx.java.core.VoidHandler;
16
- import org.vertx.java.core.buffer.Buffer;
17
- import org.vertx.java.core.http.HttpServerRequest;
18
- import org.vertx.java.core.json.JsonObject;
19
- import org.vertx.java.platform.impl.WrappedVertx;
20
14
 
21
15
  import java.io.IOException;
22
16
  import java.io.PrintWriter;
@@ -34,14 +28,14 @@ public class RackApplication {
34
28
  private boolean ssl;
35
29
  private boolean hideErrorStack;
36
30
  private Ruby runtime;
37
- private WrappedVertx vertx;
31
+ private Vertx vertx;
38
32
  private RubyClass rackIOInputClass;
39
33
  private RubyClass httpServerResponseClass;
40
34
  private RackEnvironment rackEnv;
41
35
 
42
- public RackApplication(WrappedVertx vertx, ThreadContext context, IRubyObject app, JsonObject config) throws IOException {
36
+ public RackApplication(Vertx vertx, ThreadContext context, IRubyObject app, JsonObject config) throws IOException {
43
37
  this.app = app;
44
- this.ssl = config.getBoolean("ssl", false);
38
+ this.ssl = config.getBoolean("ssl");
45
39
  this.hideErrorStack = config.getBoolean("hide_error_stack", false);
46
40
  this.vertx = vertx;
47
41
  this.runtime = context.runtime;
@@ -64,60 +58,46 @@ public class RackApplication {
64
58
  final AtomicBoolean eof = new AtomicBoolean(false);
65
59
  input = new RubyIORackInput(runtime, rackIOInputClass, request, bodyBuf, eof);
66
60
 
67
- request.dataHandler(new Handler<Buffer>() {
68
- @Override
69
- public void handle(Buffer buffer) {
70
- bodyBuf.writeBytes(buffer.getByteBuf());
71
- }
61
+ request.handler(buffer -> {
62
+ bodyBuf.writeBytes(buffer.getByteBuf());
72
63
  });
73
64
 
74
- request.endHandler(new VoidHandler() {
75
- @Override
76
- protected void handle() {
77
- eof.set(true);
78
- }
65
+ request.endHandler(v -> {
66
+ eof.set(true);
79
67
  });
80
- request.exceptionHandler(new Handler<Throwable>() {
81
- @Override
82
- public void handle(Throwable ignore) {
83
- eof.set(true);
84
- }
68
+ request.exceptionHandler(ignore -> {
69
+ eof.set(true);
85
70
  });
86
71
  // } else {
87
72
  // input = nullio;
88
73
  // }
89
- Runnable task = new Runnable() {
90
- @Override
91
- public void run() {
92
- try {
93
- // This is a different context, do NOT replace runtime.getCurrentContext()
94
- IRubyObject result = app.callMethod(runtime.getCurrentContext(), "call", rackEnv.getEnv(request, input, ssl));
95
- /*
96
- if (request.isHijacked()) {
97
- // It's the hijacker's response to close the socket.
98
- return;
99
- }
100
- */
101
- RackResponse response = (RackResponse) JavaEmbedUtils.rubyToJava(runtime, result, RackResponse.class);
102
- RubyHttpServerResponse resp = new RubyHttpServerResponse(runtime,
103
- httpServerResponseClass, request);
104
- response.respond(resp);
105
- } catch (Exception e) {
106
- request.response().setStatusCode(500);
107
- String message = "Jubilee caught this error: " + e.getMessage() + "\n";
108
- StringWriter stringWriter = new StringWriter();
109
- PrintWriter printWriter = new PrintWriter(stringWriter);
110
- e.printStackTrace(printWriter);
111
- if (hideErrorStack) {
112
- request.response().end("Internal error.");
113
- } else {
114
- request.response().end(message + stringWriter.toString());
115
- }
116
- e.printStackTrace(runtime.getErrorStream());
74
+ vertx.executeBlocking((future) -> {
75
+ try {
76
+ // This is a different context, do NOT replace runtime.getCurrentContext()
77
+ IRubyObject result = app.callMethod(runtime.getCurrentContext(), "call", rackEnv.getEnv(request, input, ssl));
78
+ // if (request.isHijacked()) {
79
+ // // It's the hijacker's response to close the socket.
80
+ // return;
81
+ // }
82
+ RackResponse response = (RackResponse) JavaEmbedUtils.rubyToJava(runtime, result, RackResponse.class);
83
+ RubyHttpServerResponse resp = new RubyHttpServerResponse(runtime,
84
+ httpServerResponseClass, request);
85
+ response.respond(resp);
86
+ future.complete();
87
+ } catch (Exception e) {
88
+ request.response().setStatusCode(500);
89
+ String message = "Jubilee caught this error: " + e.getMessage() + "\n";
90
+ StringWriter stringWriter = new StringWriter();
91
+ PrintWriter printWriter = new PrintWriter(stringWriter);
92
+ e.printStackTrace(printWriter);
93
+ if (hideErrorStack) {
94
+ request.response().end("Internal error.");
95
+ } else {
96
+ request.response().end(message + stringWriter.toString());
117
97
  }
98
+ e.printStackTrace(runtime.getErrorStream());
118
99
  }
119
- };
120
- vertx.startInBackground(task, false);
100
+ }, false, (ar) -> {});
121
101
  }
122
102
 
123
103
  }
@@ -1,17 +1,16 @@
1
1
  package org.jruby.jubilee;
2
2
 
3
3
  import io.netty.handler.codec.http.HttpHeaders;
4
+ import io.vertx.core.MultiMap;
5
+ import io.vertx.core.http.HttpServerRequest;
6
+ import io.vertx.core.http.HttpVersion;
7
+ import io.vertx.core.net.SocketAddress;
4
8
  import org.jruby.*;
5
9
  import org.jruby.jubilee.utils.RubyHelper;
6
10
  import org.jruby.runtime.*;
7
11
  import org.jruby.runtime.builtin.IRubyObject;
8
- import org.vertx.java.core.MultiMap;
9
- import org.vertx.java.core.http.HttpServerRequest;
10
- import org.vertx.java.core.http.HttpVersion;
11
- import org.vertx.java.core.net.NetSocket;
12
12
 
13
13
  import java.io.IOException;
14
- import java.net.InetSocketAddress;
15
14
  import java.util.HashMap;
16
15
  import java.util.Map;
17
16
 
@@ -81,15 +80,19 @@ public class RackEnvironment {
81
80
 
82
81
  String scriptName = "";
83
82
  String[] hostInfo = getHostInfo(request.headers().get(Const.HOST));
83
+ String httpVersion = "1.1";
84
+ if (request.version() == HttpVersion.HTTP_1_0) {
85
+ httpVersion = "1.0";
86
+ }
84
87
 
85
- env.lazyPut(RACK_KEY.REQUEST_METHOD, request.method(), true);
88
+ env.lazyPut(RACK_KEY.REQUEST_METHOD, request.method().toString(), true);
86
89
  env.lazyPut(RACK_KEY.SCRIPT_NAME, scriptName, false);
87
90
  env.lazyPut(RACK_KEY.PATH_INFO, pathInfo, false);
88
91
  env.lazyPut(RACK_KEY.QUERY_STRING, orEmpty(request.query()), false);
89
92
  env.lazyPut(RACK_KEY.SERVER_NAME, hostInfo[0], false);
90
93
  env.lazyPut(RACK_KEY.SERVER_PORT, hostInfo[1], true);
91
94
  env.lazyPut(RACK_KEY.HTTP_VERSION,
92
- request.version() == HttpVersion.HTTP_1_1 ? Const.HTTP_11 : Const.HTTP_10, true);
95
+ httpVersion, true);
93
96
  env.lazyPut(RACK_KEY.CONTENT_TYPE, headers.get(HttpHeaders.Names.CONTENT_TYPE), true);
94
97
  env.lazyPut(RACK_KEY.REQUEST_URI, request.uri(), false);
95
98
  env.lazyPut(RACK_KEY.REMOTE_ADDR, getRemoteAddr(request), true);
@@ -99,9 +102,9 @@ public class RackEnvironment {
99
102
  env.lazyPut(RACK_KEY.MULTIPROCESS, runtime.getFalse(), false);
100
103
  env.lazyPut(RACK_KEY.RUN_ONCE, runtime.getFalse(), false);
101
104
 
102
- // Hijack handling
105
+ // Hijack handling (disabled)
103
106
  env.lazyPut(RACK_KEY.HIJACK_P, runtime.getFalse(), false);
104
- // env.lazyPut(RACK_KEY.HIJACK, hijackProc(env, request), false);
107
+ //env.lazyPut(RACK_KEY.HIJACK, hijackProc(env, request), false);
105
108
 
106
109
 
107
110
  final int contentLength = getContentLength(headers);
@@ -116,30 +119,30 @@ public class RackEnvironment {
116
119
  return env;
117
120
  }
118
121
 
119
- private IRubyObject hijackProc(final RackEnvironmentHash env, final HttpServerRequest req) {
120
- CompiledBlockCallback19 callback = new CompiledBlockCallback19() {
121
- @Override
122
- public IRubyObject call(ThreadContext context, IRubyObject self, IRubyObject[] args, Block block) {
123
- RubyNetSocket rubyNetSocket = new RubyNetSocket(context.runtime, netSocketClass, req.netSocket());
124
- env.put("rack.hijack_io", rubyNetSocket);
125
- return rubyNetSocket;
126
- }
127
-
128
- @Override
129
- public String getFile() {
130
- return null;
131
- }
132
-
133
- @Override
134
- public int getLine() {
135
- return 0;
136
- }
137
- };
138
- BlockBody body = CompiledBlockLight19.newCompiledBlockLight(Arity.NO_ARGUMENTS, runtime.getStaticScopeFactory().getDummyScope(), callback, false, 0, new String[]{});
139
- Block b = new Block(body, runtime.newBinding().getBinding());
140
-
141
- return RubyProc.newProc(runtime, b, Block.Type.LAMBDA);
142
- }
122
+ // private IRubyObject hijackProc(final RackEnvironmentHash env, final HttpServerRequest req) {
123
+ // CompiledBlockCallback19 callback = new CompiledBlockCallback19() {
124
+ // @Override
125
+ // public IRubyObject call(ThreadContext context, IRubyObject self, IRubyObject[] args, Block block) {
126
+ // RubyNetSocket rubyNetSocket = new RubyNetSocket(context.runtime, netSocketClass, req.netSocket());
127
+ // env.put("rack.hijack_io", rubyNetSocket);
128
+ // return rubyNetSocket;
129
+ // }
130
+ //
131
+ // @Override
132
+ // public String getFile() {
133
+ // return null;
134
+ // }
135
+ //
136
+ // @Override
137
+ // public int getLine() {
138
+ // return 0;
139
+ // }
140
+ // };
141
+ // BlockBody body = CompiledBlockLight19.newCompiledBlockLight(Arity.NO_ARGUMENTS, runtime.getStaticScopeFactory().getDummyScope(), callback, false, 0, new String[]{});
142
+ // Block b = new Block(body, runtime.newBinding().getBinding());
143
+ //
144
+ // return RubyProc.newProc(runtime, b, Block.Type.LAMBDA);
145
+ // }
143
146
 
144
147
  public String[] getHostInfo(String host) {
145
148
  String[] hostInfo;
@@ -157,11 +160,11 @@ public class RackEnvironment {
157
160
  }
158
161
 
159
162
  private static String getRemoteAddr(final HttpServerRequest request) {
160
- InetSocketAddress sourceAddress = request.remoteAddress();
163
+ SocketAddress sourceAddress = request.remoteAddress();
161
164
  if (sourceAddress == null) {
162
165
  return "";
163
166
  }
164
- return sourceAddress.getHostString();
167
+ return sourceAddress.host();
165
168
  }
166
169
 
167
170
  private static int getContentLength(final MultiMap headers) {