Package com.squareup.rack

Examples of com.squareup.rack.RackResponse


    app = new JRubyRackApplication(callable);
    env = envBuilder.build(request);
  }

  @Test public void callSetsTheResponseStatus() {
    RackResponse response = app.call(env);
    assertThat(response.getStatus()).isEqualTo(200);
  }
View Full Code Here


    RackResponse response = app.call(env);
    assertThat(response.getStatus()).isEqualTo(200);
  }

  @Test public void callSetsTheResponseHeaders() {
    RackResponse response = app.call(env);
    assertThat(response.getHeaders()).contains(entry("Content-Type", "text/plain"));
  }
View Full Code Here

    RackResponse response = app.call(env);
    assertThat(response.getHeaders()).contains(entry("Content-Type", "text/plain"));
  }

  @Test public void callSetsTheResponseBody() {
    RackResponse response = app.call(env);

    ImmutableList.Builder<String> strings = ImmutableList.builder();

    Iterator<byte[]> bytes = response.getBody();
    while (bytes.hasNext()) {
      strings.add(new String(bytes.next()));
    }

    assertThat(SPACE.join(strings.build())).isEqualTo(SPACE.join(env.keySet()));
View Full Code Here

  @Test public void callParsesTheResponseStatusFromAString() {
    IRubyObject callable = Ruby.getGlobalRuntime()
        .evalScriptlet("proc { |env| ['201', {'Content-Type' => 'text/plain'}, env.keys] }");
    app = new JRubyRackApplication(callable);

    RackResponse response = app.call(env);
    assertThat(response.getStatus()).isEqualTo(201);
  }
View Full Code Here

      body.add(parts);
      return this;
    }

    public RackResponse build() {
      return new RackResponse(status, headers.build(), body.build().iterator());
    }
View Full Code Here

  @Override protected void service(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    RackEnvironment rackEnvironment = rackEnvironmentBuilder.build(request);

    try {
      RackResponse rackResponse = rackApplication.call(rackEnvironment);
      rackResponsePropagator.propagate(rackResponse, response);
    } finally {
      rackEnvironment.closeRackInput();
    }
  }
View Full Code Here

  private RackResponse convertToJavaRackResponse(RubyArray response) {
    int status = Integer.parseInt(response.get(0).toString(), 10);
    Map headers = (Map) response.get(1);
    IRubyObject body = (IRubyObject) response.get(2);

    return new RackResponse(status, headers, new JRubyRackBodyIterator(body));
  }
View Full Code Here

TOP

Related Classes of com.squareup.rack.RackResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.