ureq
ureq copied to clipboard
interrupt redirects or save all cookies per redirect
Hello,
i have a little problem. UReq takes all redirects and after the request it is an 200.statuscode. I wish i can interrupting each redirect per an iteration or so.
Or ist it possible to save all cookies per redirect individual?
thx
Hi!
You can stop the redirects by setting the redirect count to 0 on agent.
Check out AgentBuilder::redirects
@algesten Thx, wonderful, but now, after heavy experimenting, i want to use the cookie_store in an agent (ureq::Builder) for read (after redirect interruption where i have save the cookies) and became this error message:
.cookie_store(my_store)
| ------------ ^^^^^^^^ expected struct `cookie_store::cookie_store::CookieStore`, found struct `CookieStore`
is the new agent for the next location-request after saving the cookiestore
ps: some code from my project:
let file = File::open("cookies_agent.json").unwrap();
let read = std::io::BufReader::new(file);
let my_store = CookieStore::load_json(read).unwrap();
let agent = ureq::builder()
.redirects(0)
.cookie_store(my_store)
.build();
let response = agent.get(&gogUri)
.call().unwrap();
for variable in response.headers_names()
{
println!("{:?} - {:?}", variable, response.header(&variable).unwrap());
}
Can you share the full code from your project? Debugging the error you shared requires looking at the imports.
@jsha hi, sure the imports i have forgot:
extern crate ureq;
extern crate serde_json;
extern crate select;
extern crate cookie_store;
use std::fs::File;
use std::io;
use cookie_store::CookieStore;
use select::{document::*, predicate::*};
use regex::*;
At the moment i use .set("Cookie") and use my own cookies->string but i love the idea from CookieStore and the agents. #548 this is not the issue with my problem, or?
The actual git version accept my my_store variable but i have another issue with the git version. Give it an middleway, that the cookiestore handling from git version can included in the 2.5.1 or so?
Closing since we're moving to ureq 3.x.