Hi,
I have this URL https://beerfactory.org/api/v1/apps
which redirects (HTTP 301) to https://mastodon.beerfactory.org/api/v1/apps
.
When using HTTPoison to post of this URL with the following code to follow the redirection:
HTTPoison.request(:post, "https://beerfactory.org/api/v1/apps", "", [], [follow_redirect: true])
I get the following result :
{:ok,
%HTTPoison.AsyncResponse{
id: {:maybe_redirect, 301,
[
{"Server", "nginx/1.14.0 (Ubuntu)"},
{"Date", "Mon, 29 Oct 2018 21:45:22 GMT"},
{"Content-Type", "text/html"},
{"Content-Length", "194"},
{"Connection", "keep-alive"},
{"Location", "https://mastodon.beerfactory.org/api/v1/apps"}
],
{:client, {1540, 849522, 427514}, {:metrics_ng, :metrics_dummy},
:hackney_ssl, 'beerfactory.org', 443, "beerfactory.org",
[max_redirect: 5, follow_redirect: true],
{:sslsocket, {:gen_tcp, #Port<0.7>, :tls_connection, :undefined},
[#PID<0.204.0>, #PID<0.203.0>]},
{:default, #Reference<0.4243972227.2875195393.28572>,
{'beerfactory.org', 443, :hackney_ssl}, #PID<0.199.0>, :hackney_ssl},
#Reference<0.4243972227.2875195393.28572>, true, :hackney_pool, 5000, true,
5, false, 5, nil, nil,
{:hparser, :response, 4096, 10, 0, :on_body,
"<html>\r\n<head><title>301 Moved Permanently</title></head>\r\n<body bgcolor=\"white\">\r\n<center><h1>301 Moved Permanently</h1></center>\r\n<hr><center>nginx/1.14.0 (Ubuntu)</center>\r\n</body>\r\n</html>\r\n",
{1, 1}, "", [], 194, "", "keep-alive", "text/html",
"https://mastodon.beerfactory.org/api/v1/apps", :waiting},
{6,
{:dict, 6, 16, 16, 8, 80, 48,
{[], [], [], [], [], [], [], [], [], [], [], ...},
{{[["content-length", {3, "Content-Length", "194"}]],
[
[
"location",
{5, "Location", "https://mastodon.beerfactory.org/api/v1/apps"}
]
], [["date", {1, "Date", "Mon, 29 Oct 2018 21:45:22 GMT"}]], [], [],
[["server", {...}]], [], [], [], ...}}}}, :connected, :waiting, nil,
:normal, false, false, false, :undefined, false, &:hackney_request.send/2,
:waiting, nil, 4096, "", [], {1, 1}, 194, nil, nil, "POST", "/api/v1/apps",
...}}
}}
Is there a way I can get the redirection target body from this result ?
Thanks.