File tree Expand file tree Collapse file tree
main/java/org/jruby/rack/ext Expand file tree Collapse file tree Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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"
You can’t perform that action at this time.
0 commit comments