Skip to content

Commit 67a0a50

Browse files
committed
Merge branch '1.3-stable'
2 parents 4b481ee + 4319f15 commit 67a0a50

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

‎src/main/java/org/jruby/rack/ext/Response.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,10 @@ protected void writeHeaders(final RackResponseEnvironment response) {
369369
public void visit(final IRubyObject key, final IRubyObject val) {
370370
final String name = key.toString();
371371

372+
// SPEC: special headers starting "rack." are for communicating
373+
// with the server and must not be sent back to the client
374+
if ( name.startsWith("rack.") ) return;
375+
372376
if ( name.equalsIgnoreCase("Content-Type") ) {
373377
response.setContentType( val.asJavaString() ); return;
374378
}

‎src/spec/ruby/jruby/rack/response_spec.rb‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ class << value
112112
response.to_java.respond(response_environment)
113113
end
114114

115+
it "does not send rack. headers to the client" do
116+
headers = { "rack.hijack" => Object.new, "Server" => "Trinidad" }
117+
response = JRuby::Rack::Response.new [200, headers, ['body']]
118+
expect(servlet_response).to receive(:addHeader).with("Server", "Trinidad")
119+
expect(servlet_response).not_to receive(:addHeader).with("rack.hijack", anything)
120+
response.write_headers(response_environment)
121+
end
122+
115123
it "calls close on the body if the body responds to close" do
116124
body = double('body')
117125
expect(body).to receive(:each).ordered.and_yield "hello"

0 commit comments

Comments
 (0)