M
M
Maxim Barulin2015-11-03 15:03:48
Erlang
Maxim Barulin, 2015-11-03 15:03:48

Why doesn't autoredirect work in httpc:request [Erlang]?

There is a request code:

httpc:request(post,
    {Url, [],
      "application/x-www-form-urlencoded",
        "param1=1"
    }, [], [])

the response looks like this:
{ok,{{"HTTP/1.1",301,"Moved Permanently"},
     [{"connection","keep-alive"},
      {"date","Mon, 02 Nov 2015 14:34:38 GMT"},
      {"location","http://site.ru/new"},
      {"server","nginx"},
      {"content-length","249"},
      {"content-type","text/html; charset=iso-8859-1"},
      {"keep-alive","timeout=60"}],
     "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>301 Moved Permanently</title>\n</head><body>\n<h1>Moved Permanently</h1>\n<p>The document has moved <a href=\"http://site.ru/new\">here</a>.</p>\n</body></html>\n"}}

According to documentation
autoredirect
The client automatically retrieves the information from the new URI and returns that as the result, instead of a 30X-result code.
For some 30X-result codes, automatic redirect is not allowed. In these cases the 30X-result is always returned.
default is true.

there should be an automatic redirect, but for some reason this does not happen. I tried to manually set the parameter {autoredirect, true}, nothing has changed. What have I done wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2015-11-03
@Slavenin999

I gave you httpc. Use shotgun.
https://github.com/inaka/shotgun
httpc behaves inappropriately with a large number of requests.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question