Commit graph

169 commits

Author SHA1 Message Date
Tim van der Lippe
36e4886da1
Implement basics of link preloading (#37036)
These changes allow a minimal set of checks for font-src
CSP checks to pass.

Part of #4577
Part of #35035

---------

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-05-29 11:26:27 +00:00
Martin Robinson
cf2b93f18a
libservo: Convert intercept_web_resource_load into load_web_resource (#35564)
Rework the `WebViewDelegate::intercept_web_resource_load` into
`WebViewDelegate::load_web_resource` and clean up internal messaging.
The main thing here is adding objects which manage the response to these
delegate methods. Now we have `WebResourceLoad` and
`InterceptedWebResourceLoad` which make it much harder to misuse the
API.

In addition, the internal messaging for this is cleaned up. Canceling
and finishing the load are unrelated to the HTTP body so they are no
longer subtypes of an HttpBodyData message. Processing of messages is
made a bit more efficient by collecting all body chunks in a vector and
only flattening the chunks at the end.

Finally, "interceptor" is a much more common spelling than "intercepter"
so I've gone ahead and made this change everywhere.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-02-21 14:36:42 +00:00
zhuhaichao518
a1326a7cf6
Implement WebResourceRequested Event. (#34961)
* Implement WebResourceRequested Event on the Embedder Layer

Signed-off-by: zhuhaichao518 <zhuhaichao518@gmail.com>

* fix and add test

Signed-off-by: zhuhaichao518 <zhuhaichao518@gmail.com>

* resolve comments

Signed-off-by: zhuhaichao518 <zhuhaichao518@gmail.com>

* remove sample code in webview

Signed-off-by: zhuhaichao518 <zhuhaichao518@gmail.com>

* remove typo

Signed-off-by: zhuhaichao518 <zhuhaichao518@gmail.com>

* ./mach format

Signed-off-by: zhuhaichao518 <zhuhaichao518@gmail.com>

* fix test fail caused by interception message

Signed-off-by: zhuhaichao518 <zhuhaichao518@gmail.com>

* update impl for is_for_main_frame

Signed-off-by: zhuhaichao518 <zhuhaichao518@gmail.com>

---------

Signed-off-by: zhuhaichao518 <zhuhaichao518@gmail.com>
2025-01-16 07:44:16 +00:00
arthmis
90c5685d61
add minimal implementation of FetchParams (#34833)
* add minimal implementation of fetchParams and fetch controller for cancellation support

fix something

removing fetch params from http network or cache fetch due to implementation difficult

Signed-off-by: Lloyd Massiah <artmis9@protonmail.com>

* run formatter

Signed-off-by: Lloyd Massiah <artmis9@protonmail.com>

* fix incorrect spec implementation and add comments with related step number and description

Signed-off-by: Lloyd Massiah <artmis9@protonmail.com>

* fix double borrow issue

Signed-off-by: Lloyd Massiah <artmis9@protonmail.com>

* remove unused code from FetchParams

Signed-off-by: Lloyd Massiah <artmis9@protonmail.com>

* add workaround for double mutable borrow error

Signed-off-by: Lloyd Massiah <artmis9@protonmail.com>

* remove unnecessary comments, move import and format

Signed-off-by: Lloyd Massiah <artmis9@protonmail.com>

* fix comments that state spec instructions

Signed-off-by: Lloyd Massiah <artmis9@protonmail.com>

* update comment

Signed-off-by: Lloyd Massiah <artmis9@protonmail.com>

* refactor tests

Signed-off-by: Lloyd Massiah <artmis9@protonmail.com>

* refactor tests

Signed-off-by: Lloyd Massiah <artmis9@protonmail.com>

---------

Signed-off-by: Lloyd Massiah <artmis9@protonmail.com>
Co-authored-by: lazypassion <25536767+lazypassion@users.noreply.github.com>
2025-01-12 14:37:25 +00:00
Cristian Brinza
c7a4e4f627
net: Refactor Decoder (#33611)
* Refactor Decoder to be fully async

Signed-off-by: crbrz <cristianb@gmail.com>

* Update WPT results

Signed-off-by: crbrz <cristianb@gmail.com>

* Fix deflate unit test

Signed-off-by: crbrz <cristianb@gmail.com>

* Add compressed response update count test

Signed-off-by: crbrz <cristianb@gmail.com>

* Fix typo

Signed-off-by: crbrz <cristianb@gmail.com>

* Source error check without conversion to String

Signed-off-by: crbrz <cristianb@gmail.com>

* Simplify error check

Signed-off-by: crbrz <cristianb@gmail.com>

* Fix variable name

Signed-off-by: crbrz <cristianb@gmail.com>

* Added TODO note for network.tls.ignore_unexpected_eof

Signed-off-by: crbrz <cristianb@gmail.com>

---------

Signed-off-by: crbrz <cristianb@gmail.com>
2024-10-02 16:59:31 +00:00
webbeef
663a92a5df
make protocol handlers registrable (#33104)
Signed-off-by: webbeef <me@webbeef.org>
2024-08-22 04:11:16 +00:00
Martin Robinson
7ea894774f
Add a directory listing feature for file URLs (#32580)
Signed-off-by: Bobulous <Bobulous@users.noreply.github.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Bobulous <Bobulous@users.noreply.github.com>
2024-06-26 08:02:50 +00:00
tannal
5c0199b568
Net: fold websocket and http tokio runtime into one (#31771)
* net: use the same tokio runtime in websocket loader

#31648

* readability

* license
2024-03-21 06:13:03 +00:00
Samson
711dbbd4af
remove extern crate (#30311)
* remove extern crate

* Update components/script_plugins/lib.rs

Co-authored-by: Martin Robinson <mrobinson@igalia.com>

---------

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2023-09-08 12:11:31 +00:00
Martin Robinson
bce7622cde
Switch to rustls and webpki-roots (#30025)
This change replaces OpenSSL with rustls and also the manually curated
CA certs file with webpki-roots (effectively the same thing, but as a
crate).

Generally speaking the design of the network stack is the same. Changes:

- Code around certificate overrides needed to be refactored to work with
  rustls so the various thread-safe list of certificates is refactored
  into `CertificateErrorOverrideManager`
- hyper-rustls takes care of setting ALPN protocols for HTTP requests,
  so for WebSockets this is moved to the WebSocket code.
- The safe set of cypher suites is chosen, which seem to correspond to
  the "Modern" configuration from [1]. This can be adjusted later.
- Instead of passing a string of PEM CA certificates around, an enum is
  used that includes parsed Certificates (or the default which reads
  them from webpki-roots).
- Code for starting up an SSL server for testing is cleaned up a little,
  due to the fact that the certificates need to be overriden explicitly
  now. This is due to the fact that the `webpki` crate is more stringent
  with self-signed certificates than SSL (CA certificates cannot used as
  end-entity certificates). [2]

1. https://wiki.mozilla.org/Security/Server_Side_TLS
2. https://github.com/briansmith/webpki/issues/114

Fixes #7888.
Fixes #13749.
Fixes #26835.
Fixes #29291.
2023-08-08 14:00:10 +00:00
Vincent Ricard
3b3824078d Fix some 'nosniff' tests 2021-03-08 21:24:08 +01:00
Simon Sapin
d4227b5b0d Remove some unused dependency declarations
This is based on compiling with `RUSTFLAGS="-W unused_crate_dependencies"` (CC https://github.com/rust-lang/rust/pull/72342) in a recent Nightly (more so than used in the tree as of this writing, CC https://github.com/servo/servo/issues/26661 for work-arounds).

Only one crate is actually removed from the dependency graph, others are still dependended from other places.
2020-05-29 00:04:34 +02:00
Simon Sapin
db4f27f361 Use the matches! macro from the standard library 2020-02-12 10:08:31 +01:00
Peter Hall
8bfd4dc1e2 #8539 Config preferences backend restructure 2019-03-20 15:01:26 +00:00
Josh Matthews
6404a0ef53 Redesign network response decoding to avoid creating decoders before some content is present. 2019-01-15 16:04:45 -05:00
Fernando Jiménez Moreno
a84442864d Add support fo byte range requests for blob URLs 2018-11-26 09:33:35 +01:00
Jan Andre Ikenmeyer
1d6fe65401
Update MPL license to https (part 4) 2018-11-19 14:47:27 +01:00
Simon Sapin
2012be4a8b cargo fix --edition-idioms 2018-11-08 09:28:00 +01:00
Pyfisch
9e92eb205a Reorder imports 2018-11-06 22:35:07 +01:00
Simon Sapin
45f7199eee cargo fix --edition 2018-11-06 15:26:02 +01:00
Pyfisch
2481ad25f8 Rustfmt net crate 2018-11-03 15:29:01 +01:00
Bastien Orivel
024b40b39d Update hyper to 0.12 2018-11-01 19:17:36 +01:00
Anthony Ramine
784fbb2bc1 Merge some byte swap/premultiply functions in their own crate 2018-10-06 01:11:55 +02:00
Simon Sapin
2a996fbc8f Replace mpsc with crossbeam/servo channel, update ipc-channel
Co-authored-by: Gregory Terzian <gterzian@users.noreply.github.com>
2018-09-12 13:33:32 +08:00
Bastien Orivel
2e11bc10fb Replace servo-websocket by ws
This is heavily based on previous work done in #16012.

Fixes #14517
2018-08-15 16:53:48 +02:00
Gregory Terzian
d438240772 move msg to embedder_traits, use in script, handle send error in embedder 2018-05-23 21:45:57 +08:00
OJ Kwon
2fab94785b
refactor(filemanager): uses embedderproxy directly 2018-04-27 12:23:25 -07:00
OJ Kwon
f69b124444
refactor(filemanager): remove awareness to ui behavior 2018-04-27 12:21:18 -07:00
OJ Kwon
1c465bcd66
refactor(resourcethread): expose constellationmsg channel 2018-04-27 12:21:16 -07:00
Paul Rouget
9fb5795f37 delegate resource reading to embedder 2018-04-27 15:34:52 +08:00
modal-d17
af445a357d Measure cache memory usage (#19251):
Made the memory cache data structure derive MallocSizeOf, along with
manual size_of() implementations in malloc_size_of.

Added a Measurable struct that acts as a container for fields size_of() can be called for.

Added a new IpcReceiver used for listening to messages from the memory profiler,
and used run_with_memory reporting to register a memory reporter in the thread.
Now when a message from the memory profiler arrives, report includes sizes of public and private http caches.

Updated test file.
2018-04-01 13:30:57 -04:00
Simon Sapin
eb3652b3c6 Replace parse-hosts crate with 10 lines of code.
This removes 3927 lines of Rust code in 6 crates from the dependency graph:
parse-hosts, multistr, bow, extra-default, len-trait, and push-trait.

One of these crates doesn’t build in today’s Nightly:
https://github.com/rust-lang/rust/issues/46328
2017-11-28 16:19:29 +01:00
Josh Matthews
f674cba612 Beginnings of a http cache
Doom cache entries based on the initial response, and prevent matching against doomed cache enties.

Evict cache entries that have passed their expiry date instead of matching them.

Document the cache. Refactor incomplete entries to lessen Option-itis.

Revalidate expired cache entries instead of unconditionally evicting them.

Forbid missing docs in cache code.

Revalidate must-revalidate entries.

Fetch content tests from a local HTTP server.

Track requests made to the test HTTP server.

Add a simple test that a cached resource with no expiry is not revalidated. Correct inverted expiry check in revalidation code.

Fix incorrect revalidation logic that dropped the consumer channels on the floor.

Ensure that requests are cached based on their request headers.

Run a separate http server instance for each test to avoid intermittent failures due to concurrent cache tests.

Add a test for uncacheable responses.

Address review comments.
2017-11-14 17:20:39 +08:00
Simon Sapin
aa5761a5fb Remove usage of unstable box syntax, except in the script crate
… because there’s a lot of it,
and script still uses any other unstable features anyway.
2017-10-12 12:10:56 +02:00
Simon Sapin
cbcc7d0802 Remove usage of unstable feature iterator_step_by 2017-10-11 20:17:16 +02:00
Martin Robinson
e58e8ab42e Upgrade to the latest version of WebRender 2017-07-13 07:44:08 +10:00
Simon Sapin
605ef8b7ec Remove explicit dependencies on serde_derive 2017-06-16 13:58:21 +02:00
Anthony Ramine
4c8a0f0626 Update Rust nightly to 1.19.0-nightly (2416e222e 2017-06-09) 2017-06-09 11:12:42 +02:00
Anthony Ramine
56c961af5a Revert "Update Rust nightly to 1.19.0-nightly (6165203c4 2017-06-03)"
This reverts commit f081380dc0.
2017-06-03 14:37:17 +02:00
Anthony Ramine
f081380dc0 Update Rust nightly to 1.19.0-nightly (6165203c4 2017-06-03) 2017-06-03 13:35:55 +02:00
Nikhil Shagrithaya
541baafe1c Redirect document loads manually 2017-05-31 17:28:53 +05:30
Josh Matthews
6f590a87bf Move hosts module into net crate. Remove obsolete functions. 2017-04-06 19:25:47 +09:00
Anthony Ramine
016fee016b Move the HTTP connector to FetchContext 2017-04-03 12:47:33 +02:00
ddh
e527c9a991 Update Hyper and OpenSSL 2017-03-31 16:32:21 +02:00
Fernando Jiménez Moreno
166c4e8bb2 Move image cache implementation to the net crate 2017-03-27 19:54:15 +02:00
Fernando Jiménez Moreno
72d7ee613b Make image cache per-document rather than global 2017-03-27 19:54:13 +02:00
Anthony Ramine
0ed4df28b5 Replace use of rustc_serialize::base64 by base64 2017-03-26 14:15:31 +02:00
Jamie Nicol
ec3142e811 Premultiply RGBA image data before sending to webrender 2017-03-10 11:06:44 +10:00
Ms2ger
5a61d8b2ea Remove unused content blocker code.
I don't know what it is for, so I believe it would be better to remove it
entirely until and unless we start using it.
2017-03-07 10:29:27 +01:00
Anthony Ramine
fd9cd33892 Use serde_json to persist cookies in the net crate 2017-02-22 12:33:10 +01:00