Hopefully, this isn't a mistake like on #32. I'm having a problem with getting Faraday to follow redirects.
Without specifying the middleware, I receive a 301 and a location. Everything's a okay.
url = 'http://www.simplyhired.com/job-id/ep7zlwnw5b/director-of-jobs/'
conn1 = Faraday.new
conn1.get url
=> #<Faraday::Response:0x00000002142128
@env=
#<struct Faraday::Env
method=:get,
body="",
url=#<URI::HTTP:0x0000000212c198 URL:http://www.simplyhired.com/job-id/ep7zlwnw5b/director-of-jobs/>,
request=#<struct Faraday::RequestOptions params_encoder=nil, proxy=nil, bind=nil, timeout=nil, open_timeout=nil, boundary=nil, oauth=nil>,
request_headers={"User-Agent"=>"Faraday v0.9.0"},
ssl=#<struct Faraday::SSLOptions verify=nil, ca_file=nil, ca_path=nil, verify_mode=nil, cert_store=nil, client_cert=nil, client_key=nil, certificate=nil, private_key=nil, verify_depth=nil, version=nil>,
parallel_manager=nil,
params=nil,
response=nil,
response_headers=
{"server"=>"shw",
"date"=>"Sat, 08 Nov 2014 00:47:04 GMT",
"content-type"=>"text/html; charset=UTF-8",
"content-length"=>"0",
"connection"=>"close",
"set-cookie"=>
"gc=1; expires=Sun, 09-Nov-2014 00:47:04 GMT; path=/, sess=ct%3D545d6808; path=/; domain=.simplyhired.com, sh3=id%3D273527411545d6808d42ea5.21614343%3Brv%3D208bbe4f%3Bcv%3D2; expires=Mon, 09-Nov-2015 00:47:04 GMT; path=/; domain=.simplyhired.com, sh2=cso%3D545d6808%3Bslu%3D0%3Bref%3Dsh; expires=Mon, 09-Nov-2015 00:47:04 GMT; path=/; domain=.simplyhired.com, shup=fvt%3D545d6808; expires=Mon, 08-Dec-2014 00:47:04 GMT; path=/, sh_uid=id%3A526650745545d6808d24440.69738556; expires=Thu, 07-Nov-2019 00:47:04 GMT; Max-Age=157680000; path=/; domain=.simplyhired.com, sh_sess=id%3A1415407624%2Csrc%3Aother%2Cnu%3A1; expires=Sat, 08-Nov-2014 01:17:04 GMT; Max-Age=1800; path=/; domain=.simplyhired.com",
"cache-control"=>"no-cache, must-revalidate",
"location"=>"http://www.simplyhired.com/job/ep7zlwnw5b",
"p3p"=>"CP=\"CAO DSP COR CURa ADMa DEVa TAIa OUR BUS IND UNI COM NAV INT\""},
status=301>,
@on_complete_callbacks=[]>
However, when I specify middleware, the body comes as nil.
conn2 = Faraday.new { |c| c.use FaradayMiddleware::FollowRedirects }
conn2.get url
=> #<Faraday::Connection:0x00000002ae6fd0
@builder=#<Faraday::RackBuilder:0x00000002ae6be8 @handlers=[FaradayMiddleware::FollowRedirects]>,
@default_parallel_manager=nil,
@headers={"User-Agent"=>"Faraday v0.9.0"},
@options=#<struct Faraday::RequestOptions params_encoder=nil, proxy=nil, bind=nil, timeout=nil, open_timeout=nil, boundary=nil, oauth=nil>,
@parallel_manager=nil,
@params={},
@proxy=nil,
@ssl=#<struct Faraday::SSLOptions verify=nil, ca_file=nil, ca_path=nil, verify_mode=nil, cert_store=nil, client_cert=nil, client_key=nil, certificate=nil, private_key=nil, verify_depth=nil, version=nil>,
@url_prefix=#<URI::HTTP:0x00000002ae6968 URL:http:/>>
[20] pry(main)> conn.get url
=> #<Faraday::Response:0x00000002b575c8
@env=
#<struct Faraday::Env
method=:get,
body=nil,
url=#<URI::HTTP:0x00000002b57988 URL:http://www.simplyhired.com/job-id/ep7zlwnw5b/director-of-jobs/>,
request=#<struct Faraday::RequestOptions params_encoder=nil, proxy=nil, bind=nil, timeout=nil, open_timeout=nil, boundary=nil, oauth=nil>,
request_headers={"User-Agent"=>"Faraday v0.9.0"},
ssl=#<struct Faraday::SSLOptions verify=nil, ca_file=nil, ca_path=nil, verify_mode=nil, cert_store=nil, client_cert=nil, client_key=nil, certificate=nil, private_key=nil, verify_depth=nil, version=nil>,
parallel_manager=nil,
params=nil,
response=nil,
response_headers=nil,
status=nil>,
@on_complete_callbacks=[]>
As a matter of fact, every body returns as nil.
conn.get 'https://github.com'
=> #<Faraday::Response:0x00000002b02910
@env=
#<struct Faraday::Env
method=:get,
body=nil,
url=#<URI::HTTPS:0x00000002b02d48 URL:https://github.com>,
request=#<struct Faraday::RequestOptions params_encoder=nil, proxy=nil, bind=nil, timeout=nil, open_timeout=nil, boundary=nil, oauth=nil>,
request_headers={"User-Agent"=>"Faraday v0.9.0"},
ssl=#<struct Faraday::SSLOptions verify=nil, ca_file=nil, ca_path=nil, verify_mode=nil, cert_store=nil, client_cert=nil, client_key=nil, certificate=nil, private_key=nil, verify_depth=nil, version=nil>,
parallel_manager=nil,
params=nil,
response=nil,
response_headers=nil,
status=nil>,
@on_complete_callbacks=[]>