Skip to content

Create an HTTP global state object #10175

Closed

Description

@jdm

We pass around stuff like the cookie storage, the HSTS list, the HTTP authentication cache, etc. in http_loader.rs. This also means that the unit tests have a lot of repeated initialization code that creates these objects even when they're not used. I propose we wrap them up in a struct and give it a argument-less constructor to make reading the code easier and require fewer changes when adding additional global HTTP state.

Code: components/net/http_loader.rs, components/net/resource_thread.rs, tests/unit/net/http_loader.rs

Activity

  1. added
    E-less-complex
    I-refactor
    on Mar 24, 2016
  2. notriddle commented on Mar 24, 2016

    @notriddle
    Contributor

    You would still be passing around that one object, right?

  3. jdm commented on Mar 24, 2016

    @jdm
    MemberAuthor

    Yes.

  4. cbrewster commented on Mar 24, 2016

    @cbrewster
    Contributor

    Should this state object include things like LoadData, or only things that can be initialized without any parameters?

    ex. LoadData is setup in a test like:

    let mut load_data = LoadData::new(LoadContext::Browsing, url.clone(), None);
    load_data.data = None;
    load_data.method = Method::Get;
    
  5. jdm commented on Mar 24, 2016

    @jdm
    MemberAuthor

    LoadData is a per-request object, so it would not be included.

  6. cbrewster commented on Mar 24, 2016

    @cbrewster
    Contributor

    @jdm ok makes sense, currently I have:

    hsts_list
    cookie_jar
    auth_cache
    

    included in the http global state object, should anything else be included/excluded?

  7. added
    C-assigned
    on Mar 25, 2016
  8. added a commit that references this issue on Mar 26, 2016
  9. cbrewster commented on Mar 26, 2016

    @cbrewster
    Contributor

    Issue resolved in PR #10188.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-networkC-assignedE-less-complexI-refactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions