Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed invalid rack response

  • Loading branch information...
commit 4703fe0de34a030a1ac26401cef18a88d973a9be 1 parent d3ae9ec
@jferris jferris authored
View
7 lib/copycopter_client/inject_editor.rb
@@ -19,7 +19,7 @@ def call(env)
status, headers, body =*response
if status == 200 && headers['Content-Type'].include?('text/html')
- [status, headers, inject_into(body, keys)]
+ inject_into(headers, body, keys)
else
[status, headers, body]
end
@@ -29,10 +29,11 @@ def call(env)
attr_reader :host
- def inject_into(body_parts, keys)
+ def inject_into(headers, body_parts, keys)
body = ""
body_parts.each { |part| body << part }
- [body.sub("</body>", "#{editor_html_for(keys)}</body>")]
+ injected_body = body.sub("</body>", "#{editor_html_for(keys)}</body>")
+ [200, headers.merge('Content-Length' => injected_body.size.to_s), [injected_body]]
end
def editor_html_for(keys)
View
4 spec/copycopter_client/inject_editor_spec.rb
@@ -41,7 +41,9 @@ def call(env)
response = call('Content-Type' => 'text/html; charset=utf-8',
'Response-Code' => 200,
'Response-Body' => "<body>hello</body>")
- response.last.should == ["<body>hello#{editor_code}</body>"]
+ expected_body = "<body>hello#{editor_code}</body>"
+ response.last.should == [expected_body]
+ response[1]['Content-Length'].should == expected_body.size.to_s
end
it "doesn't inject a translated key into html without a body tag" do
Please sign in to comment.
Something went wrong with that request. Please try again.