mirror of
https://github.com/servo/servo.git
synced 2025-09-30 16:49:16 +01:00
Remove empty lines following braces.
This commit is contained in:
parent
4ebc065cba
commit
3cb8af20c2
69 changed files with 3 additions and 162 deletions
|
@ -77,7 +77,6 @@ fn match_headers(cors_cache: &CORSCacheEntry, cors_req: &Request) -> bool {
|
|||
pub struct CORSCache(Vec<CORSCacheEntry>);
|
||||
|
||||
impl CORSCache {
|
||||
|
||||
pub fn new() -> CORSCache {
|
||||
CORSCache(vec![])
|
||||
}
|
||||
|
|
|
@ -47,7 +47,6 @@ pub fn fetch(request: Rc<Request>) -> Response {
|
|||
}
|
||||
|
||||
pub fn fetch_with_cors_cache(request: Rc<Request>, cache: &mut CORSCache) -> Response {
|
||||
|
||||
// Step 1
|
||||
if request.window.get() == Window::Client {
|
||||
// TODO: Set window to request's client object if client is a Window object
|
||||
|
@ -63,9 +62,7 @@ pub fn fetch_with_cors_cache(request: Rc<Request>, cache: &mut CORSCache) -> Res
|
|||
|
||||
// Step 3
|
||||
if !request.headers.borrow().has::<Accept>() {
|
||||
|
||||
let value = match request.type_ {
|
||||
|
||||
// Substep 2
|
||||
_ if request.is_navigation_request() =>
|
||||
vec
|
||||
fn basic_fetch(request: Rc<Request>, cache: &mut CORSCache) -> Response {
|
||||
|
||||
let url = request.current_url();
|
||||
|
||||
match url.scheme() {
|
||||
|
||||
"about" if url.path() == "blank" => {
|
||||
let mut response = Response::new();
|
||||
response.headers.set(ContentType(mime!(Text / Html; Charset = Utf8)));
|
||||
|
@ -358,7 +351,6 @@ fn http_fetch(request: Rc<Request>,
|
|||
cors_flag: bool,
|
||||
cors_preflight_flag: bool,
|
||||
authentication_fetch_flag: bool) -> Response {
|
||||
|
||||
// Step 1
|
||||
let mut response: Option<Response> = None;
|
||||
|
||||
|
@ -367,12 +359,10 @@ fn http_fetch(request: Rc<Request>,
|
|||
|
||||
// Step 3
|
||||
if !request.skip_service_worker.get() && !request.is_service_worker_global_scope {
|
||||
|
||||
// Substep 1
|
||||
// TODO (handle fetch unimplemented)
|
||||
|
||||
if let Some(ref res) = response {
|
||||
|
||||
// Substep 2
|
||||
// nothing to do, since actual_response is a function on response
|
||||
|
||||
|
@ -400,7 +390,6 @@ fn http_fetch(request: Rc<Request>,
|
|||
|
||||
// Step 4
|
||||
if response.is_none() {
|
||||
|
||||
// Substep 1
|
||||
if cors_preflight_flag {
|
||||
let method_cache_match = cache.match_method(&*request,
|
||||
|
@ -450,11 +439,9 @@ fn http_fetch(request: Rc<Request>,
|
|||
|
||||
// Step 5
|
||||
match response.actual_response().status.unwrap() {
|
||||
|
||||
// Code 301, 302, 303, 307, 308
|
||||
StatusCode::MovedPermanently | StatusCode::Found | StatusCode::SeeOther |
|
||||
StatusCode::TemporaryRedirect | StatusCode::PermanentRedirect => {
|
||||
|
||||
response = match request.redirect_mode.get() {
|
||||
RedirectMode::Error => Response::network_error(),
|
||||
RedirectMode::Manual => {
|
||||
|
@ -470,7 +457,6 @@ fn http_fetch(request: Rc<Request>,
|
|||
|
||||
// Code 401
|
||||
StatusCode::Unauthorized => {
|
||||
|
||||
// Step 1
|
||||
// FIXME: Figure out what to do with request window objects
|
||||
if cors_flag || request.credentials_mode != CredentialsMode::Include {
|
||||
|
@ -491,7 +477,6 @@ fn http_fetch(request: Rc<Request>,
|
|||
|
||||
// Code 407
|
||||
StatusCode::ProxyAuthenticationRequired => {
|
||||
|
||||
// Step 1
|
||||
// TODO: Figure out what to do with request window objects
|
||||
|
||||
|
@ -526,7 +511,6 @@ fn http_redirect_fetch(request: Rc<Request>,
|
|||
cache: &mut CORSCache,
|
||||
response: Rc<Response>,
|
||||
cors_flag: bool) -> Response {
|
||||
|
||||
// Step 1
|
||||
assert_eq!(response.return_internal.get(), true);
|
||||
|
||||
|
@ -592,7 +576,6 @@ fn http_redirect_fetch(request: Rc<Request>,
|
|||
if ((status_code == StatusCode::MovedPermanently || status_code == StatusCode::Found) &&
|
||||
*request.method.borrow() == Method::Post) ||
|
||||
status_code == StatusCode::SeeOther {
|
||||
|
||||
*request.method.borrow_mut() = Method::Get;
|
||||
*request.body.borrow_mut() = None;
|
||||
}
|
||||
|
@ -608,7 +591,6 @@ fn http_redirect_fetch(request: Rc<Request>,
|
|||
fn http_network_or_cache_fetch(request: Rc<Request>,
|
||||
credentials_flag: bool,
|
||||
authentication_fetch_flag: bool) -> Response {
|
||||
|
||||
// TODO: Implement Window enum for Request
|
||||
let request_has_no_window = true;
|
||||
|
||||
|
@ -662,7 +644,6 @@ fn http_network_or_cache_fetch(request: Rc<Request>,
|
|||
}
|
||||
|
||||
match http_request.cache_mode.get() {
|
||||
|
||||
// Step 9
|
||||
CacheMode::Default if is_no_store_cache(&http_request.headers.borrow()) => {
|
||||
http_request.cache_mode.set(CacheMode::NoStore);
|
||||
|
@ -695,13 +676,11 @@ fn http_network_or_cache_fetch(request: Rc<Request>,
|
|||
// Step 13
|
||||
// TODO some of this step can't be implemented yet
|
||||
if credentials_flag {
|
||||
|
||||
// Substep 1
|
||||
// TODO http://mxr.mozilla.org/servo/source/components/net/http_loader.rs#504
|
||||
|
||||
// Substep 2
|
||||
if !http_request.headers.borrow().has::<Authorization<String>>() {
|
||||
|
||||
// Substep 3
|
||||
let mut authorization_value = None;
|
||||
|
||||
|
@ -710,7 +689,6 @@ fn http_network_or_cache_fetch(request: Rc<Request>,
|
|||
|
||||
// Substep 5
|
||||
if authentication_fetch_flag {
|
||||
|
||||
let current_url = http_request.current_url();
|
||||
|
||||
authorization_value = if has_credentials(¤t_url) {
|
||||
|
@ -742,7 +720,6 @@ fn http_network_or_cache_fetch(request: Rc<Request>,
|
|||
if http_request.cache_mode.get() != CacheMode::NoStore &&
|
||||
http_request.cache_mode.get() != CacheMode::Reload &&
|
||||
complete_http_response_from_cache.is_some() {
|
||||
|
||||
// Substep 1
|
||||
if http_request.cache_mode.get() == CacheMode::ForceCache {
|
||||
// TODO pull response from HTTP cache
|
||||
|
@ -764,7 +741,6 @@ fn http_network_or_cache_fetch(request: Rc<Request>,
|
|||
// Substep 3
|
||||
if revalidation_needed && http_request.cache_mode.get() == CacheMode::Default ||
|
||||
http_request.cache_mode.get() == CacheMode::NoCache {
|
||||
|
||||
// TODO this substep
|
||||
}
|
||||
|
||||
|
@ -786,7 +762,6 @@ fn http_network_or_cache_fetch(request: Rc<Request>,
|
|||
if status == StatusCode::NotModified &&
|
||||
(http_request.cache_mode.get() == CacheMode::Default ||
|
||||
http_request.cache_mode.get() == CacheMode::NoCache) {
|
||||
|
||||
// Substep 1
|
||||
// TODO this substep
|
||||
// let cached_response: Option<Response> = None;
|
||||
|
@ -848,7 +823,6 @@ fn http_network_fetch(request: Rc<Request>,
|
|||
|
||||
let res_body = response.body.clone();
|
||||
thread::spawn(move || {
|
||||
|
||||
*res_body.lock().unwrap() = ResponseBody::Receiving(vec![]);
|
||||
|
||||
loop {
|
||||
|
@ -892,11 +866,9 @@ fn http_network_fetch(request: Rc<Request>,
|
|||
// TODO this step
|
||||
if let Some(encoding) = response.headers.get::<ContentEncoding>() {
|
||||
if encoding.contains(&Encoding::Gzip) {
|
||||
|
||||
}
|
||||
|
||||
else if encoding.contains(&Encoding::Compress) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1027,7 +999,6 @@ fn cors_preflight_fetch(request: Rc<Request>, cache: &mut CORSCache) -> Response
|
|||
|
||||
/// [CORS check](https://fetch.spec.whatwg.org#concept-cors-check)
|
||||
fn cors_check(request: Rc<Request>, response: &Response) -> Result<(), ()> {
|
||||
|
||||
// Step 1
|
||||
let origin = response.headers.get::<AccessControlAllowOrigin>().cloned();
|
||||
|
||||
|
|
|
@ -132,7 +132,6 @@ impl FileManager {
|
|||
}
|
||||
|
||||
fn read_file(&mut self, sender: IpcSender<FileManagerResult<Vec<u8>>>, id: Uuid) {
|
||||
|
||||
match self.idmap.borrow().get(&id).and_then(|filepath| {
|
||||
let mut buffer = vec![];
|
||||
match File::open(&filepath) {
|
||||
|
|
|
@ -124,7 +124,6 @@ fn load_for_consumer(load_data: LoadData,
|
|||
devtools_chan: Option<Sender<DevtoolsControlMsg>>,
|
||||
cancel_listener: CancellationListener,
|
||||
user_agent: String) {
|
||||
|
||||
let factory = NetworkHttpRequestFactory {
|
||||
connector: connector,
|
||||
};
|
||||
|
@ -555,7 +554,6 @@ fn send_request_to_devtools(devtools_chan: Option<Sender<DevtoolsControlMsg>>,
|
|||
headers: Headers,
|
||||
body: Option<Vec<u8>>,
|
||||
pipeline_id: PipelineId, now: Tm) {
|
||||
|
||||
if let Some(ref chan) = devtools_chan {
|
||||
let request = DevtoolsHttpRequest {
|
||||
url: url, method: method, headers: headers, body: body, pipeline_id: pipeline_id, startedDateTime: now };
|
||||
|
@ -632,7 +630,6 @@ pub fn modify_request_headers(headers: &mut Headers,
|
|||
fn set_auth_header(headers: &mut Headers,
|
||||
url: &Url,
|
||||
auth_cache: &Arc<RwLock<AuthCache>>) {
|
||||
|
||||
if !headers.has::<Authorization<Basic>>() {
|
||||
if let Some(auth) = auth_from_url(url) {
|
||||
headers.set(auth);
|
||||
|
@ -694,7 +691,6 @@ pub fn obtain_response<A>(request_factory: &HttpRequestFactory<R=A>,
|
|||
devtools_chan: &Option<Sender<DevtoolsControlMsg>>,
|
||||
request_id: &str)
|
||||
-> Result<A::R, LoadError> where A: HttpRequest + 'static {
|
||||
|
||||
let null_data = None;
|
||||
let response;
|
||||
let connection_url = replace_hosts(&url);
|
||||
|
|
|
@ -266,7 +266,6 @@ trait Matches {
|
|||
}
|
||||
|
||||
impl <'a, T: Iterator<Item=&'a u8> + Clone> Matches for T {
|
||||
|
||||
// Matching function that works on an iterator.
|
||||
// see if the next matches.len() bytes in data_iterator equal matches
|
||||
// move iterator and return true or just return false
|
||||
|
@ -587,7 +586,6 @@ struct FeedsClassifier;
|
|||
impl FeedsClassifier {
|
||||
// Implements sniffing for mislabeled feeds (https://mimesniff.spec.whatwg.org/#sniffing-a-mislabeled-feed)
|
||||
fn classify_impl(&self, data: &[u8]) -> Option<(&'static str, &'static str)> {
|
||||
|
||||
// Step 4: can not be feed unless length is > 3
|
||||
if data.len() < 3 {
|
||||
return None;
|
||||
|
@ -603,7 +601,6 @@ impl FeedsClassifier {
|
|||
// TODO: need max_bytes to prevent inadvertently examining html document
|
||||
// eg. an html page with a feed example
|
||||
loop {
|
||||
|
||||
if matcher.find(|&x| *x == b'<').is_none() {
|
||||
return None;
|
||||
}
|
||||
|
|
|
@ -234,7 +234,6 @@ impl ResourceChannelManager {
|
|||
}
|
||||
|
||||
pub fn read_json_from_file<T: Decodable>(data: &mut T, config_dir: &str, filename: &str) {
|
||||
|
||||
let path = Path::new(config_dir).join(filename);
|
||||
let display = path.display();
|
||||
|
||||
|
@ -262,7 +261,6 @@ pub fn read_json_from_file<T: Decodable>(data: &mut T, config_dir: &str, filenam
|
|||
}
|
||||
|
||||
pub fn write_json_to_file<T: Encodable>(data: &T, config_dir: &str, filename: &str) {
|
||||
|
||||
let json_encoded: String;
|
||||
match json::encode(&data) {
|
||||
Ok(d) => json_encoded = d,
|
||||
|
@ -357,7 +355,6 @@ pub struct AuthCacheEntry {
|
|||
}
|
||||
|
||||
impl AuthCache {
|
||||
|
||||
pub fn new() -> AuthCache {
|
||||
AuthCache {
|
||||
version: 1,
|
||||
|
@ -429,7 +426,6 @@ impl CoreResourceManager {
|
|||
consumer: LoadConsumer,
|
||||
id_sender: Option<IpcSender<ResourceId>>,
|
||||
resource_thread: CoreResourceThread) {
|
||||
|
||||
fn from_factory(factory: fn(LoadData, LoadConsumer, Arc<MIMEClassifier>, CancellationListener))
|
||||
-> Box<FnBox(LoadData,
|
||||
LoadConsumer,
|
||||
|
|
|
@ -30,7 +30,6 @@ fn establish_a_websocket_connection(resource_url: &Url, net_url: (Host, String,
|
|||
origin: String, protocols: Vec<String>,
|
||||
cookie_jar: Arc<RwLock<CookieStorage>>)
|
||||
-> WebSocketResult<(Headers, Sender<WebSocketStream>, Receiver<WebSocketStream>)> {
|
||||
|
||||
let host = Host {
|
||||
hostname: resource_url.host_str().unwrap().to_owned(),
|
||||
port: resource_url.port_or_known_default(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue