Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3.4k
HTTP archive support project
Josh Matthews edited this pageSep 25, 2017 ·4 revisions
Background information: Major browsers supportcreating HTTP archive files which can be analyzed by other tools. Adding native support for this feature to Servo will allow us to compare our network performance more precisely against other browsers.
Tracking issue:https://github.com/servo/servo/issues/4004 (please ask questions here)
Initial steps:
- email themozilla.dev.servo mailing list (be sure to subscribe to it first!) introducing your group and asking any necessary questions
- add therust-har library as adependency of thenet_traits component
- define anenum that represents either a filename or anIpcSender that can send a vector ofhar::Log values
- using the new enum, add a new optional member toResourceChannelManager that is initialized via create_resource_threads
- modify theCoreResourceMsg::Exit message to contain an optional vector ofhar::Page values
- add acommand line flag that controls whether to store HAR data. The flag should accept a filename argument.
- using this new global option, pass an appropriate argument when calling
new_resource_threadsincreate_constellation - when processing theCoreResourseMsg::Exit message, send an empty vector or write an empty vector as JSON to an appropriate file depending on the member variable that was added earlier
Subsequent steps:
- Store a vector of
har::PageinConstellation- when a new pipeline is created (
Constellation::new_pipeline), add an entry to this vector using the pipeline ID as the page's unique id
- when a new pipeline is created (
- Store a vector of
har::Entryvalues inCoreResourceManager, wrapped insideArcandMutextypes to allow other threads to manipulate the vector- add a
Arc<Mutex<Vec<har::Entry>>>member to theFetchContextstructure, and initialize it from the resource manager's new field - inhttp_fetch, create a new
har::Requestinstance based on the values available from therequest variable - before step 5 of
http_fetch, create a newhar::Responsevalue based on the values available from theresponse variable - create a new
har::Entryvalue and append it to the vector stored inFetchContext, using the request'spipeline_idfield as thepagerefvalue to associate it with the pages stored in theConstellation - during
Constellation::handle_shutdownas part of theCoreResourceMsg::Exitmessage send the vector ofhar::Pagevalues - when the resource thread receives this message (
CoreResourceManager::process_msg), if there is a vector present then combine the provided Page and member Entry values and process them according to the member variable (either sending them on the channel or writing them to a file)
- add a
- add a unit test to ensure that the resource thread logs the HAR information correctly:
- create a resource manager with an IpcSender as the HAR output
- start an HTTP server and fetch a URL from it by sending a CoreResourceMsg::Fetch message to the resource manager
- Once the fetch is complete, send the exit message to the resource manager with a har::Page value for the single fetch (acting as the Constellation)
- assert that the expected har::Log value is received from the resource thread