Parse correctly content-type & do not forward content-length

This commit is contained in:
href 2018-11-23 18:57:27 +01:00
parent b19597f602
commit a2640c8088
No known key found for this signature in database
GPG Key ID: EE8296C1A152C325
1 changed files with 8 additions and 3 deletions

View File

@ -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