mirror of
https://github.com/rwf2/Rocket.git
synced 2025-01-05 17:22:36 +00:00
5d9035ddc1
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.
34 lines
934 B
Rust
34 lines
934 B
Rust
#[macro_use] extern crate rocket;
|
|
|
|
use rocket::Response;
|
|
use rocket::http::Header;
|
|
|
|
#[get("/do_not_overwrite")]
|
|
fn do_not_overwrite() -> Response<'static> {
|
|
Response::build()
|
|
.header(Header::new("Server", "Test"))
|
|
.finalize()
|
|
}
|
|
|
|
#[get("/use_default")]
|
|
fn use_default() { }
|
|
|
|
mod conditionally_set_server_header {
|
|
use super::*;
|
|
use rocket::local::blocking::Client;
|
|
|
|
#[test]
|
|
fn do_not_overwrite_server_header() {
|
|
let rocket = rocket::ignite().mount("/", routes![do_not_overwrite, use_default]);
|
|
let client = Client::tracked(rocket).unwrap();
|
|
|
|
let response = client.get("/do_not_overwrite").dispatch();
|
|
let server = response.headers().get_one("Server");
|
|
assert_eq!(server, Some("Test"));
|
|
|
|
let response = client.get("/use_default").dispatch();
|
|
let server = response.headers().get_one("Server");
|
|
assert_eq!(server, Some("Rocket"));
|
|
}
|
|
}
|