This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fix attachment proxy when running on unicorn

refs #53
  • Loading branch information...
Jesse Stuart
Jesse Stuart committed Dec 27, 2012
1 parent 5ec2109 commit f3ef4aa55fbcd63b90b7b9805b2b9ed2c784789d
Showing with 9 additions and 3 deletions.
  1. +1 −2 lib/tentd/api/followings.rb
  2. +5 −0 lib/tentd/api/middleware.rb
  3. +3 −1 lib/tentd/api/posts.rb
@@ -216,8 +216,7 @@ def action(env)
path = env.params.delete(:proxy_path).sub(%r{\A/}, '')
res = client.http.get(path, env.params, whitelisted_headers(env))
headers = res.headers
- blacklist = %w[ transfer-encoding connection status ]
- blacklist.each { |key| headers.delete(key) }
+ filter_proxy_response_headers(headers)
[res.status, headers, [res.body]]
end
@@ -62,6 +62,11 @@ def serialize_params(params)
def error_response(status, error, headers = {})
[status, headers.merge('Content-Type' => MEDIA_TYPE), [{ 'error' => error }.to_json]]
end
+
+ def filter_proxy_response_headers(headers)
+ blacklist = %w[ transfer-encoding connection status ]
+ blacklist.each { |key| headers.delete(key) }
+ end
end
end
end
View
@@ -400,7 +400,9 @@ def action(env)
if following = Model::Following.first(:id => post.following_id)
client = TentClient.new(following.core_profile.servers.first, following.auth_details.merge(:skip_serialization => true, :faraday_adapter => TentD.faraday_adapter))
res = client.post.attachment.get(post.public_id, env.params.attachment_name, type)
- return [res.status, res.headers, [res.body]]
+ headers = res.headers
+ filter_proxy_response_headers(headers)
+ return [res.status, headers, [res.body]]
else
raise NotFound
end

0 comments on commit f3ef4aa

Please sign in to comment.