Comments (4)
Looking in Postman, there are indeed redirects on this request:
Only the first response in the chain has Set-Cookie
for PHPSESSID-FRONT
, so when you examine the (final) response you don't see it. If you inspect the contents of jar
in your original example, instead of response.cookies()
, you will find the PHPSESSID-FRONT
cookie is stored, as is the case w/ the reqwest_cookie_store
version.
_response_ cookie names:
["AWSALBTG", "AWSALBTGCORS"]
_jar_ cookie names:
"applicationId"
" AWSALBTG"
" AWSALBTGCORS"
" PHPSESSID-FRONT"
from reqwest.
I resolved my issue using a cookie store:
[dependencies]
tokio = { version = "1", features = ["full"] }
reqwest = "0.12.2"
reqwest_cookie_store= "0.7.0"
use tokio;
use std::sync::Arc;
use reqwest::{self, Client, Url};
use reqwest_cookie_store::{RawCookie, CookieStore};
#[tokio::main]
async fn main() {
let application_id = "21891030";
let cookie = RawCookie::new("applicationId", application_id);
let mut cookie_store = CookieStore::new(None);
let domain_url = format!("https://sport.nubapp.com").parse::<Url>().unwrap();
let _ = cookie_store.insert_raw(&cookie, &domain_url);
let cookie_store = reqwest_cookie_store::CookieStoreMutex::new(cookie_store);
let cookie_store = Arc::new(cookie_store);
let client = Client::builder()
.cookie_provider(Arc::clone(&cookie_store))
.build()
.unwrap();
let url = format!("https://sport.nubapp.com/web/cookieChecker.php?id_application={application_id}&isIframe=true");
let response = client.get(url)
.send()
.await
.unwrap();
let cookies = response.cookies().collect::<Vec<reqwest::cookie::Cookie>>();
let cookies_name = cookies.iter().map(reqwest::cookie::Cookie::name).collect::<Vec<&str>>();
println!("{:?}", cookies_name);
{
// Examine the contents of the store.
println!("Examining cookie store");
let store = cookie_store.lock().unwrap();
for c in store.iter_any() {
println!("{:?}", c.name());
}
}
}
First print still returns ["AWSALBTG", "AWSALBTGCORS"]
Prints in the loop show
Examining cookie store
"AWSALBTG"
"PHPSESSID-FRONT"
"AWSALBTGCORS"
"applicationId"
I am still curious to understand why the PHPSESSID-FRONT cookie is not set in the response.
from reqwest.
Could it be that "missing" cookie comes from a redirect? Or has a different path/domain than the response?
from reqwest.
No same path and domain, and no redirect it seems.
from reqwest.
Related Issues (20)
- (feat.) Manage multipart Content-type header HOT 4
- Question: Howto extract Peer Certificate
- native-tis-alpn feature overrides request's host header HOT 5
- [BUG] TCP Socket Error Os 10013 Windows
- Use `simd_json` HOT 4
- Change Response to be an Enum HOT 2
- `Sync` bound in `Body::wrap_stream` back after `v0.12.0`
- `response.content_length()` documentation does not reflect the semantics of `content_length()` after `chunk()` has been called.
- Performance regression starting with version 0.12 HOT 2
- `connection_verbose` does not emit the response headers and body HOT 1
- Removing header from client?
- How can trace a request?
- rustls 0.22.2 vulnerability HOT 1
- A time out error after upgrading from 0.11.x to 0.12.x and using http2
- reqwest serialization of data. HOT 2
- Option to customize dns config HOT 2
- Supporting 425 Too Early HOT 3
- Getting invlideUriChar error when loading a url with "quotes" HOT 2
- Support WebAssembly Component bindings, aka wasip2, in addition to javascript bindings HOT 2
- Sudden memory spike on downloading lots of files HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reqwest.