Rocket/core/lib/tests/absolute-uris-okay-issue-443.rs
Sergio Benitez 5d9035ddc1 Keep an op-log for sync 'CookieJar'.
In brief, this commit:

  * Updates to the latest upstream 'cookie', fixing a memory leak.
  * Make changes to 'CookieJar' observable only through 'pending()'.
  * Deprecates 'Client::new()' in favor of 'Client::tracked()'.
  * Makes 'dispatch()' on tracked 'Client's synchronize on cookies.
  * Makes 'Client::untracked()' actually untracked.

This commit updates to the latest 'cookie' which removes support for
'Sync' cookie jars. Instead of relying on 'cookie', this commit
implements an op-log based 'CookieJar' which internally keeps track of
changes. The API is such that changes are only observable through
specialized '_pending()' methods.
2020-10-14 21:37:16 -07:00

33 lines
880 B
Rust

#[macro_use] extern crate rocket;
use rocket::response::Redirect;
#[get("/google")]
fn google() -> Redirect {
Redirect::to("https://www.google.com")
}
#[get("/rocket")]
fn redirect() -> Redirect {
Redirect::to("https://rocket.rs:80")
}
mod test_absolute_uris_okay {
use super::*;
use rocket::local::blocking::Client;
#[test]
fn redirect_works() {
let rocket = rocket::ignite().mount("/", routes![google, redirect]);
let client = Client::tracked(rocket).unwrap();
let response = client.get("/google").dispatch();
let location = response.headers().get_one("Location");
assert_eq!(location, Some("https://www.google.com"));
let response = client.get("/rocket").dispatch();
let location = response.headers().get_one("Location");
assert_eq!(location, Some("https://rocket.rs:80"));
}
}