aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorhref <href@random.sh>2018-11-23 18:57:27 +0100
committerhref <href@random.sh>2018-11-30 18:00:57 +0100
commita2640c8088f46a16732a63978e92161c5199f396 (patch)
tree07350f59200baf021d24e29246ac5e5a0c412c51 /lib
parentb19597f602e70121a1762476873377c782549817 (diff)
downloadpleroma-a2640c8088f46a16732a63978e92161c5199f396.tar.gz
Parse correctly content-type & do not forward content-length
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/reverse_proxy.ex11
1 files 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