From a2640c8088f46a16732a63978e92161c5199f396 Mon Sep 17 00:00:00 2001 From: href Date: Fri, 23 Nov 2018 18:57:27 +0100 Subject: [PATCH] Parse correctly content-type & do not forward content-length --- lib/pleroma/reverse_proxy.ex | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/pleroma/reverse_proxy.ex b/lib/pleroma/reverse_proxy.ex index 64c3c3a19..c8b14a89d 100644 --- a/lib/pleroma/reverse_proxy.ex +++ b/lib/pleroma/reverse_proxy.ex @@ -2,7 +2,7 @@ defmodule Pleroma.ReverseProxy do @keep_req_headers ~w(accept user-agent accept-encoding cache-control if-modified-since if-none-match range) @resp_cache_headers ~w(etag date last-modified cache-control) @keep_resp_headers @resp_cache_headers ++ - ~w(content-type content-disposition content-length accept-ranges vary) + ~w(content-type content-disposition accept-ranges vary) @default_cache_control_header "public, max-age=1209600" @valid_resp_codes [200, 206, 304] @max_read_duration :timer.minutes(2) @@ -225,6 +225,12 @@ defmodule Pleroma.ReverseProxy do end) end + defp get_content_type(headers) do + {_, content_type} = List.keyfind(headers, "content-type", 0, {"content-type", "application/octet-stream"}) + [content_type | _] = String.split(content_type, ";") + content_type + end + defp put_resp_headers(conn, headers) do Enum.reduce(headers, conn, fn {k, v}, conn -> put_resp_header(conn, k, v) @@ -274,8 +280,7 @@ defmodule Pleroma.ReverseProxy do defp build_resp_content_disposition_header(headers, opts) do opt = Keyword.get(opts, :inline_content_types, @inline_content_types) - {_, content_type} = - List.keyfind(headers, "content-type", 0, {"content-type", "application/octect-stream"}) + content_type = get_content_type(headers) attachment? = cond do